mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-17 14:11:53 -06:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e021179cd | ||
|
|
0dc16c691d | ||
|
|
f08f4dcc3c | ||
|
|
83f8ddcc5b | ||
|
|
35596517f2 | ||
|
|
de4f8c22fe | ||
|
|
b75af1bba6 | ||
|
|
c65230d858 | ||
|
|
2eb60a0598 | ||
|
|
044e4bb741 | ||
|
|
e279500d76 | ||
|
|
708873490e |
0
Asm/arm/7zCrcOpt.asm
Executable file → Normal file
0
Asm/arm/7zCrcOpt.asm
Executable file → Normal file
28
Asm/x86/7zAsm.asm
Executable file → Normal file
28
Asm/x86/7zAsm.asm
Executable file → Normal file
@@ -1,5 +1,5 @@
|
|||||||
; 7zAsm.asm -- ASM macros
|
; 7zAsm.asm -- ASM macros
|
||||||
; 2009-12-12 : Igor Pavlov : Public domain
|
; 2012-12-30 : Igor Pavlov : Public domain
|
||||||
|
|
||||||
MY_ASM_START macro
|
MY_ASM_START macro
|
||||||
ifdef x64
|
ifdef x64
|
||||||
@@ -13,30 +13,34 @@ endm
|
|||||||
|
|
||||||
MY_PROC macro name:req, numParams:req
|
MY_PROC macro name:req, numParams:req
|
||||||
align 16
|
align 16
|
||||||
proc_numParams equ numParams
|
proc_numParams = numParams
|
||||||
ifdef x64
|
ifdef x64
|
||||||
proc_name equ name
|
proc_name equ name
|
||||||
name PROC
|
|
||||||
else
|
else
|
||||||
proc_fastcall_name equ @CatStr(@,name,@, %numParams * 4)
|
proc_name equ @CatStr(@,name,@, %numParams * 4)
|
||||||
public proc_fastcall_name
|
|
||||||
proc_fastcall_name:
|
|
||||||
endif
|
endif
|
||||||
|
proc_name PROC
|
||||||
endm
|
endm
|
||||||
|
|
||||||
MY_ENDP macro
|
MY_ENDP macro
|
||||||
ifdef x64
|
ifdef x64
|
||||||
ret
|
ret
|
||||||
proc_name ENDP
|
|
||||||
else
|
else
|
||||||
ret (proc_numParams - 2) * 4
|
if proc_numParams LT 3
|
||||||
|
ret
|
||||||
|
else
|
||||||
|
ret (proc_numParams - 2) * 4
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
proc_name ENDP
|
||||||
endm
|
endm
|
||||||
|
|
||||||
ifdef x64
|
ifdef x64
|
||||||
REG_SIZE equ 8
|
REG_SIZE equ 8
|
||||||
|
REG_LOGAR_SIZE equ 3
|
||||||
else
|
else
|
||||||
REG_SIZE equ 4
|
REG_SIZE equ 4
|
||||||
|
REG_LOGAR_SIZE equ 2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
x0 equ EAX
|
x0 equ EAX
|
||||||
@@ -67,6 +71,14 @@ ifdef x64
|
|||||||
r5 equ RBP
|
r5 equ RBP
|
||||||
r6 equ RSI
|
r6 equ RSI
|
||||||
r7 equ RDI
|
r7 equ RDI
|
||||||
|
x8 equ r8d
|
||||||
|
x9 equ r9d
|
||||||
|
x10 equ r10d
|
||||||
|
x11 equ r11d
|
||||||
|
x12 equ r12d
|
||||||
|
x13 equ r13d
|
||||||
|
x14 equ r14d
|
||||||
|
x15 equ r15d
|
||||||
else
|
else
|
||||||
r0 equ x0
|
r0 equ x0
|
||||||
r1 equ x1
|
r1 equ x1
|
||||||
|
|||||||
0
Asm/x86/7zCrcOpt.asm
Executable file → Normal file
0
Asm/x86/7zCrcOpt.asm
Executable file → Normal file
0
Asm/x86/AesOpt.asm
Executable file → Normal file
0
Asm/x86/AesOpt.asm
Executable file → Normal file
205
Asm/x86/XzCrc64Opt.asm
Normal file
205
Asm/x86/XzCrc64Opt.asm
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
; XzCrc64Opt.asm -- CRC64 calculation : optimized version
|
||||||
|
; 2011-06-28 : Igor Pavlov : Public domain
|
||||||
|
|
||||||
|
include 7zAsm.asm
|
||||||
|
|
||||||
|
MY_ASM_START
|
||||||
|
|
||||||
|
ifdef x64
|
||||||
|
|
||||||
|
rD equ r9
|
||||||
|
rN equ r10
|
||||||
|
|
||||||
|
num_VAR equ r8
|
||||||
|
table_VAR equ r9
|
||||||
|
|
||||||
|
SRCDAT equ rN + rD
|
||||||
|
|
||||||
|
CRC_XOR macro dest:req, src:req, t:req
|
||||||
|
xor dest, QWORD PTR [r5 + src * 8 + 0800h * t]
|
||||||
|
endm
|
||||||
|
|
||||||
|
CRC1b macro
|
||||||
|
movzx x6, BYTE PTR [rD]
|
||||||
|
inc rD
|
||||||
|
movzx x3, x0_L
|
||||||
|
xor x6, x3
|
||||||
|
shr r0, 8
|
||||||
|
CRC_XOR r0, r6, 0
|
||||||
|
dec rN
|
||||||
|
endm
|
||||||
|
|
||||||
|
MY_PROLOG macro crc_end:req
|
||||||
|
MY_PUSH_4_REGS
|
||||||
|
|
||||||
|
mov r0, r1
|
||||||
|
mov rN, num_VAR
|
||||||
|
mov r5, table_VAR
|
||||||
|
mov rD, r2
|
||||||
|
test rN, rN
|
||||||
|
jz crc_end
|
||||||
|
@@:
|
||||||
|
test rD, 3
|
||||||
|
jz @F
|
||||||
|
CRC1b
|
||||||
|
jnz @B
|
||||||
|
@@:
|
||||||
|
cmp rN, 8
|
||||||
|
jb crc_end
|
||||||
|
add rN, rD
|
||||||
|
mov num_VAR, rN
|
||||||
|
sub rN, 4
|
||||||
|
and rN, NOT 3
|
||||||
|
sub rD, rN
|
||||||
|
mov x1, [SRCDAT]
|
||||||
|
xor r0, r1
|
||||||
|
add rN, 4
|
||||||
|
endm
|
||||||
|
|
||||||
|
MY_EPILOG macro crc_end:req
|
||||||
|
sub rN, 4
|
||||||
|
mov x1, [SRCDAT]
|
||||||
|
xor r0, r1
|
||||||
|
mov rD, rN
|
||||||
|
mov rN, num_VAR
|
||||||
|
sub rN, rD
|
||||||
|
crc_end:
|
||||||
|
test rN, rN
|
||||||
|
jz @F
|
||||||
|
CRC1b
|
||||||
|
jmp crc_end
|
||||||
|
@@:
|
||||||
|
MY_POP_4_REGS
|
||||||
|
endm
|
||||||
|
|
||||||
|
MY_PROC XzCrc64UpdateT4, 4
|
||||||
|
MY_PROLOG crc_end_4
|
||||||
|
align 16
|
||||||
|
main_loop_4:
|
||||||
|
mov x1, [SRCDAT]
|
||||||
|
movzx x2, x0_L
|
||||||
|
movzx x3, x0_H
|
||||||
|
shr r0, 16
|
||||||
|
movzx x6, x0_L
|
||||||
|
movzx x7, x0_H
|
||||||
|
shr r0, 16
|
||||||
|
CRC_XOR r1, r2, 3
|
||||||
|
CRC_XOR r0, r3, 2
|
||||||
|
CRC_XOR r1, r6, 1
|
||||||
|
CRC_XOR r0, r7, 0
|
||||||
|
xor r0, r1
|
||||||
|
|
||||||
|
add rD, 4
|
||||||
|
jnz main_loop_4
|
||||||
|
|
||||||
|
MY_EPILOG crc_end_4
|
||||||
|
MY_ENDP
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
rD equ r1
|
||||||
|
rN equ r7
|
||||||
|
|
||||||
|
crc_val equ (REG_SIZE * 5)
|
||||||
|
crc_table equ (8 + crc_val)
|
||||||
|
table_VAR equ [r4 + crc_table]
|
||||||
|
num_VAR equ table_VAR
|
||||||
|
|
||||||
|
|
||||||
|
SRCDAT equ rN + rD
|
||||||
|
|
||||||
|
CRC macro op0:req, op1:req, dest0:req, dest1:req, src:req, t:req
|
||||||
|
op0 dest0, DWORD PTR [r5 + src * 8 + 0800h * t]
|
||||||
|
op1 dest1, DWORD PTR [r5 + src * 8 + 0800h * t + 4]
|
||||||
|
endm
|
||||||
|
|
||||||
|
CRC_XOR macro dest0:req, dest1:req, src:req, t:req
|
||||||
|
CRC xor, xor, dest0, dest1, src, t
|
||||||
|
endm
|
||||||
|
|
||||||
|
|
||||||
|
CRC1b macro
|
||||||
|
movzx x6, BYTE PTR [rD]
|
||||||
|
inc rD
|
||||||
|
movzx x3, x0_L
|
||||||
|
xor x6, x3
|
||||||
|
shrd r0, r2, 8
|
||||||
|
shr r2, 8
|
||||||
|
CRC_XOR r0, r2, r6, 0
|
||||||
|
dec rN
|
||||||
|
endm
|
||||||
|
|
||||||
|
MY_PROLOG macro crc_end:req
|
||||||
|
MY_PUSH_4_REGS
|
||||||
|
|
||||||
|
mov rN, r2
|
||||||
|
|
||||||
|
mov x0, [r4 + crc_val]
|
||||||
|
mov x2, [r4 + crc_val + 4]
|
||||||
|
mov r5, table_VAR
|
||||||
|
test rN, rN
|
||||||
|
jz crc_end
|
||||||
|
@@:
|
||||||
|
test rD, 3
|
||||||
|
jz @F
|
||||||
|
CRC1b
|
||||||
|
jnz @B
|
||||||
|
@@:
|
||||||
|
cmp rN, 8
|
||||||
|
jb crc_end
|
||||||
|
add rN, rD
|
||||||
|
|
||||||
|
mov num_VAR, rN
|
||||||
|
|
||||||
|
sub rN, 4
|
||||||
|
and rN, NOT 3
|
||||||
|
sub rD, rN
|
||||||
|
xor r0, [SRCDAT]
|
||||||
|
add rN, 4
|
||||||
|
endm
|
||||||
|
|
||||||
|
MY_EPILOG macro crc_end:req
|
||||||
|
sub rN, 4
|
||||||
|
xor r0, [SRCDAT]
|
||||||
|
|
||||||
|
mov rD, rN
|
||||||
|
mov rN, num_VAR
|
||||||
|
sub rN, rD
|
||||||
|
crc_end:
|
||||||
|
test rN, rN
|
||||||
|
jz @F
|
||||||
|
CRC1b
|
||||||
|
jmp crc_end
|
||||||
|
@@:
|
||||||
|
MY_POP_4_REGS
|
||||||
|
endm
|
||||||
|
|
||||||
|
MY_PROC XzCrc64UpdateT4, 5
|
||||||
|
MY_PROLOG crc_end_4
|
||||||
|
movzx x6, x0_L
|
||||||
|
align 16
|
||||||
|
main_loop_4:
|
||||||
|
mov r3, [SRCDAT]
|
||||||
|
xor r3, r2
|
||||||
|
|
||||||
|
CRC xor, mov, r3, r2, r6, 3
|
||||||
|
movzx x6, x0_H
|
||||||
|
shr r0, 16
|
||||||
|
CRC_XOR r3, r2, r6, 2
|
||||||
|
|
||||||
|
movzx x6, x0_L
|
||||||
|
movzx x0, x0_H
|
||||||
|
CRC_XOR r3, r2, r6, 1
|
||||||
|
CRC_XOR r3, r2, r0, 0
|
||||||
|
movzx x6, x3_L
|
||||||
|
mov r0, r3
|
||||||
|
|
||||||
|
add rD, 4
|
||||||
|
jnz main_loop_4
|
||||||
|
|
||||||
|
MY_EPILOG crc_end_4
|
||||||
|
MY_ENDP
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
end
|
||||||
177
C/7z.h
Executable file → Normal file
177
C/7z.h
Executable file → Normal file
@@ -1,58 +1,34 @@
|
|||||||
/* 7z.h -- 7z interface
|
/* 7z.h -- 7z interface
|
||||||
2010-03-11 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_H
|
#ifndef __7Z_H
|
||||||
#define __7Z_H
|
#define __7Z_H
|
||||||
|
|
||||||
#include "7zBuf.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
#define k7zStartHeaderSize 0x20
|
#define k7zStartHeaderSize 0x20
|
||||||
#define k7zSignatureSize 6
|
#define k7zSignatureSize 6
|
||||||
extern Byte k7zSignature[k7zSignatureSize];
|
|
||||||
#define k7zMajorVersion 0
|
|
||||||
|
|
||||||
enum EIdEnum
|
extern Byte k7zSignature[k7zSignatureSize];
|
||||||
{
|
|
||||||
k7zIdEnd,
|
|
||||||
k7zIdHeader,
|
|
||||||
k7zIdArchiveProperties,
|
|
||||||
k7zIdAdditionalStreamsInfo,
|
|
||||||
k7zIdMainStreamsInfo,
|
|
||||||
k7zIdFilesInfo,
|
|
||||||
k7zIdPackInfo,
|
|
||||||
k7zIdUnpackInfo,
|
|
||||||
k7zIdSubStreamsInfo,
|
|
||||||
k7zIdSize,
|
|
||||||
k7zIdCRC,
|
|
||||||
k7zIdFolder,
|
|
||||||
k7zIdCodersUnpackSize,
|
|
||||||
k7zIdNumUnpackStream,
|
|
||||||
k7zIdEmptyStream,
|
|
||||||
k7zIdEmptyFile,
|
|
||||||
k7zIdAnti,
|
|
||||||
k7zIdName,
|
|
||||||
k7zIdCTime,
|
|
||||||
k7zIdATime,
|
|
||||||
k7zIdMTime,
|
|
||||||
k7zIdWinAttributes,
|
|
||||||
k7zIdComment,
|
|
||||||
k7zIdEncodedHeader,
|
|
||||||
k7zIdStartPos,
|
|
||||||
k7zIdDummy
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UInt32 NumInStreams;
|
const Byte *Data;
|
||||||
UInt32 NumOutStreams;
|
size_t Size;
|
||||||
UInt64 MethodID;
|
} CSzData;
|
||||||
CBuf Props;
|
|
||||||
} CSzCoderInfo;
|
|
||||||
|
|
||||||
void SzCoderInfo_Init(CSzCoderInfo *p);
|
/* CSzCoderInfo & CSzFolder support only default methods */
|
||||||
void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc);
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
size_t PropsOffset;
|
||||||
|
UInt32 MethodID;
|
||||||
|
Byte NumInStreams;
|
||||||
|
Byte NumOutStreams;
|
||||||
|
Byte PropsSize;
|
||||||
|
} CSzCoderInfo;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -60,30 +36,35 @@ typedef struct
|
|||||||
UInt32 OutIndex;
|
UInt32 OutIndex;
|
||||||
} CSzBindPair;
|
} CSzBindPair;
|
||||||
|
|
||||||
|
#define SZ_NUM_CODERS_IN_FOLDER_MAX 4
|
||||||
|
#define SZ_NUM_BINDS_IN_FOLDER_MAX 3
|
||||||
|
#define SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX 4
|
||||||
|
#define SZ_NUM_CODERS_OUT_STREAMS_IN_FOLDER_MAX 4
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CSzCoderInfo *Coders;
|
|
||||||
CSzBindPair *BindPairs;
|
|
||||||
UInt32 *PackStreams;
|
|
||||||
UInt64 *UnpackSizes;
|
|
||||||
UInt32 NumCoders;
|
UInt32 NumCoders;
|
||||||
UInt32 NumBindPairs;
|
UInt32 NumBindPairs;
|
||||||
UInt32 NumPackStreams;
|
UInt32 NumPackStreams;
|
||||||
int UnpackCRCDefined;
|
UInt32 MainOutStream;
|
||||||
UInt32 UnpackCRC;
|
UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX];
|
||||||
|
CSzBindPair BindPairs[SZ_NUM_BINDS_IN_FOLDER_MAX];
|
||||||
UInt32 NumUnpackStreams;
|
CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX];
|
||||||
|
UInt64 CodersUnpackSizes[SZ_NUM_CODERS_OUT_STREAMS_IN_FOLDER_MAX];
|
||||||
} CSzFolder;
|
} CSzFolder;
|
||||||
|
|
||||||
void SzFolder_Init(CSzFolder *p);
|
/*
|
||||||
UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
|
typedef struct
|
||||||
int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex);
|
{
|
||||||
UInt32 SzFolder_GetNumOutStreams(CSzFolder *p);
|
size_t CodersDataOffset;
|
||||||
UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
|
size_t UnpackSizeDataOffset;
|
||||||
|
// UInt32 StartCoderUnpackSizesIndex;
|
||||||
|
UInt32 StartPackStreamIndex;
|
||||||
|
// UInt32 IndexOfMainOutStream;
|
||||||
|
} CSzFolder2;
|
||||||
|
*/
|
||||||
|
|
||||||
SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes,
|
SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd, CSzData *sdSizes);
|
||||||
ILookInStream *stream, UInt64 startPos,
|
|
||||||
Byte *outBuffer, size_t outSize, ISzAlloc *allocMain);
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -93,35 +74,46 @@ typedef struct
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CNtfsFileTime MTime;
|
Byte *Defs; /* MSB 0 bit numbering */
|
||||||
UInt64 Size;
|
UInt32 *Vals;
|
||||||
UInt32 Crc;
|
} CSzBitUi32s;
|
||||||
UInt32 Attrib;
|
|
||||||
Byte HasStream;
|
typedef struct
|
||||||
Byte IsDir;
|
{
|
||||||
Byte IsAnti;
|
Byte *Defs; /* MSB 0 bit numbering */
|
||||||
Byte CrcDefined;
|
// UInt64 *Vals;
|
||||||
Byte MTimeDefined;
|
CNtfsFileTime *Vals;
|
||||||
Byte AttribDefined;
|
} CSzBitUi64s;
|
||||||
} CSzFileItem;
|
|
||||||
|
#define SzBitArray_Check(p, i) (((p)[(i) >> 3] & (0x80 >> ((i) & 7))) != 0)
|
||||||
void SzFile_Init(CSzFileItem *p);
|
|
||||||
|
#define SzBitWithVals_Check(p, i) ((p)->Defs && ((p)->Defs[(i) >> 3] & (0x80 >> ((i) & 7))) != 0)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UInt64 *PackSizes;
|
|
||||||
Byte *PackCRCsDefined;
|
|
||||||
UInt32 *PackCRCs;
|
|
||||||
CSzFolder *Folders;
|
|
||||||
CSzFileItem *Files;
|
|
||||||
UInt32 NumPackStreams;
|
UInt32 NumPackStreams;
|
||||||
UInt32 NumFolders;
|
UInt32 NumFolders;
|
||||||
UInt32 NumFiles;
|
|
||||||
|
UInt64 *PackPositions; // NumPackStreams + 1
|
||||||
|
CSzBitUi32s FolderCRCs;
|
||||||
|
|
||||||
|
size_t *FoCodersOffsets;
|
||||||
|
size_t *FoSizesOffsets;
|
||||||
|
// UInt32 StartCoderUnpackSizesIndex;
|
||||||
|
UInt32 *FoStartPackStreamIndex;
|
||||||
|
|
||||||
|
// CSzFolder2 *Folders; // +1 item for sum values
|
||||||
|
Byte *CodersData;
|
||||||
|
Byte *UnpackSizesData;
|
||||||
|
size_t UnpackSizesDataSize;
|
||||||
|
// UInt64 *CoderUnpackSizes;
|
||||||
} CSzAr;
|
} CSzAr;
|
||||||
|
|
||||||
void SzAr_Init(CSzAr *p);
|
|
||||||
void SzAr_Free(CSzAr *p, ISzAlloc *alloc);
|
|
||||||
|
|
||||||
|
SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,
|
||||||
|
ILookInStream *stream, UInt64 startPos,
|
||||||
|
Byte *outBuffer, size_t outSize,
|
||||||
|
ISzAlloc *allocMain);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SzExtract extracts file from archive
|
SzExtract extracts file from archive
|
||||||
@@ -150,15 +142,30 @@ typedef struct
|
|||||||
UInt64 startPosAfterHeader;
|
UInt64 startPosAfterHeader;
|
||||||
UInt64 dataPos;
|
UInt64 dataPos;
|
||||||
|
|
||||||
UInt32 *FolderStartPackStreamIndex;
|
UInt32 NumFiles;
|
||||||
UInt64 *PackStreamStartPositions;
|
|
||||||
UInt32 *FolderStartFileIndex;
|
UInt64 *UnpackPositions;
|
||||||
|
// Byte *IsEmptyFiles;
|
||||||
|
Byte *IsDirs;
|
||||||
|
CSzBitUi32s CRCs;
|
||||||
|
|
||||||
|
CSzBitUi32s Attribs;
|
||||||
|
// CSzBitUi32s Parents;
|
||||||
|
CSzBitUi64s MTime;
|
||||||
|
CSzBitUi64s CTime;
|
||||||
|
|
||||||
|
// UInt32 *FolderStartPackStreamIndex;
|
||||||
|
UInt32 *FolderStartFileIndex; // + 1
|
||||||
UInt32 *FileIndexToFolderIndexMap;
|
UInt32 *FileIndexToFolderIndexMap;
|
||||||
|
|
||||||
size_t *FileNameOffsets; /* in 2-byte steps */
|
size_t *FileNameOffsets; /* in 2-byte steps */
|
||||||
CBuf FileNames; /* UTF-16-LE */
|
Byte *FileNames; /* UTF-16-LE */
|
||||||
} CSzArEx;
|
} CSzArEx;
|
||||||
|
|
||||||
|
#define SzArEx_IsDir(p, i) (SzBitArray_Check((p)->IsDirs, i))
|
||||||
|
|
||||||
|
#define SzArEx_GetFileSize(p, i) ((p)->UnpackPositions[(i) + 1] - (p)->UnpackPositions[i])
|
||||||
|
|
||||||
void SzArEx_Init(CSzArEx *p);
|
void SzArEx_Init(CSzArEx *p);
|
||||||
void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc);
|
void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc);
|
||||||
UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);
|
UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);
|
||||||
@@ -172,6 +179,11 @@ if dest != NULL, the return value specifies the number of 16-bit characters that
|
|||||||
|
|
||||||
size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
|
size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
|
||||||
|
|
||||||
|
/*
|
||||||
|
size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex);
|
||||||
|
UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
|
||||||
|
*/
|
||||||
|
|
||||||
SRes SzArEx_Extract(
|
SRes SzArEx_Extract(
|
||||||
const CSzArEx *db,
|
const CSzArEx *db,
|
||||||
ILookInStream *inStream,
|
ILookInStream *inStream,
|
||||||
@@ -196,7 +208,8 @@ SZ_ERROR_INPUT_EOF
|
|||||||
SZ_ERROR_FAIL
|
SZ_ERROR_FAIL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp);
|
SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream,
|
||||||
|
ISzAlloc *allocMain, ISzAlloc *allocTemp);
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
|
||||||
|
|||||||
5
C/Util/7z/7zAlloc.c → C/7zAlloc.c
Executable file → Normal file
5
C/Util/7z/7zAlloc.c → C/7zAlloc.c
Executable file → Normal file
@@ -1,7 +1,8 @@
|
|||||||
/* 7zAlloc.c -- Allocation functions
|
/* 7zAlloc.c -- Allocation functions
|
||||||
2008-10-04 : Igor Pavlov : Public domain */
|
2010-10-29 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "7zAlloc.h"
|
#include "7zAlloc.h"
|
||||||
|
|
||||||
/* #define _SZ_ALLOC_DEBUG */
|
/* #define _SZ_ALLOC_DEBUG */
|
||||||
12
C/Util/7z/7zAlloc.h → C/7zAlloc.h
Executable file → Normal file
12
C/Util/7z/7zAlloc.h → C/7zAlloc.h
Executable file → Normal file
@@ -1,14 +1,10 @@
|
|||||||
/* 7zAlloc.h -- Allocation functions
|
/* 7zAlloc.h -- Allocation functions
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2010-10-29 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_ALLOC_H
|
#ifndef __7Z_ALLOC_H
|
||||||
#define __7Z_ALLOC_H
|
#define __7Z_ALLOC_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void *SzAlloc(void *p, size_t size);
|
void *SzAlloc(void *p, size_t size);
|
||||||
void SzFree(void *p, void *address);
|
void SzFree(void *p, void *address);
|
||||||
@@ -16,8 +12,4 @@ void SzFree(void *p, void *address);
|
|||||||
void *SzAllocTemp(void *p, size_t size);
|
void *SzAllocTemp(void *p, size_t size);
|
||||||
void SzFreeTemp(void *p, void *address);
|
void SzFreeTemp(void *p, void *address);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
1839
C/7zArcIn.c
Normal file
1839
C/7zArcIn.c
Normal file
File diff suppressed because it is too large
Load Diff
6
C/7zBuf.c
Executable file → Normal file
6
C/7zBuf.c
Executable file → Normal file
@@ -1,7 +1,7 @@
|
|||||||
/* 7zBuf.c -- Byte Buffer
|
/* 7zBuf.c -- Byte Buffer
|
||||||
2008-03-28
|
2013-01-21 : Igor Pavlov : Public domain */
|
||||||
Igor Pavlov
|
|
||||||
Public domain */
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "7zBuf.h"
|
#include "7zBuf.h"
|
||||||
|
|
||||||
|
|||||||
12
C/7zBuf.h
Executable file → Normal file
12
C/7zBuf.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* 7zBuf.h -- Byte Buffer
|
/* 7zBuf.h -- Byte Buffer
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_BUF_H
|
#ifndef __7Z_BUF_H
|
||||||
#define __7Z_BUF_H
|
#define __7Z_BUF_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -32,8 +30,6 @@ void DynBuf_SeekToBeg(CDynBuf *p);
|
|||||||
int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc);
|
int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc);
|
||||||
void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc);
|
void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
5
C/7zBuf2.c
Executable file → Normal file
5
C/7zBuf2.c
Executable file → Normal file
@@ -1,7 +1,10 @@
|
|||||||
/* 7zBuf2.c -- Byte Buffer
|
/* 7zBuf2.c -- Byte Buffer
|
||||||
2008-10-04 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "7zBuf.h"
|
#include "7zBuf.h"
|
||||||
|
|
||||||
void DynBuf_Construct(CDynBuf *p)
|
void DynBuf_Construct(CDynBuf *p)
|
||||||
|
|||||||
69
C/7zCrc.c
Executable file → Normal file
69
C/7zCrc.c
Executable file → Normal file
@@ -1,41 +1,33 @@
|
|||||||
/* 7zCrc.c -- CRC32 calculation
|
/* 7zCrc.c -- CRC32 init
|
||||||
2009-11-23 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "7zCrc.h"
|
#include "7zCrc.h"
|
||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
|
|
||||||
#define kCrcPoly 0xEDB88320
|
#define kCrcPoly 0xEDB88320
|
||||||
|
|
||||||
#ifdef MY_CPU_LE
|
#ifdef MY_CPU_X86_OR_AMD64
|
||||||
#define CRC_NUM_TABLES 8
|
#define CRC_NUM_TABLES 8
|
||||||
|
UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
||||||
|
#elif defined(MY_CPU_LE)
|
||||||
|
#define CRC_NUM_TABLES 4
|
||||||
#else
|
#else
|
||||||
#define CRC_NUM_TABLES 1
|
#define CRC_NUM_TABLES 5
|
||||||
|
#define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24))
|
||||||
|
UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MY_CPU_BE
|
||||||
|
UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
||||||
|
|
||||||
static CRC_FUNC g_CrcUpdate;
|
CRC_FUNC g_CrcUpdate;
|
||||||
UInt32 g_CrcTable[256 * CRC_NUM_TABLES];
|
UInt32 g_CrcTable[256 * CRC_NUM_TABLES];
|
||||||
|
|
||||||
#if CRC_NUM_TABLES == 1
|
|
||||||
|
|
||||||
#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
|
||||||
|
|
||||||
static UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table)
|
|
||||||
{
|
|
||||||
const Byte *p = (const Byte *)data;
|
|
||||||
for (; size > 0; size--, p++)
|
|
||||||
v = CRC_UPDATE_BYTE_2(v, *p);
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
|
||||||
UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
|
UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
|
||||||
{
|
{
|
||||||
return g_CrcUpdate(v, data, size, g_CrcTable);
|
return g_CrcUpdate(v, data, size, g_CrcTable);
|
||||||
@@ -57,18 +49,37 @@ void MY_FAST_CALL CrcGenerateTable()
|
|||||||
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
||||||
g_CrcTable[i] = r;
|
g_CrcTable[i] = r;
|
||||||
}
|
}
|
||||||
#if CRC_NUM_TABLES == 1
|
|
||||||
g_CrcUpdate = CrcUpdateT1;
|
|
||||||
#else
|
|
||||||
for (; i < 256 * CRC_NUM_TABLES; i++)
|
for (; i < 256 * CRC_NUM_TABLES; i++)
|
||||||
{
|
{
|
||||||
UInt32 r = g_CrcTable[i - 256];
|
UInt32 r = g_CrcTable[i - 256];
|
||||||
g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
|
g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MY_CPU_LE
|
||||||
|
|
||||||
g_CrcUpdate = CrcUpdateT4;
|
g_CrcUpdate = CrcUpdateT4;
|
||||||
#ifdef MY_CPU_X86_OR_AMD64
|
|
||||||
|
#if CRC_NUM_TABLES == 8
|
||||||
if (!CPU_Is_InOrder())
|
if (!CPU_Is_InOrder())
|
||||||
g_CrcUpdate = CrcUpdateT8;
|
g_CrcUpdate = CrcUpdateT8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
#ifndef MY_CPU_BE
|
||||||
|
UInt32 k = 1;
|
||||||
|
if (*(const Byte *)&k == 1)
|
||||||
|
g_CrcUpdate = CrcUpdateT4;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--)
|
||||||
|
{
|
||||||
|
UInt32 x = g_CrcTable[i - 256];
|
||||||
|
g_CrcTable[i] = CRC_UINT32_SWAP(x);
|
||||||
|
}
|
||||||
|
g_CrcUpdate = CrcUpdateT1_BeT4;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
4
C/7zCrc.h
Executable file → Normal file
4
C/7zCrc.h
Executable file → Normal file
@@ -1,10 +1,10 @@
|
|||||||
/* 7zCrc.h -- CRC32 calculation
|
/* 7zCrc.h -- CRC32 calculation
|
||||||
2009-11-21 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_CRC_H
|
#ifndef __7Z_CRC_H
|
||||||
#define __7Z_CRC_H
|
#define __7Z_CRC_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
|||||||
40
C/7zCrcOpt.c
Executable file → Normal file
40
C/7zCrcOpt.c
Executable file → Normal file
@@ -1,12 +1,14 @@
|
|||||||
/* 7zCrcOpt.c -- CRC32 calculation : optimized version
|
/* 7zCrcOpt.c -- CRC32 calculation
|
||||||
2009-11-23 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
|
|
||||||
#ifdef MY_CPU_LE
|
|
||||||
|
|
||||||
#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
||||||
|
|
||||||
|
#ifndef MY_CPU_BE
|
||||||
|
|
||||||
UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table)
|
UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table)
|
||||||
{
|
{
|
||||||
const Byte *p = (const Byte *)data;
|
const Byte *p = (const Byte *)data;
|
||||||
@@ -32,3 +34,33 @@ UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const U
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MY_CPU_LE
|
||||||
|
|
||||||
|
#define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24))
|
||||||
|
|
||||||
|
UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table)
|
||||||
|
{
|
||||||
|
const Byte *p = (const Byte *)data;
|
||||||
|
for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)
|
||||||
|
v = CRC_UPDATE_BYTE_2(v, *p);
|
||||||
|
v = CRC_UINT32_SWAP(v);
|
||||||
|
table += 0x100;
|
||||||
|
for (; size >= 4; size -= 4, p += 4)
|
||||||
|
{
|
||||||
|
v ^= *(const UInt32 *)p;
|
||||||
|
v =
|
||||||
|
table[0x000 + (v & 0xFF)] ^
|
||||||
|
table[0x100 + ((v >> 8) & 0xFF)] ^
|
||||||
|
table[0x200 + ((v >> 16) & 0xFF)] ^
|
||||||
|
table[0x300 + ((v >> 24))];
|
||||||
|
}
|
||||||
|
table -= 0x100;
|
||||||
|
v = CRC_UINT32_SWAP(v);
|
||||||
|
for (; size > 0; size--, p++)
|
||||||
|
v = CRC_UPDATE_BYTE_2(v, *p);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
159
C/7zDec.c
Executable file → Normal file
159
C/7zDec.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* 7zDec.c -- Decoding from 7z folder
|
/* 7zDec.c -- Decoding from 7z folder
|
||||||
2010-03-15 : Igor Pavlov : Public domain */
|
2014-06-16 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -18,9 +20,13 @@
|
|||||||
|
|
||||||
#define k_Copy 0
|
#define k_Copy 0
|
||||||
#define k_LZMA2 0x21
|
#define k_LZMA2 0x21
|
||||||
#define k_LZMA 0x30101
|
#define k_LZMA 0x30101
|
||||||
#define k_BCJ 0x03030103
|
#define k_BCJ 0x03030103
|
||||||
#define k_BCJ2 0x0303011B
|
#define k_PPC 0x03030205
|
||||||
|
#define k_ARM 0x03030501
|
||||||
|
#define k_ARMT 0x03030701
|
||||||
|
#define k_SPARC 0x03030805
|
||||||
|
#define k_BCJ2 0x0303011B
|
||||||
|
|
||||||
#ifdef _7ZIP_PPMD_SUPPPORT
|
#ifdef _7ZIP_PPMD_SUPPPORT
|
||||||
|
|
||||||
@@ -59,7 +65,7 @@ static Byte ReadByte(void *pp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SRes SzDecodePpmd(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inStream,
|
static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream,
|
||||||
Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain)
|
Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain)
|
||||||
{
|
{
|
||||||
CPpmd7 ppmd;
|
CPpmd7 ppmd;
|
||||||
@@ -73,12 +79,12 @@ static SRes SzDecodePpmd(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inSt
|
|||||||
s.res = SZ_OK;
|
s.res = SZ_OK;
|
||||||
s.processed = 0;
|
s.processed = 0;
|
||||||
|
|
||||||
if (coder->Props.size != 5)
|
if (propsSize != 5)
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned order = coder->Props.data[0];
|
unsigned order = props[0];
|
||||||
UInt32 memSize = GetUi32(coder->Props.data + 1);
|
UInt32 memSize = GetUi32(props + 1);
|
||||||
if (order < PPMD7_MIN_ORDER ||
|
if (order < PPMD7_MIN_ORDER ||
|
||||||
order > PPMD7_MAX_ORDER ||
|
order > PPMD7_MAX_ORDER ||
|
||||||
memSize < PPMD7_MIN_MEM_SIZE ||
|
memSize < PPMD7_MIN_MEM_SIZE ||
|
||||||
@@ -120,14 +126,14 @@ static SRes SzDecodePpmd(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inSt
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static SRes SzDecodeLzma(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inStream,
|
static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream,
|
||||||
Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain)
|
Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain)
|
||||||
{
|
{
|
||||||
CLzmaDec state;
|
CLzmaDec state;
|
||||||
SRes res = SZ_OK;
|
SRes res = SZ_OK;
|
||||||
|
|
||||||
LzmaDec_Construct(&state);
|
LzmaDec_Construct(&state);
|
||||||
RINOK(LzmaDec_AllocateProbs(&state, coder->Props.data, (unsigned)coder->Props.size, allocMain));
|
RINOK(LzmaDec_AllocateProbs(&state, props, propsSize, allocMain));
|
||||||
state.dic = outBuffer;
|
state.dic = outBuffer;
|
||||||
state.dicBufSize = outSize;
|
state.dicBufSize = outSize;
|
||||||
LzmaDec_Init(&state);
|
LzmaDec_Init(&state);
|
||||||
@@ -168,16 +174,16 @@ static SRes SzDecodeLzma(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inSt
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SRes SzDecodeLzma2(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inStream,
|
static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream,
|
||||||
Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain)
|
Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain)
|
||||||
{
|
{
|
||||||
CLzma2Dec state;
|
CLzma2Dec state;
|
||||||
SRes res = SZ_OK;
|
SRes res = SZ_OK;
|
||||||
|
|
||||||
Lzma2Dec_Construct(&state);
|
Lzma2Dec_Construct(&state);
|
||||||
if (coder->Props.size != 1)
|
if (propsSize != 1)
|
||||||
return SZ_ERROR_DATA;
|
return SZ_ERROR_DATA;
|
||||||
RINOK(Lzma2Dec_AllocateProbs(&state, coder->Props.data[0], allocMain));
|
RINOK(Lzma2Dec_AllocateProbs(&state, props[0], allocMain));
|
||||||
state.decoder.dic = outBuffer;
|
state.decoder.dic = outBuffer;
|
||||||
state.decoder.dicBufSize = outSize;
|
state.decoder.dicBufSize = outSize;
|
||||||
Lzma2Dec_Init(&state);
|
Lzma2Dec_Init(&state);
|
||||||
@@ -238,7 +244,7 @@ static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer
|
|||||||
|
|
||||||
static Bool IS_MAIN_METHOD(UInt32 m)
|
static Bool IS_MAIN_METHOD(UInt32 m)
|
||||||
{
|
{
|
||||||
switch(m)
|
switch (m)
|
||||||
{
|
{
|
||||||
case k_Copy:
|
case k_Copy:
|
||||||
case k_LZMA:
|
case k_LZMA:
|
||||||
@@ -256,11 +262,10 @@ static Bool IS_SUPPORTED_CODER(const CSzCoderInfo *c)
|
|||||||
return
|
return
|
||||||
c->NumInStreams == 1 &&
|
c->NumInStreams == 1 &&
|
||||||
c->NumOutStreams == 1 &&
|
c->NumOutStreams == 1 &&
|
||||||
c->MethodID <= (UInt32)0xFFFFFFFF &&
|
/* c->MethodID <= (UInt32)0xFFFFFFFF && */
|
||||||
IS_MAIN_METHOD((UInt32)c->MethodID);
|
IS_MAIN_METHOD((UInt32)c->MethodID);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IS_BCJ(c) ((c)->MethodID == k_BCJ && (c)->NumInStreams == 1 && (c)->NumOutStreams == 1)
|
|
||||||
#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumInStreams == 4 && (c)->NumOutStreams == 1)
|
#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumInStreams == 4 && (c)->NumOutStreams == 1)
|
||||||
|
|
||||||
static SRes CheckSupportedFolder(const CSzFolder *f)
|
static SRes CheckSupportedFolder(const CSzFolder *f)
|
||||||
@@ -277,11 +282,25 @@ static SRes CheckSupportedFolder(const CSzFolder *f)
|
|||||||
}
|
}
|
||||||
if (f->NumCoders == 2)
|
if (f->NumCoders == 2)
|
||||||
{
|
{
|
||||||
if (!IS_BCJ(&f->Coders[1]) ||
|
const CSzCoderInfo *c = &f->Coders[1];
|
||||||
f->NumPackStreams != 1 || f->PackStreams[0] != 0 ||
|
if (
|
||||||
|
/* c->MethodID > (UInt32)0xFFFFFFFF || */
|
||||||
|
c->NumInStreams != 1 ||
|
||||||
|
c->NumOutStreams != 1 ||
|
||||||
|
f->NumPackStreams != 1 ||
|
||||||
|
f->PackStreams[0] != 0 ||
|
||||||
f->NumBindPairs != 1 ||
|
f->NumBindPairs != 1 ||
|
||||||
f->BindPairs[0].InIndex != 1 || f->BindPairs[0].OutIndex != 0)
|
f->BindPairs[0].InIndex != 1 ||
|
||||||
|
f->BindPairs[0].OutIndex != 0)
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
switch ((UInt32)c->MethodID)
|
||||||
|
{
|
||||||
|
case k_BCJ:
|
||||||
|
case k_ARM:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
}
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
if (f->NumCoders == 4)
|
if (f->NumCoders == 4)
|
||||||
@@ -305,16 +324,12 @@ static SRes CheckSupportedFolder(const CSzFolder *f)
|
|||||||
return SZ_ERROR_UNSUPPORTED;
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UInt64 GetSum(const UInt64 *values, UInt32 index)
|
#define CASE_BRA_CONV(isa) case k_ ## isa: isa ## _Convert(outBuffer, outSize, 0, 0); break;
|
||||||
{
|
|
||||||
UInt64 sum = 0;
|
|
||||||
UInt32 i;
|
|
||||||
for (i = 0; i < index; i++)
|
|
||||||
sum += values[i];
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes,
|
static SRes SzFolder_Decode2(const CSzFolder *folder,
|
||||||
|
const Byte *propsData,
|
||||||
|
const UInt64 *unpackSizes,
|
||||||
|
const UInt64 *packPositions,
|
||||||
ILookInStream *inStream, UInt64 startPos,
|
ILookInStream *inStream, UInt64 startPos,
|
||||||
Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain,
|
Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain,
|
||||||
Byte *tempBuf[])
|
Byte *tempBuf[])
|
||||||
@@ -328,7 +343,7 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes,
|
|||||||
|
|
||||||
for (ci = 0; ci < folder->NumCoders; ci++)
|
for (ci = 0; ci < folder->NumCoders; ci++)
|
||||||
{
|
{
|
||||||
CSzCoderInfo *coder = &folder->Coders[ci];
|
const CSzCoderInfo *coder = &folder->Coders[ci];
|
||||||
|
|
||||||
if (IS_MAIN_METHOD((UInt32)coder->MethodID))
|
if (IS_MAIN_METHOD((UInt32)coder->MethodID))
|
||||||
{
|
{
|
||||||
@@ -340,7 +355,7 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes,
|
|||||||
if (folder->NumCoders == 4)
|
if (folder->NumCoders == 4)
|
||||||
{
|
{
|
||||||
UInt32 indices[] = { 3, 2, 0 };
|
UInt32 indices[] = { 3, 2, 0 };
|
||||||
UInt64 unpackSize = folder->UnpackSizes[ci];
|
UInt64 unpackSize = unpackSizes[ci];
|
||||||
si = indices[ci];
|
si = indices[ci];
|
||||||
if (ci < 2)
|
if (ci < 2)
|
||||||
{
|
{
|
||||||
@@ -364,8 +379,8 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes,
|
|||||||
else
|
else
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
offset = GetSum(packSizes, si);
|
offset = packPositions[si];
|
||||||
inSize = packSizes[si];
|
inSize = packPositions[si + 1] - offset;
|
||||||
RINOK(LookInStream_SeekTo(inStream, startPos + offset));
|
RINOK(LookInStream_SeekTo(inStream, startPos + offset));
|
||||||
|
|
||||||
if (coder->MethodID == k_Copy)
|
if (coder->MethodID == k_Copy)
|
||||||
@@ -376,33 +391,25 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes,
|
|||||||
}
|
}
|
||||||
else if (coder->MethodID == k_LZMA)
|
else if (coder->MethodID == k_LZMA)
|
||||||
{
|
{
|
||||||
RINOK(SzDecodeLzma(coder, inSize, inStream, outBufCur, outSizeCur, allocMain));
|
RINOK(SzDecodeLzma(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain));
|
||||||
}
|
}
|
||||||
else if (coder->MethodID == k_LZMA2)
|
else if (coder->MethodID == k_LZMA2)
|
||||||
{
|
{
|
||||||
RINOK(SzDecodeLzma2(coder, inSize, inStream, outBufCur, outSizeCur, allocMain));
|
RINOK(SzDecodeLzma2(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef _7ZIP_PPMD_SUPPPORT
|
#ifdef _7ZIP_PPMD_SUPPPORT
|
||||||
RINOK(SzDecodePpmd(coder, inSize, inStream, outBufCur, outSizeCur, allocMain));
|
RINOK(SzDecodePpmd(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain));
|
||||||
#else
|
#else
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (coder->MethodID == k_BCJ)
|
|
||||||
{
|
|
||||||
UInt32 state;
|
|
||||||
if (ci != 1)
|
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
|
||||||
x86_Convert_Init(state);
|
|
||||||
x86_Convert(outBuffer, outSize, 0, &state, 0);
|
|
||||||
}
|
|
||||||
else if (coder->MethodID == k_BCJ2)
|
else if (coder->MethodID == k_BCJ2)
|
||||||
{
|
{
|
||||||
UInt64 offset = GetSum(packSizes, 1);
|
UInt64 offset = packPositions[1];
|
||||||
UInt64 s3Size = packSizes[1];
|
UInt64 s3Size = packPositions[2] - offset;
|
||||||
SRes res;
|
SRes res;
|
||||||
if (ci != 3)
|
if (ci != 3)
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
@@ -425,20 +432,62 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes,
|
|||||||
RINOK(res)
|
RINOK(res)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
{
|
||||||
|
if (ci != 1)
|
||||||
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
switch (coder->MethodID)
|
||||||
|
{
|
||||||
|
case k_BCJ:
|
||||||
|
{
|
||||||
|
UInt32 state;
|
||||||
|
x86_Convert_Init(state);
|
||||||
|
x86_Convert(outBuffer, outSize, 0, &state, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
CASE_BRA_CONV(ARM)
|
||||||
|
default:
|
||||||
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes,
|
SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,
|
||||||
ILookInStream *inStream, UInt64 startPos,
|
ILookInStream *inStream, UInt64 startPos,
|
||||||
Byte *outBuffer, size_t outSize, ISzAlloc *allocMain)
|
Byte *outBuffer, size_t outSize,
|
||||||
|
ISzAlloc *allocMain)
|
||||||
{
|
{
|
||||||
Byte *tempBuf[3] = { 0, 0, 0};
|
SRes res;
|
||||||
int i;
|
CSzFolder folder;
|
||||||
SRes res = SzFolder_Decode2(folder, packSizes, inStream, startPos,
|
CSzData sd;
|
||||||
outBuffer, (SizeT)outSize, allocMain, tempBuf);
|
CSzData sdSizes;
|
||||||
for (i = 0; i < 3; i++)
|
|
||||||
IAlloc_Free(allocMain, tempBuf[i]);
|
const Byte *data = p->CodersData + p->FoCodersOffsets[folderIndex];
|
||||||
return res;
|
sd.Data = data;
|
||||||
|
sd.Size = p->FoCodersOffsets[folderIndex + 1] - p->FoCodersOffsets[folderIndex];
|
||||||
|
|
||||||
|
sdSizes.Data = p->UnpackSizesData + p->FoSizesOffsets[folderIndex];
|
||||||
|
sdSizes.Size =
|
||||||
|
p->FoSizesOffsets[folderIndex + 1] -
|
||||||
|
p->FoSizesOffsets[folderIndex];
|
||||||
|
|
||||||
|
res = SzGetNextFolderItem(&folder, &sd, &sdSizes);
|
||||||
|
|
||||||
|
if (res != SZ_OK)
|
||||||
|
return res;
|
||||||
|
|
||||||
|
if (sd.Size != 0 || outSize != folder.CodersUnpackSizes[folder.MainOutStream])
|
||||||
|
return SZ_ERROR_FAIL;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
Byte *tempBuf[3] = { 0, 0, 0};
|
||||||
|
res = SzFolder_Decode2(&folder, data, folder.CodersUnpackSizes,
|
||||||
|
p->PackPositions + p->FoStartPackStreamIndex[folderIndex],
|
||||||
|
inStream, startPos,
|
||||||
|
outBuffer, (SizeT)outSize, allocMain, tempBuf);
|
||||||
|
for (i = 0; i < 3; i++)
|
||||||
|
IAlloc_Free(allocMain, tempBuf[i]);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
C/7zFile.c
Executable file → Normal file
2
C/7zFile.c
Executable file → Normal file
@@ -1,6 +1,8 @@
|
|||||||
/* 7zFile.c -- File IO
|
/* 7zFile.c -- File IO
|
||||||
2009-11-24 : Igor Pavlov : Public domain */
|
2009-11-24 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "7zFile.h"
|
#include "7zFile.h"
|
||||||
|
|
||||||
#ifndef USE_WINDOWS_FILE
|
#ifndef USE_WINDOWS_FILE
|
||||||
|
|||||||
4
C/7zFile.h
Executable file → Normal file
4
C/7zFile.h
Executable file → Normal file
@@ -1,5 +1,5 @@
|
|||||||
/* 7zFile.h -- File IO
|
/* 7zFile.h -- File IO
|
||||||
2009-11-24 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_FILE_H
|
#ifndef __7Z_FILE_H
|
||||||
#define __7Z_FILE_H
|
#define __7Z_FILE_H
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
|||||||
6
C/7zStream.c
Executable file → Normal file
6
C/7zStream.c
Executable file → Normal file
@@ -1,9 +1,11 @@
|
|||||||
/* 7zStream.c -- 7z Stream functions
|
/* 7zStream.c -- 7z Stream functions
|
||||||
2010-03-11 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType)
|
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType)
|
||||||
{
|
{
|
||||||
|
|||||||
32
C/Types.h → C/7zTypes.h
Executable file → Normal file
32
C/Types.h → C/7zTypes.h
Executable file → Normal file
@@ -1,15 +1,15 @@
|
|||||||
/* Types.h -- Basic types
|
/* 7zTypes.h -- Basic types
|
||||||
2010-03-11 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_TYPES_H
|
#ifndef __7Z_TYPES_H
|
||||||
#define __7Z_TYPES_H
|
#define __7Z_TYPES_H
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
/* #include <windows.h> */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifndef EXTERN_C_BEGIN
|
#ifndef EXTERN_C_BEGIN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define EXTERN_C_BEGIN extern "C" {
|
#define EXTERN_C_BEGIN extern "C" {
|
||||||
@@ -43,7 +43,8 @@ EXTERN_C_BEGIN
|
|||||||
typedef int SRes;
|
typedef int SRes;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
typedef DWORD WRes;
|
/* typedef DWORD WRes; */
|
||||||
|
typedef unsigned WRes;
|
||||||
#else
|
#else
|
||||||
typedef int WRes;
|
typedef int WRes;
|
||||||
#endif
|
#endif
|
||||||
@@ -77,9 +78,11 @@ typedef unsigned long UInt64;
|
|||||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
typedef __int64 Int64;
|
typedef __int64 Int64;
|
||||||
typedef unsigned __int64 UInt64;
|
typedef unsigned __int64 UInt64;
|
||||||
|
#define UINT64_CONST(n) n
|
||||||
#else
|
#else
|
||||||
typedef long long int Int64;
|
typedef long long int Int64;
|
||||||
typedef unsigned long long int UInt64;
|
typedef unsigned long long int UInt64;
|
||||||
|
#define UINT64_CONST(n) n ## ULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -114,6 +117,7 @@ typedef int Bool;
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#define MY_NO_INLINE
|
||||||
#define MY_CDECL
|
#define MY_CDECL
|
||||||
#define MY_FAST_CALL
|
#define MY_FAST_CALL
|
||||||
|
|
||||||
@@ -231,6 +235,22 @@ typedef struct
|
|||||||
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
|
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
|
||||||
#define IAlloc_Free(p, a) (p)->Free((p), a)
|
#define IAlloc_Free(p, a) (p)->Free((p), a)
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#define CHAR_PATH_SEPARATOR '\\'
|
||||||
|
#define WCHAR_PATH_SEPARATOR L'\\'
|
||||||
|
#define STRING_PATH_SEPARATOR "\\"
|
||||||
|
#define WSTRING_PATH_SEPARATOR L"\\"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define CHAR_PATH_SEPARATOR '/'
|
||||||
|
#define WCHAR_PATH_SEPARATOR L'/'
|
||||||
|
#define STRING_PATH_SEPARATOR "/"
|
||||||
|
#define WSTRING_PATH_SEPARATOR L"/"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
11
C/7zVersion.h
Executable file → Normal file
11
C/7zVersion.h
Executable file → Normal file
@@ -1,7 +1,10 @@
|
|||||||
#define MY_VER_MAJOR 9
|
#define MY_VER_MAJOR 9
|
||||||
#define MY_VER_MINOR 13
|
#define MY_VER_MINOR 36
|
||||||
#define MY_VER_BUILD 0
|
#define MY_VER_BUILD 00
|
||||||
#define MY_VERSION "9.13 beta"
|
#define MY_VERSION "9.36 beta"
|
||||||
#define MY_DATE "2010-04-15"
|
// #define MY_7ZIP_VERSION "9.36"
|
||||||
|
#define MY_DATE "2014-12-26"
|
||||||
|
#undef MY_COPYRIGHT
|
||||||
|
#undef MY_VERSION_COPYRIGHT_DATE
|
||||||
#define MY_COPYRIGHT ": Igor Pavlov : Public domain"
|
#define MY_COPYRIGHT ": Igor Pavlov : Public domain"
|
||||||
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE
|
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE
|
||||||
|
|||||||
55
C/7zVersion.rc
Normal file
55
C/7zVersion.rc
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#define MY_VS_FFI_FILEFLAGSMASK 0x0000003FL
|
||||||
|
#define MY_VOS_NT_WINDOWS32 0x00040004L
|
||||||
|
#define MY_VOS_CE_WINDOWS32 0x00050004L
|
||||||
|
|
||||||
|
#define MY_VFT_APP 0x00000001L
|
||||||
|
#define MY_VFT_DLL 0x00000002L
|
||||||
|
|
||||||
|
// #include <WinVer.h>
|
||||||
|
|
||||||
|
#ifndef MY_VERSION
|
||||||
|
#include "7zVersion.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define DBG_FL VS_FF_DEBUG
|
||||||
|
#else
|
||||||
|
#define DBG_FL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MY_VERSION_INFO(fileType, descr, intName, origName) \
|
||||||
|
LANGUAGE 9, 1 \
|
||||||
|
1 VERSIONINFO \
|
||||||
|
FILEVERSION MY_VER \
|
||||||
|
PRODUCTVERSION MY_VER \
|
||||||
|
FILEFLAGSMASK MY_VS_FFI_FILEFLAGSMASK \
|
||||||
|
FILEFLAGS DBG_FL \
|
||||||
|
FILEOS MY_VOS_NT_WINDOWS32 \
|
||||||
|
FILETYPE fileType \
|
||||||
|
FILESUBTYPE 0x0L \
|
||||||
|
BEGIN \
|
||||||
|
BLOCK "StringFileInfo" \
|
||||||
|
BEGIN \
|
||||||
|
BLOCK "040904b0" \
|
||||||
|
BEGIN \
|
||||||
|
VALUE "CompanyName", "Igor Pavlov" \
|
||||||
|
VALUE "FileDescription", descr \
|
||||||
|
VALUE "FileVersion", MY_VERSION \
|
||||||
|
VALUE "InternalName", intName \
|
||||||
|
VALUE "LegalCopyright", MY_COPYRIGHT \
|
||||||
|
VALUE "OriginalFilename", origName \
|
||||||
|
VALUE "ProductName", "7-Zip" \
|
||||||
|
VALUE "ProductVersion", MY_VERSION \
|
||||||
|
END \
|
||||||
|
END \
|
||||||
|
BLOCK "VarFileInfo" \
|
||||||
|
BEGIN \
|
||||||
|
VALUE "Translation", 0x409, 1200 \
|
||||||
|
END \
|
||||||
|
END
|
||||||
|
|
||||||
|
#define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(MY_VFT_APP, descr, intName, intName ".exe")
|
||||||
|
|
||||||
|
#define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(MY_VFT_DLL, descr, intName, intName ".dll")
|
||||||
4
C/Aes.c
Executable file → Normal file
4
C/Aes.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* Aes.c -- AES encryption / decryption
|
/* Aes.c -- AES encryption / decryption
|
||||||
2009-11-23 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Aes.h"
|
#include "Aes.h"
|
||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
|
|||||||
4
C/Aes.h
Executable file → Normal file
4
C/Aes.h
Executable file → Normal file
@@ -1,10 +1,10 @@
|
|||||||
/* Aes.h -- AES encryption / decryption
|
/* Aes.h -- AES encryption / decryption
|
||||||
2009-11-23 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __AES_H
|
#ifndef __AES_H
|
||||||
#define __AES_H
|
#define __AES_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
|||||||
4
C/AesOpt.c
Executable file → Normal file
4
C/AesOpt.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* AesOpt.c -- Intel's AES
|
/* AesOpt.c -- Intel's AES
|
||||||
2009-11-23 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
|
|
||||||
|
|||||||
6
C/Alloc.c
Executable file → Normal file
6
C/Alloc.c
Executable file → Normal file
@@ -1,7 +1,7 @@
|
|||||||
/* Alloc.c -- Memory allocation functions
|
/* Alloc.c -- Memory allocation functions
|
||||||
2008-09-24
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
Igor Pavlov
|
|
||||||
Public domain */
|
#include "Precomp.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|||||||
2
C/Bcj2.c
Executable file → Normal file
2
C/Bcj2.c
Executable file → Normal file
@@ -1,6 +1,8 @@
|
|||||||
/* Bcj2.c -- Converter for x86 code (BCJ2)
|
/* Bcj2.c -- Converter for x86 code (BCJ2)
|
||||||
2008-10-04 : Igor Pavlov : Public domain */
|
2008-10-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Bcj2.h"
|
#include "Bcj2.h"
|
||||||
|
|
||||||
#ifdef _LZMA_PROB32
|
#ifdef _LZMA_PROB32
|
||||||
|
|||||||
12
C/Bcj2.h
Executable file → Normal file
12
C/Bcj2.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* Bcj2.h -- Converter for x86 code (BCJ2)
|
/* Bcj2.h -- Converter for x86 code (BCJ2)
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __BCJ2_H
|
#ifndef __BCJ2_H
|
||||||
#define __BCJ2_H
|
#define __BCJ2_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Conditions:
|
Conditions:
|
||||||
@@ -31,8 +29,6 @@ int Bcj2_Decode(
|
|||||||
const Byte *buf3, SizeT size3,
|
const Byte *buf3, SizeT size3,
|
||||||
Byte *outBuf, SizeT outSize);
|
Byte *outBuf, SizeT outSize);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
8
C/Bra.c
Executable file → Normal file
8
C/Bra.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* Bra.c -- Converters for RISC code
|
/* Bra.c -- Converters for RISC code
|
||||||
2008-10-04 : Igor Pavlov : Public domain */
|
2010-04-16 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Bra.h"
|
#include "Bra.h"
|
||||||
|
|
||||||
@@ -104,8 +106,8 @@ SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
|||||||
size -= 4;
|
size -= 4;
|
||||||
for (i = 0; i <= size; i += 4)
|
for (i = 0; i <= size; i += 4)
|
||||||
{
|
{
|
||||||
if (data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00 ||
|
if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) ||
|
||||||
data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)
|
(data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0))
|
||||||
{
|
{
|
||||||
UInt32 src =
|
UInt32 src =
|
||||||
((UInt32)data[i + 0] << 24) |
|
((UInt32)data[i + 0] << 24) |
|
||||||
|
|||||||
12
C/Bra.h
Executable file → Normal file
12
C/Bra.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* Bra.h -- Branch converters for executables
|
/* Bra.h -- Branch converters for executables
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __BRA_H
|
#ifndef __BRA_H
|
||||||
#define __BRA_H
|
#define __BRA_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
These functions convert relative addresses to absolute addresses
|
These functions convert relative addresses to absolute addresses
|
||||||
@@ -61,8 +59,6 @@ SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
|
|||||||
SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
|
SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
|
||||||
SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
|
SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
99
C/Bra86.c
Executable file → Normal file
99
C/Bra86.c
Executable file → Normal file
@@ -1,85 +1,82 @@
|
|||||||
/* Bra86.c -- Converter for x86 code (BCJ)
|
/* Bra86.c -- Converter for x86 code (BCJ)
|
||||||
2008-10-04 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Bra.h"
|
#include "Bra.h"
|
||||||
|
|
||||||
#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF)
|
#define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0)
|
||||||
|
|
||||||
const Byte kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0};
|
|
||||||
const Byte kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3};
|
|
||||||
|
|
||||||
SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding)
|
SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding)
|
||||||
{
|
{
|
||||||
SizeT bufferPos = 0, prevPosT;
|
SizeT pos = 0;
|
||||||
UInt32 prevMask = *state & 0x7;
|
UInt32 mask = *state & 7;
|
||||||
if (size < 5)
|
if (size < 5)
|
||||||
return 0;
|
return 0;
|
||||||
|
size -= 4;
|
||||||
ip += 5;
|
ip += 5;
|
||||||
prevPosT = (SizeT)0 - 1;
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
Byte *p = data + bufferPos;
|
Byte *p = data + pos;
|
||||||
Byte *limit = data + size - 4;
|
const Byte *limit = data + size;
|
||||||
for (; p < limit; p++)
|
for (; p < limit; p++)
|
||||||
if ((*p & 0xFE) == 0xE8)
|
if ((*p & 0xFE) == 0xE8)
|
||||||
break;
|
break;
|
||||||
bufferPos = (SizeT)(p - data);
|
|
||||||
if (p >= limit)
|
|
||||||
break;
|
|
||||||
prevPosT = bufferPos - prevPosT;
|
|
||||||
if (prevPosT > 3)
|
|
||||||
prevMask = 0;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7;
|
SizeT d = (SizeT)(p - data - pos);
|
||||||
if (prevMask != 0)
|
pos = (SizeT)(p - data);
|
||||||
|
if (p >= limit)
|
||||||
{
|
{
|
||||||
Byte b = p[4 - kMaskToBitNumber[prevMask]];
|
*state = (d > 2 ? 0 : mask >> (unsigned)d);
|
||||||
if (!kMaskToAllowedStatus[prevMask] || Test86MSByte(b))
|
return pos;
|
||||||
|
}
|
||||||
|
if (d > 2)
|
||||||
|
mask = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mask >>= (unsigned)d;
|
||||||
|
if (mask != 0 && (mask > 4 || mask == 3 || Test86MSByte(p[(mask >> 1) + 1])))
|
||||||
{
|
{
|
||||||
prevPosT = bufferPos;
|
mask = (mask >> 1) | 4;
|
||||||
prevMask = ((prevMask << 1) & 0x7) | 1;
|
pos++;
|
||||||
bufferPos++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prevPosT = bufferPos;
|
|
||||||
|
|
||||||
if (Test86MSByte(p[4]))
|
if (Test86MSByte(p[4]))
|
||||||
{
|
{
|
||||||
UInt32 src = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);
|
UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);
|
||||||
UInt32 dest;
|
UInt32 cur = ip + (UInt32)pos;
|
||||||
for (;;)
|
pos += 5;
|
||||||
|
if (encoding)
|
||||||
|
v += cur;
|
||||||
|
else
|
||||||
|
v -= cur;
|
||||||
|
if (mask != 0)
|
||||||
{
|
{
|
||||||
Byte b;
|
unsigned sh = (mask & 6) << 2;
|
||||||
int index;
|
if (Test86MSByte((Byte)(v >> sh)))
|
||||||
if (encoding)
|
{
|
||||||
dest = (ip + (UInt32)bufferPos) + src;
|
v ^= (((UInt32)0x100 << sh) - 1);
|
||||||
else
|
if (encoding)
|
||||||
dest = src - (ip + (UInt32)bufferPos);
|
v += cur;
|
||||||
if (prevMask == 0)
|
else
|
||||||
break;
|
v -= cur;
|
||||||
index = kMaskToBitNumber[prevMask] * 8;
|
}
|
||||||
b = (Byte)(dest >> (24 - index));
|
mask = 0;
|
||||||
if (!Test86MSByte(b))
|
|
||||||
break;
|
|
||||||
src = dest ^ ((1 << (32 - index)) - 1);
|
|
||||||
}
|
}
|
||||||
p[4] = (Byte)(~(((dest >> 24) & 1) - 1));
|
p[1] = (Byte)v;
|
||||||
p[3] = (Byte)(dest >> 16);
|
p[2] = (Byte)(v >> 8);
|
||||||
p[2] = (Byte)(dest >> 8);
|
p[3] = (Byte)(v >> 16);
|
||||||
p[1] = (Byte)dest;
|
p[4] = (Byte)(0 - ((v >> 24) & 1));
|
||||||
bufferPos += 5;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prevMask = ((prevMask << 1) & 0x7) | 1;
|
mask = (mask >> 1) | 4;
|
||||||
bufferPos++;
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prevPosT = bufferPos - prevPosT;
|
|
||||||
*state = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7));
|
|
||||||
return bufferPos;
|
|
||||||
}
|
}
|
||||||
|
|||||||
4
C/BraIA64.c
Executable file → Normal file
4
C/BraIA64.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* BraIA64.c -- Converter for IA-64 code
|
/* BraIA64.c -- Converter for IA-64 code
|
||||||
2008-10-04 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Bra.h"
|
#include "Bra.h"
|
||||||
|
|
||||||
|
|||||||
6
C/BwtSort.c
Executable file → Normal file
6
C/BwtSort.c
Executable file → Normal file
@@ -1,7 +1,7 @@
|
|||||||
/* BwtSort.c -- BWT block sorting
|
/* BwtSort.c -- BWT block sorting
|
||||||
2008-08-17
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
Igor Pavlov
|
|
||||||
Public domain */
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "BwtSort.h"
|
#include "BwtSort.h"
|
||||||
#include "Sort.h"
|
#include "Sort.h"
|
||||||
|
|||||||
12
C/BwtSort.h
Executable file → Normal file
12
C/BwtSort.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* BwtSort.h -- BWT block sorting
|
/* BwtSort.h -- BWT block sorting
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __BWT_SORT_H
|
#ifndef __BWT_SORT_H
|
||||||
#define __BWT_SORT_H
|
#define __BWT_SORT_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* use BLOCK_SORT_EXTERNAL_FLAGS if blockSize can be > 1M */
|
/* use BLOCK_SORT_EXTERNAL_FLAGS if blockSize can be > 1M */
|
||||||
/* #define BLOCK_SORT_EXTERNAL_FLAGS */
|
/* #define BLOCK_SORT_EXTERNAL_FLAGS */
|
||||||
@@ -23,8 +21,6 @@ extern "C" {
|
|||||||
|
|
||||||
UInt32 BlockSort(UInt32 *indices, const Byte *data, UInt32 blockSize);
|
UInt32 BlockSort(UInt32 *indices, const Byte *data, UInt32 blockSize);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
28
C/Compiler.h
Normal file
28
C/Compiler.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/* Compiler.h -- Compiler ypes
|
||||||
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __7Z_COMPILER_H
|
||||||
|
#define __7Z_COMPILER_H
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#ifdef UNDER_CE
|
||||||
|
#define RPC_NO_WINDOWS_H
|
||||||
|
/* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */
|
||||||
|
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
|
||||||
|
#pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1300
|
||||||
|
#pragma warning(disable : 4996) // This function or variable may be unsafe
|
||||||
|
#else
|
||||||
|
#pragma warning(disable : 4511) // copy constructor could not be generated
|
||||||
|
#pragma warning(disable : 4512) // assignment operator could not be generated
|
||||||
|
#pragma warning(disable : 4702) // unreachable code
|
||||||
|
#pragma warning(disable : 4710) // not inlined
|
||||||
|
#pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
40
C/CpuArch.c
Executable file → Normal file
40
C/CpuArch.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* CpuArch.c -- CPU specific code
|
/* CpuArch.c -- CPU specific code
|
||||||
2009-12-12: Igor Pavlov : Public domain */
|
2012-05-29: Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
|
|
||||||
@@ -9,6 +11,10 @@
|
|||||||
#define USE_ASM
|
#define USE_ASM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(USE_ASM) && _MSC_VER >= 1500
|
||||||
|
#include <intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(USE_ASM) && !defined(MY_CPU_AMD64)
|
#if defined(USE_ASM) && !defined(MY_CPU_AMD64)
|
||||||
static UInt32 CheckFlag(UInt32 flag)
|
static UInt32 CheckFlag(UInt32 flag)
|
||||||
{
|
{
|
||||||
@@ -72,13 +78,21 @@ static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"cpuid"
|
#if defined(MY_CPU_X86) && defined(__PIC__)
|
||||||
: "=a" (*a) ,
|
"mov %%ebx, %%edi;"
|
||||||
"=b" (*b) ,
|
"cpuid;"
|
||||||
"=c" (*c) ,
|
"xchgl %%ebx, %%edi;"
|
||||||
"=d" (*d)
|
: "=a" (*a) ,
|
||||||
: "0" (function)) ;
|
"=D" (*b) ,
|
||||||
|
#else
|
||||||
|
"cpuid"
|
||||||
|
: "=a" (*a) ,
|
||||||
|
"=b" (*b) ,
|
||||||
|
#endif
|
||||||
|
"=c" (*c) ,
|
||||||
|
"=d" (*d)
|
||||||
|
: "0" (function)) ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -135,7 +149,14 @@ Bool CPU_Is_InOrder()
|
|||||||
firm = x86cpuid_GetFirm(&p);
|
firm = x86cpuid_GetFirm(&p);
|
||||||
switch (firm)
|
switch (firm)
|
||||||
{
|
{
|
||||||
case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && model == 0x100C));
|
case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && (
|
||||||
|
/* Atom CPU */
|
||||||
|
model == 0x100C /* 45 nm, N4xx, D4xx, N5xx, D5xx, 230, 330 */
|
||||||
|
|| model == 0x2006 /* 45 nm, Z6xx */
|
||||||
|
|| model == 0x2007 /* 32 nm, Z2460 */
|
||||||
|
|| model == 0x3005 /* 32 nm, Z2760 */
|
||||||
|
|| model == 0x3006 /* 32 nm, N2xxx, D2xxx */
|
||||||
|
)));
|
||||||
case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA)));
|
case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA)));
|
||||||
case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF));
|
case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF));
|
||||||
}
|
}
|
||||||
@@ -143,6 +164,7 @@ Bool CPU_Is_InOrder()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(MY_CPU_AMD64) && defined(_WIN32)
|
#if !defined(MY_CPU_AMD64) && defined(_WIN32)
|
||||||
|
#include <windows.h>
|
||||||
static Bool CPU_Sys_Is_SSE_Supported()
|
static Bool CPU_Sys_Is_SSE_Supported()
|
||||||
{
|
{
|
||||||
OSVERSIONINFO vi;
|
OSVERSIONINFO vi;
|
||||||
|
|||||||
33
C/CpuArch.h
Executable file → Normal file
33
C/CpuArch.h
Executable file → Normal file
@@ -1,10 +1,10 @@
|
|||||||
/* CpuArch.h -- CPU specific code
|
/* CpuArch.h -- CPU specific code
|
||||||
2010-03-11: Igor Pavlov : Public domain */
|
2013-11-12: Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __CPU_ARCH_H
|
#ifndef __CPU_ARCH_H
|
||||||
#define __CPU_ARCH_H
|
#define __CPU_ARCH_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
@@ -40,21 +40,34 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
|||||||
#define MY_CPU_ARM_LE
|
#define MY_CPU_ARM_LE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32) && defined(_M_IA64)
|
||||||
|
#define MY_CPU_IA64_LE
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MY_CPU_X86_OR_AMD64)
|
#if defined(MY_CPU_X86_OR_AMD64)
|
||||||
#define MY_CPU_LE_UNALIGN
|
#define MY_CPU_LE_UNALIGN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MY_CPU_X86_OR_AMD64) || defined(MY_CPU_ARM_LE)
|
#if defined(MY_CPU_X86_OR_AMD64) || defined(MY_CPU_ARM_LE) || defined(MY_CPU_IA64_LE) || defined(__ARMEL__) || defined(__MIPSEL__) || defined(__LITTLE_ENDIAN__)
|
||||||
#define MY_CPU_LE
|
#define MY_CPU_LE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__BIG_ENDIAN__) || defined(__m68k__) || defined(__ARMEB__) || defined(__MIPSEB__)
|
||||||
|
#define MY_CPU_BE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MY_CPU_LE) && defined(MY_CPU_BE)
|
||||||
|
Stop_Compiling_Bad_Endian
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MY_CPU_LE_UNALIGN
|
#ifdef MY_CPU_LE_UNALIGN
|
||||||
|
|
||||||
#define GetUi16(p) (*(const UInt16 *)(p))
|
#define GetUi16(p) (*(const UInt16 *)(const void *)(p))
|
||||||
#define GetUi32(p) (*(const UInt32 *)(p))
|
#define GetUi32(p) (*(const UInt32 *)(const void *)(p))
|
||||||
#define GetUi64(p) (*(const UInt64 *)(p))
|
#define GetUi64(p) (*(const UInt64 *)(const void *)(p))
|
||||||
#define SetUi16(p, d) *(UInt16 *)(p) = (d);
|
#define SetUi16(p, d) *(UInt16 *)(p) = (d);
|
||||||
#define SetUi32(p, d) *(UInt32 *)(p) = (d);
|
#define SetUi32(p, d) *(UInt32 *)(p) = (d);
|
||||||
|
#define SetUi64(p, d) *(UInt64 *)(p) = (d);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -78,10 +91,16 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
|||||||
((Byte *)(p))[2] = (Byte)(_x_ >> 16); \
|
((Byte *)(p))[2] = (Byte)(_x_ >> 16); \
|
||||||
((Byte *)(p))[3] = (Byte)(_x_ >> 24); }
|
((Byte *)(p))[3] = (Byte)(_x_ >> 24); }
|
||||||
|
|
||||||
|
#define SetUi64(p, d) { UInt64 _x64_ = (d); \
|
||||||
|
SetUi32(p, (UInt32)_x64_); \
|
||||||
|
SetUi32(((Byte *)(p)) + 4, (UInt32)(_x64_ >> 32)); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MY_CPU_LE_UNALIGN) && defined(_WIN64) && (_MSC_VER >= 1300)
|
#if defined(MY_CPU_LE_UNALIGN) && defined(_WIN64) && (_MSC_VER >= 1300)
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#pragma intrinsic(_byteswap_ulong)
|
#pragma intrinsic(_byteswap_ulong)
|
||||||
#pragma intrinsic(_byteswap_uint64)
|
#pragma intrinsic(_byteswap_uint64)
|
||||||
#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
|
#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
|
||||||
@@ -99,7 +118,7 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GetBe16(p) (((UInt16)((const Byte *)(p))[0] << 8) | ((const Byte *)(p))[1])
|
#define GetBe16(p) ((UInt16)(((UInt16)((const Byte *)(p))[0] << 8) | ((const Byte *)(p))[1]))
|
||||||
|
|
||||||
|
|
||||||
#ifdef MY_CPU_X86_OR_AMD64
|
#ifdef MY_CPU_X86_OR_AMD64
|
||||||
|
|||||||
2
C/Delta.c
Executable file → Normal file
2
C/Delta.c
Executable file → Normal file
@@ -1,6 +1,8 @@
|
|||||||
/* Delta.c -- Delta converter
|
/* Delta.c -- Delta converter
|
||||||
2009-05-26 : Igor Pavlov : Public domain */
|
2009-05-26 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Delta.h"
|
#include "Delta.h"
|
||||||
|
|
||||||
void Delta_Init(Byte *state)
|
void Delta_Init(Byte *state)
|
||||||
|
|||||||
12
C/Delta.h
Executable file → Normal file
12
C/Delta.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* Delta.h -- Delta converter
|
/* Delta.h -- Delta converter
|
||||||
2009-04-15 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __DELTA_H
|
#ifndef __DELTA_H
|
||||||
#define __DELTA_H
|
#define __DELTA_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DELTA_STATE_SIZE 256
|
#define DELTA_STATE_SIZE 256
|
||||||
|
|
||||||
@@ -16,8 +14,6 @@ void Delta_Init(Byte *state);
|
|||||||
void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size);
|
void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size);
|
||||||
void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size);
|
void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
2
C/HuffEnc.c
Executable file → Normal file
2
C/HuffEnc.c
Executable file → Normal file
@@ -1,6 +1,8 @@
|
|||||||
/* HuffEnc.c -- functions for Huffman encoding
|
/* HuffEnc.c -- functions for Huffman encoding
|
||||||
2009-09-02 : Igor Pavlov : Public domain */
|
2009-09-02 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "HuffEnc.h"
|
#include "HuffEnc.h"
|
||||||
#include "Sort.h"
|
#include "Sort.h"
|
||||||
|
|
||||||
|
|||||||
12
C/HuffEnc.h
Executable file → Normal file
12
C/HuffEnc.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* HuffEnc.h -- Huffman encoding
|
/* HuffEnc.h -- Huffman encoding
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __HUFF_ENC_H
|
#ifndef __HUFF_ENC_H
|
||||||
#define __HUFF_ENC_H
|
#define __HUFF_ENC_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Conditions:
|
Conditions:
|
||||||
@@ -20,8 +18,6 @@ Conditions:
|
|||||||
|
|
||||||
void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 num, UInt32 maxLen);
|
void Huffman_Generate(const UInt32 *freqs, UInt32 *p, Byte *lens, UInt32 num, UInt32 maxLen);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
2
C/LzFind.c
Executable file → Normal file
2
C/LzFind.c
Executable file → Normal file
@@ -1,6 +1,8 @@
|
|||||||
/* LzFind.c -- Match finder for LZ algorithms
|
/* LzFind.c -- Match finder for LZ algorithms
|
||||||
2009-04-22 : Igor Pavlov : Public domain */
|
2009-04-22 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "LzFind.h"
|
#include "LzFind.h"
|
||||||
|
|||||||
12
C/LzFind.h
Executable file → Normal file
12
C/LzFind.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* LzFind.h -- Match finder for LZ algorithms
|
/* LzFind.h -- Match finder for LZ algorithms
|
||||||
2009-04-22 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZ_FIND_H
|
#ifndef __LZ_FIND_H
|
||||||
#define __LZ_FIND_H
|
#define __LZ_FIND_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef UInt32 CLzRef;
|
typedef UInt32 CLzRef;
|
||||||
|
|
||||||
@@ -108,8 +106,6 @@ UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
|||||||
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
||||||
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
12
C/LzFindMt.c
Executable file → Normal file
12
C/LzFindMt.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
|
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
|
||||||
2009-09-20 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "LzHash.h"
|
#include "LzHash.h"
|
||||||
|
|
||||||
@@ -97,7 +99,7 @@ void MtSync_Destruct(CMtSync *p)
|
|||||||
|
|
||||||
#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; }
|
#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; }
|
||||||
|
|
||||||
static SRes MtSync_Create2(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks)
|
static SRes MtSync_Create2(CMtSync *p, THREAD_FUNC_TYPE startAddress, void *obj, UInt32 numBlocks)
|
||||||
{
|
{
|
||||||
if (p->wasCreated)
|
if (p->wasCreated)
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
@@ -119,7 +121,7 @@ static SRes MtSync_Create2(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void
|
|||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SRes MtSync_Create(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks)
|
static SRes MtSync_Create(CMtSync *p, THREAD_FUNC_TYPE startAddress, void *obj, UInt32 numBlocks)
|
||||||
{
|
{
|
||||||
SRes res = MtSync_Create2(p, startAddress, obj, numBlocks);
|
SRes res = MtSync_Create2(p, startAddress, obj, numBlocks);
|
||||||
if (res != SZ_OK)
|
if (res != SZ_OK)
|
||||||
@@ -451,8 +453,8 @@ void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc)
|
|||||||
#define kHashBufferSize (kMtHashBlockSize * kMtHashNumBlocks)
|
#define kHashBufferSize (kMtHashBlockSize * kMtHashNumBlocks)
|
||||||
#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks)
|
#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks)
|
||||||
|
|
||||||
static unsigned MY_STD_CALL HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; }
|
static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; }
|
||||||
static unsigned MY_STD_CALL BtThreadFunc2(void *p)
|
static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE BtThreadFunc2(void *p)
|
||||||
{
|
{
|
||||||
Byte allocaDummy[0x180];
|
Byte allocaDummy[0x180];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
10
C/LzFindMt.h
Executable file → Normal file
10
C/LzFindMt.h
Executable file → Normal file
@@ -1,5 +1,5 @@
|
|||||||
/* LzFindMt.h -- multithreaded Match finder for LZ algorithms
|
/* LzFindMt.h -- multithreaded Match finder for LZ algorithms
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZ_FIND_MT_H
|
#ifndef __LZ_FIND_MT_H
|
||||||
#define __LZ_FIND_MT_H
|
#define __LZ_FIND_MT_H
|
||||||
@@ -7,9 +7,7 @@
|
|||||||
#include "LzFind.h"
|
#include "LzFind.h"
|
||||||
#include "Threads.h"
|
#include "Threads.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define kMtHashBlockSize (1 << 13)
|
#define kMtHashBlockSize (1 << 13)
|
||||||
#define kMtHashNumBlocks (1 << 3)
|
#define kMtHashNumBlocks (1 << 3)
|
||||||
@@ -98,8 +96,6 @@ SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddB
|
|||||||
void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable);
|
void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable);
|
||||||
void MatchFinderMt_ReleaseStream(CMatchFinderMt *p);
|
void MatchFinderMt_ReleaseStream(CMatchFinderMt *p);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
0
C/LzHash.h
Executable file → Normal file
0
C/LzHash.h
Executable file → Normal file
28
C/Lzma2Dec.c
Executable file → Normal file
28
C/Lzma2Dec.c
Executable file → Normal file
@@ -1,8 +1,10 @@
|
|||||||
/* Lzma2Dec.c -- LZMA2 Decoder
|
/* Lzma2Dec.c -- LZMA2 Decoder
|
||||||
2009-05-03 : Igor Pavlov : Public domain */
|
2010-12-15 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
/* #define SHOW_DEBUG_INFO */
|
/* #define SHOW_DEBUG_INFO */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#ifdef SHOW_DEBUG_INFO
|
#ifdef SHOW_DEBUG_INFO
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -330,27 +332,21 @@ SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *
|
|||||||
SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
||||||
Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc)
|
Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc)
|
||||||
{
|
{
|
||||||
CLzma2Dec decoder;
|
CLzma2Dec p;
|
||||||
SRes res;
|
SRes res;
|
||||||
SizeT outSize = *destLen, inSize = *srcLen;
|
SizeT outSize = *destLen, inSize = *srcLen;
|
||||||
Byte props[LZMA_PROPS_SIZE];
|
|
||||||
|
|
||||||
Lzma2Dec_Construct(&decoder);
|
|
||||||
|
|
||||||
*destLen = *srcLen = 0;
|
*destLen = *srcLen = 0;
|
||||||
*status = LZMA_STATUS_NOT_SPECIFIED;
|
*status = LZMA_STATUS_NOT_SPECIFIED;
|
||||||
decoder.decoder.dic = dest;
|
Lzma2Dec_Construct(&p);
|
||||||
decoder.decoder.dicBufSize = outSize;
|
RINOK(Lzma2Dec_AllocateProbs(&p, prop, alloc));
|
||||||
|
p.decoder.dic = dest;
|
||||||
RINOK(Lzma2Dec_GetOldProps(prop, props));
|
p.decoder.dicBufSize = outSize;
|
||||||
RINOK(LzmaDec_AllocateProbs(&decoder.decoder, props, LZMA_PROPS_SIZE, alloc));
|
Lzma2Dec_Init(&p);
|
||||||
|
|
||||||
*srcLen = inSize;
|
*srcLen = inSize;
|
||||||
res = Lzma2Dec_DecodeToDic(&decoder, outSize, src, srcLen, finishMode, status);
|
res = Lzma2Dec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
|
||||||
*destLen = decoder.decoder.dicPos;
|
*destLen = p.decoder.dicPos;
|
||||||
if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
|
if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
|
||||||
res = SZ_ERROR_INPUT_EOF;
|
res = SZ_ERROR_INPUT_EOF;
|
||||||
|
Lzma2Dec_FreeProbs(&p, alloc);
|
||||||
LzmaDec_FreeProbs(&decoder.decoder, alloc);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
10
C/Lzma2Dec.h
Executable file → Normal file
10
C/Lzma2Dec.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* Lzma2Dec.h -- LZMA2 Decoder
|
/* Lzma2Dec.h -- LZMA2 Decoder
|
||||||
2009-05-03 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA2_DEC_H
|
#ifndef __LZMA2_DEC_H
|
||||||
#define __LZMA2_DEC_H
|
#define __LZMA2_DEC_H
|
||||||
|
|
||||||
#include "LzmaDec.h"
|
#include "LzmaDec.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ---------- State Interface ---------- */
|
/* ---------- State Interface ---------- */
|
||||||
|
|
||||||
@@ -77,8 +75,6 @@ Returns:
|
|||||||
SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
||||||
Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc);
|
Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
26
C/Lzma2Enc.c
Executable file → Normal file
26
C/Lzma2Enc.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* Lzma2Enc.c -- LZMA2 Encoder
|
/* Lzma2Enc.c -- LZMA2 Encoder
|
||||||
2010-03-25 : Igor Pavlov : Public domain */
|
2012-06-19 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
/* #include <stdio.h> */
|
/* #include <stdio.h> */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -141,7 +143,7 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
|
|||||||
|
|
||||||
PRF(printf(" "));
|
PRF(printf(" "));
|
||||||
|
|
||||||
outBuf[destPos++] = (Byte)(LZMA2_CONTROL_LZMA | (mode << 5) | (u >> 16) & 0x1F);
|
outBuf[destPos++] = (Byte)(LZMA2_CONTROL_LZMA | (mode << 5) | ((u >> 16) & 0x1F));
|
||||||
outBuf[destPos++] = (Byte)(u >> 8);
|
outBuf[destPos++] = (Byte)(u >> 8);
|
||||||
outBuf[destPos++] = (Byte)u;
|
outBuf[destPos++] = (Byte)u;
|
||||||
outBuf[destPos++] = (Byte)(pm >> 8);
|
outBuf[destPos++] = (Byte)(pm >> 8);
|
||||||
@@ -216,8 +218,7 @@ void Lzma2EncProps_Normalize(CLzma2EncProps *p)
|
|||||||
t3 = t1n * t2;
|
t3 = t1n * t2;
|
||||||
|
|
||||||
p->lzmaProps.numThreads = t1;
|
p->lzmaProps.numThreads = t1;
|
||||||
p->numBlockThreads = t2;
|
|
||||||
p->numTotalThreads = t3;
|
|
||||||
LzmaEncProps_Normalize(&p->lzmaProps);
|
LzmaEncProps_Normalize(&p->lzmaProps);
|
||||||
|
|
||||||
if (p->blockSize == 0)
|
if (p->blockSize == 0)
|
||||||
@@ -231,6 +232,21 @@ void Lzma2EncProps_Normalize(CLzma2EncProps *p)
|
|||||||
if (blockSize < dictSize) blockSize = dictSize;
|
if (blockSize < dictSize) blockSize = dictSize;
|
||||||
p->blockSize = (size_t)blockSize;
|
p->blockSize = (size_t)blockSize;
|
||||||
}
|
}
|
||||||
|
if (t2 > 1)
|
||||||
|
{
|
||||||
|
UInt64 temp = p->lzmaProps.reduceSize + p->blockSize - 1;
|
||||||
|
if (temp > p->lzmaProps.reduceSize)
|
||||||
|
{
|
||||||
|
UInt64 numBlocks = temp / p->blockSize;
|
||||||
|
if (numBlocks < t2)
|
||||||
|
{
|
||||||
|
t2 = (UInt32)numBlocks;
|
||||||
|
t3 = t1 * t2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p->numBlockThreads = t2;
|
||||||
|
p->numTotalThreads = t3;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize)
|
static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize)
|
||||||
@@ -269,7 +285,7 @@ static SRes Lzma2Enc_EncodeMt1(CLzma2EncInt *p, CLzma2Enc *mainEncoder,
|
|||||||
|
|
||||||
if (mainEncoder->outBuf == 0)
|
if (mainEncoder->outBuf == 0)
|
||||||
{
|
{
|
||||||
mainEncoder->outBuf = IAlloc_Alloc(mainEncoder->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
|
mainEncoder->outBuf = (Byte *)IAlloc_Alloc(mainEncoder->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
|
||||||
if (mainEncoder->outBuf == 0)
|
if (mainEncoder->outBuf == 0)
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
}
|
}
|
||||||
|
|||||||
10
C/Lzma2Enc.h
Executable file → Normal file
10
C/Lzma2Enc.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* Lzma2Enc.h -- LZMA2 Encoder
|
/* Lzma2Enc.h -- LZMA2 Encoder
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA2_ENC_H
|
#ifndef __LZMA2_ENC_H
|
||||||
#define __LZMA2_ENC_H
|
#define __LZMA2_ENC_H
|
||||||
|
|
||||||
#include "LzmaEnc.h"
|
#include "LzmaEnc.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -59,8 +57,6 @@ SRes Lzma2Encode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
|||||||
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
4
C/Lzma86.h
Executable file → Normal file
4
C/Lzma86.h
Executable file → Normal file
@@ -1,10 +1,10 @@
|
|||||||
/* Lzma86.h -- LZMA + x86 (BCJ) Filter
|
/* Lzma86.h -- LZMA + x86 (BCJ) Filter
|
||||||
2009-08-14 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA86_H
|
#ifndef __LZMA86_H
|
||||||
#define __LZMA86_H
|
#define __LZMA86_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
|||||||
0
C/Lzma86Dec.c
Executable file → Normal file
0
C/Lzma86Dec.c
Executable file → Normal file
2
C/Lzma86Enc.c
Executable file → Normal file
2
C/Lzma86Enc.c
Executable file → Normal file
@@ -99,7 +99,7 @@ int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dest[0] = (bestIsFiltered ? 1 : 0);
|
dest[0] = (Byte)(bestIsFiltered ? 1 : 0);
|
||||||
*destLen = LZMA86_HEADER_SIZE + minSize;
|
*destLen = LZMA86_HEADER_SIZE + minSize;
|
||||||
}
|
}
|
||||||
if (useFilter)
|
if (useFilter)
|
||||||
|
|||||||
64
C/LzmaDec.c
Executable file → Normal file
64
C/LzmaDec.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* LzmaDec.c -- LZMA Decoder
|
/* LzmaDec.c -- LZMA Decoder
|
||||||
2009-09-20 : Igor Pavlov : Public domain */
|
2011-09-03 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "LzmaDec.h"
|
#include "LzmaDec.h"
|
||||||
|
|
||||||
@@ -44,6 +46,13 @@
|
|||||||
i -= 0x40; }
|
i -= 0x40; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NORMAL_LITER_DEC GET_BIT(prob + symbol, symbol)
|
||||||
|
#define MATCHED_LITER_DEC \
|
||||||
|
matchByte <<= 1; \
|
||||||
|
bit = (matchByte & offs); \
|
||||||
|
probLit = prob + offs + bit + symbol; \
|
||||||
|
GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
|
||||||
|
|
||||||
#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
|
#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
|
||||||
|
|
||||||
#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
|
#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
|
||||||
@@ -171,7 +180,18 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
{
|
{
|
||||||
state -= (state < 4) ? state : 3;
|
state -= (state < 4) ? state : 3;
|
||||||
symbol = 1;
|
symbol = 1;
|
||||||
do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100);
|
#ifdef _LZMA_SIZE_OPT
|
||||||
|
do { NORMAL_LITER_DEC } while (symbol < 0x100);
|
||||||
|
#else
|
||||||
|
NORMAL_LITER_DEC
|
||||||
|
NORMAL_LITER_DEC
|
||||||
|
NORMAL_LITER_DEC
|
||||||
|
NORMAL_LITER_DEC
|
||||||
|
NORMAL_LITER_DEC
|
||||||
|
NORMAL_LITER_DEC
|
||||||
|
NORMAL_LITER_DEC
|
||||||
|
NORMAL_LITER_DEC
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -179,16 +199,28 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
unsigned offs = 0x100;
|
unsigned offs = 0x100;
|
||||||
state -= (state < 10) ? 3 : 6;
|
state -= (state < 10) ? 3 : 6;
|
||||||
symbol = 1;
|
symbol = 1;
|
||||||
|
#ifdef _LZMA_SIZE_OPT
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
unsigned bit;
|
unsigned bit;
|
||||||
CLzmaProb *probLit;
|
CLzmaProb *probLit;
|
||||||
matchByte <<= 1;
|
MATCHED_LITER_DEC
|
||||||
bit = (matchByte & offs);
|
|
||||||
probLit = prob + offs + bit + symbol;
|
|
||||||
GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
|
|
||||||
}
|
}
|
||||||
while (symbol < 0x100);
|
while (symbol < 0x100);
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
unsigned bit;
|
||||||
|
CLzmaProb *probLit;
|
||||||
|
MATCHED_LITER_DEC
|
||||||
|
MATCHED_LITER_DEC
|
||||||
|
MATCHED_LITER_DEC
|
||||||
|
MATCHED_LITER_DEC
|
||||||
|
MATCHED_LITER_DEC
|
||||||
|
MATCHED_LITER_DEC
|
||||||
|
MATCHED_LITER_DEC
|
||||||
|
MATCHED_LITER_DEC
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
dic[dicPos++] = (Byte)symbol;
|
dic[dicPos++] = (Byte)symbol;
|
||||||
processedPos++;
|
processedPos++;
|
||||||
@@ -442,8 +474,9 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
|
|||||||
|
|
||||||
p->processedPos += len;
|
p->processedPos += len;
|
||||||
p->remainLen -= len;
|
p->remainLen -= len;
|
||||||
while (len-- != 0)
|
while (len != 0)
|
||||||
{
|
{
|
||||||
|
len--;
|
||||||
dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
|
dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
|
||||||
dicPos++;
|
dicPos++;
|
||||||
}
|
}
|
||||||
@@ -972,28 +1005,21 @@ SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
|||||||
{
|
{
|
||||||
CLzmaDec p;
|
CLzmaDec p;
|
||||||
SRes res;
|
SRes res;
|
||||||
SizeT inSize = *srcLen;
|
SizeT outSize = *destLen, inSize = *srcLen;
|
||||||
SizeT outSize = *destLen;
|
*destLen = *srcLen = 0;
|
||||||
*srcLen = *destLen = 0;
|
*status = LZMA_STATUS_NOT_SPECIFIED;
|
||||||
if (inSize < RC_INIT_SIZE)
|
if (inSize < RC_INIT_SIZE)
|
||||||
return SZ_ERROR_INPUT_EOF;
|
return SZ_ERROR_INPUT_EOF;
|
||||||
|
|
||||||
LzmaDec_Construct(&p);
|
LzmaDec_Construct(&p);
|
||||||
res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc);
|
RINOK(LzmaDec_AllocateProbs(&p, propData, propSize, alloc));
|
||||||
if (res != 0)
|
|
||||||
return res;
|
|
||||||
p.dic = dest;
|
p.dic = dest;
|
||||||
p.dicBufSize = outSize;
|
p.dicBufSize = outSize;
|
||||||
|
|
||||||
LzmaDec_Init(&p);
|
LzmaDec_Init(&p);
|
||||||
|
|
||||||
*srcLen = inSize;
|
*srcLen = inSize;
|
||||||
res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
|
res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
|
||||||
|
*destLen = p.dicPos;
|
||||||
if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
|
if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
|
||||||
res = SZ_ERROR_INPUT_EOF;
|
res = SZ_ERROR_INPUT_EOF;
|
||||||
|
|
||||||
(*destLen) = p.dicPos;
|
|
||||||
LzmaDec_FreeProbs(&p, alloc);
|
LzmaDec_FreeProbs(&p, alloc);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
12
C/LzmaDec.h
Executable file → Normal file
12
C/LzmaDec.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* LzmaDec.h -- LZMA Decoder
|
/* LzmaDec.h -- LZMA Decoder
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA_DEC_H
|
#ifndef __LZMA_DEC_H
|
||||||
#define __LZMA_DEC_H
|
#define __LZMA_DEC_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* #define _LZMA_PROB32 */
|
/* #define _LZMA_PROB32 */
|
||||||
/* _LZMA_PROB32 can increase the speed on some CPUs,
|
/* _LZMA_PROB32 can increase the speed on some CPUs,
|
||||||
@@ -224,8 +222,6 @@ SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
|||||||
const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
|
const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
|
||||||
ELzmaStatus *status, ISzAlloc *alloc);
|
ELzmaStatus *status, ISzAlloc *alloc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
18
C/LzmaEnc.c
Executable file → Normal file
18
C/LzmaEnc.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* LzmaEnc.c -- LZMA Encoder
|
/* LzmaEnc.c -- LZMA Encoder
|
||||||
2009-11-24 : Igor Pavlov : Public domain */
|
2012-11-20 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -46,6 +48,7 @@ void LzmaEncProps_Init(CLzmaEncProps *p)
|
|||||||
{
|
{
|
||||||
p->level = 5;
|
p->level = 5;
|
||||||
p->dictSize = p->mc = 0;
|
p->dictSize = p->mc = 0;
|
||||||
|
p->reduceSize = (UInt64)(Int64)-1;
|
||||||
p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1;
|
p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1;
|
||||||
p->writeEndMark = 0;
|
p->writeEndMark = 0;
|
||||||
}
|
}
|
||||||
@@ -56,6 +59,15 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p)
|
|||||||
if (level < 0) level = 5;
|
if (level < 0) level = 5;
|
||||||
p->level = level;
|
p->level = level;
|
||||||
if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26)));
|
if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26)));
|
||||||
|
if (p->dictSize > p->reduceSize)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
for (i = 11; i <= 30; i++)
|
||||||
|
{
|
||||||
|
if ((UInt32)p->reduceSize <= ((UInt32)2 << i)) { p->dictSize = ((UInt32)2 << i); break; }
|
||||||
|
if ((UInt32)p->reduceSize <= ((UInt32)3 << i)) { p->dictSize = ((UInt32)3 << i); break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
if (p->lc < 0) p->lc = 3;
|
if (p->lc < 0) p->lc = 3;
|
||||||
if (p->lp < 0) p->lp = 0;
|
if (p->lp < 0) p->lp = 0;
|
||||||
if (p->pb < 0) p->pb = 2;
|
if (p->pb < 0) p->pb = 2;
|
||||||
@@ -329,7 +341,6 @@ typedef struct
|
|||||||
|
|
||||||
SRes result;
|
SRes result;
|
||||||
UInt32 dictSize;
|
UInt32 dictSize;
|
||||||
UInt32 matchFinderCycles;
|
|
||||||
|
|
||||||
int needInit;
|
int needInit;
|
||||||
|
|
||||||
@@ -395,10 +406,9 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
|
|||||||
LzmaEncProps_Normalize(&props);
|
LzmaEncProps_Normalize(&props);
|
||||||
|
|
||||||
if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX ||
|
if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX ||
|
||||||
props.dictSize > (1 << kDicLogSizeMaxCompress) || props.dictSize > (1 << 30))
|
props.dictSize > ((UInt32)1 << kDicLogSizeMaxCompress) || props.dictSize > ((UInt32)1 << 30))
|
||||||
return SZ_ERROR_PARAM;
|
return SZ_ERROR_PARAM;
|
||||||
p->dictSize = props.dictSize;
|
p->dictSize = props.dictSize;
|
||||||
p->matchFinderCycles = props.mc;
|
|
||||||
{
|
{
|
||||||
unsigned fb = props.fb;
|
unsigned fb = props.fb;
|
||||||
if (fb < 5)
|
if (fb < 5)
|
||||||
|
|||||||
14
C/LzmaEnc.h
Executable file → Normal file
14
C/LzmaEnc.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* LzmaEnc.h -- LZMA Encoder
|
/* LzmaEnc.h -- LZMA Encoder
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA_ENC_H
|
#ifndef __LZMA_ENC_H
|
||||||
#define __LZMA_ENC_H
|
#define __LZMA_ENC_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LZMA_PROPS_SIZE 5
|
#define LZMA_PROPS_SIZE 5
|
||||||
|
|
||||||
@@ -18,6 +16,8 @@ typedef struct _CLzmaEncProps
|
|||||||
UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
|
UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
|
||||||
(1 << 12) <= dictSize <= (1 << 30) for 64-bit version
|
(1 << 12) <= dictSize <= (1 << 30) for 64-bit version
|
||||||
default = (1 << 24) */
|
default = (1 << 24) */
|
||||||
|
UInt64 reduceSize; /* estimated size of data that will be compressed. default = 0xFFFFFFFF.
|
||||||
|
Encoder uses this value to reduce dictionary size */
|
||||||
int lc; /* 0 <= lc <= 8, default = 3 */
|
int lc; /* 0 <= lc <= 8, default = 3 */
|
||||||
int lp; /* 0 <= lp <= 4, default = 0 */
|
int lp; /* 0 <= lp <= 4, default = 0 */
|
||||||
int pb; /* 0 <= pb <= 4, default = 2 */
|
int pb; /* 0 <= pb <= 4, default = 2 */
|
||||||
@@ -73,8 +73,6 @@ SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
|||||||
const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
|
const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
|
||||||
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
0
C/LzmaLib.c
Executable file → Normal file
0
C/LzmaLib.c
Executable file → Normal file
12
C/LzmaLib.h
Executable file → Normal file
12
C/LzmaLib.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* LzmaLib.h -- LZMA library interface
|
/* LzmaLib.h -- LZMA library interface
|
||||||
2009-04-07 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA_LIB_H
|
#ifndef __LZMA_LIB_H
|
||||||
#define __LZMA_LIB_H
|
#define __LZMA_LIB_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MY_STDAPI int MY_STD_CALL
|
#define MY_STDAPI int MY_STD_CALL
|
||||||
|
|
||||||
@@ -128,8 +126,6 @@ Returns:
|
|||||||
MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen,
|
MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen,
|
||||||
const unsigned char *props, size_t propsSize);
|
const unsigned char *props, size_t propsSize);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
6
C/MtCoder.c
Executable file → Normal file
6
C/MtCoder.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* MtCoder.c -- Multi-thread Coder
|
/* MtCoder.c -- Multi-thread Coder
|
||||||
2010-03-24 : Igor Pavlov : Public domain */
|
2010-09-24 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -148,7 +150,7 @@ static void CMtThread_Destruct(CMtThread *p)
|
|||||||
#define MY_BUF_ALLOC(buf, size, newSize) \
|
#define MY_BUF_ALLOC(buf, size, newSize) \
|
||||||
if (buf == 0 || size != newSize) \
|
if (buf == 0 || size != newSize) \
|
||||||
{ IAlloc_Free(p->mtCoder->alloc, buf); \
|
{ IAlloc_Free(p->mtCoder->alloc, buf); \
|
||||||
size = newSize; buf = IAlloc_Alloc(p->mtCoder->alloc, size); \
|
size = newSize; buf = (Byte *)IAlloc_Alloc(p->mtCoder->alloc, size); \
|
||||||
if (buf == 0) return SZ_ERROR_MEM; }
|
if (buf == 0) return SZ_ERROR_MEM; }
|
||||||
|
|
||||||
static SRes CMtThread_Prepare(CMtThread *p)
|
static SRes CMtThread_Prepare(CMtThread *p)
|
||||||
|
|||||||
0
C/MtCoder.h
Executable file → Normal file
0
C/MtCoder.h
Executable file → Normal file
8
C/Ppmd.h
Executable file → Normal file
8
C/Ppmd.h
Executable file → Normal file
@@ -1,11 +1,10 @@
|
|||||||
/* Ppmd.h -- PPMD codec common code
|
/* Ppmd.h -- PPMD codec common code
|
||||||
2010-03-12 : Igor Pavlov : Public domain
|
2013-01-18 : Igor Pavlov : Public domain
|
||||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||||
|
|
||||||
#ifndef __PPMD_H
|
#ifndef __PPMD_H
|
||||||
#define __PPMD_H
|
#define __PPMD_H
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
||||||
@@ -29,6 +28,9 @@ EXTERN_C_BEGIN
|
|||||||
#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4)
|
#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4)
|
||||||
#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4)
|
#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4)
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
/* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */
|
||||||
|
|
||||||
/* SEE-contexts for PPM-contexts with masked symbols */
|
/* SEE-contexts for PPM-contexts with masked symbols */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -48,6 +50,8 @@ typedef struct
|
|||||||
UInt16 SuccessorHigh;
|
UInt16 SuccessorHigh;
|
||||||
} CPpmd_State;
|
} CPpmd_State;
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
#ifdef PPMD_32BIT
|
#ifdef PPMD_32BIT
|
||||||
CPpmd_State *
|
CPpmd_State *
|
||||||
|
|||||||
2
C/Ppmd7.c
Executable file → Normal file
2
C/Ppmd7.c
Executable file → Normal file
@@ -2,6 +2,8 @@
|
|||||||
2010-03-12 : Igor Pavlov : Public domain
|
2010-03-12 : Igor Pavlov : Public domain
|
||||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
#include "Ppmd7.h"
|
#include "Ppmd7.h"
|
||||||
|
|||||||
2
C/Ppmd7Dec.c
Executable file → Normal file
2
C/Ppmd7Dec.c
Executable file → Normal file
@@ -2,6 +2,8 @@
|
|||||||
2010-03-12 : Igor Pavlov : Public domain
|
2010-03-12 : Igor Pavlov : Public domain
|
||||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Ppmd7.h"
|
#include "Ppmd7.h"
|
||||||
|
|
||||||
#define kTopValue (1 << 24)
|
#define kTopValue (1 << 24)
|
||||||
|
|||||||
2
C/Ppmd7Enc.c
Executable file → Normal file
2
C/Ppmd7Enc.c
Executable file → Normal file
@@ -2,6 +2,8 @@
|
|||||||
2010-03-12 : Igor Pavlov : Public domain
|
2010-03-12 : Igor Pavlov : Public domain
|
||||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Ppmd7.h"
|
#include "Ppmd7.h"
|
||||||
|
|
||||||
#define kTopValue (1 << 24)
|
#define kTopValue (1 << 24)
|
||||||
|
|||||||
25
C/Ppmd8.c
Executable file → Normal file
25
C/Ppmd8.c
Executable file → Normal file
@@ -1,7 +1,9 @@
|
|||||||
/* Ppmd8.c -- PPMdI codec
|
/* Ppmd8.c -- PPMdI codec
|
||||||
2010-03-24 : Igor Pavlov : Public domain
|
2013-11-12 : Igor Pavlov : Public domain
|
||||||
This code is based on PPMd var.I (2002): Dmitry Shkarin : Public domain */
|
This code is based on PPMd var.I (2002): Dmitry Shkarin : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
#include "Ppmd8.h"
|
#include "Ppmd8.h"
|
||||||
@@ -483,10 +485,11 @@ static CPpmd_Void_Ref CutOff(CPpmd8 *p, CTX_PTR ctx, unsigned order)
|
|||||||
}
|
}
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
ctx->Flags = (ctx->Flags & 0x10) + 0x08 * (s->Symbol >= 0x40);
|
ctx->Flags = (Byte)((ctx->Flags & 0x10) + 0x08 * (s->Symbol >= 0x40));
|
||||||
*ONE_STATE(ctx) = *s;
|
*ONE_STATE(ctx) = *s;
|
||||||
FreeUnits(p, s, tmp);
|
FreeUnits(p, s, tmp);
|
||||||
ONE_STATE(ctx)->Freq = (Byte)((unsigned)ONE_STATE(ctx)->Freq + 11) >> 3;
|
/* 9.31: the code was fixed. It's was not BUG, if Freq <= MAX_FREQ = 124 */
|
||||||
|
ONE_STATE(ctx)->Freq = (Byte)(((unsigned)ONE_STATE(ctx)->Freq + 11) >> 3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Refresh(p, ctx, tmp, ctx->SummFreq > 16 * i);
|
Refresh(p, ctx, tmp, ctx->SummFreq > 16 * i);
|
||||||
@@ -554,17 +557,17 @@ static void RestoreModel(CPpmd8 *p, CTX_PTR c1
|
|||||||
if (--(c->NumStats) == 0)
|
if (--(c->NumStats) == 0)
|
||||||
{
|
{
|
||||||
s = STATS(c);
|
s = STATS(c);
|
||||||
c->Flags = (c->Flags & 0x10) + 0x08 * (s->Symbol >= 0x40);
|
c->Flags = (Byte)((c->Flags & 0x10) + 0x08 * (s->Symbol >= 0x40));
|
||||||
*ONE_STATE(c) = *s;
|
*ONE_STATE(c) = *s;
|
||||||
SpecialFreeUnit(p, s);
|
SpecialFreeUnit(p, s);
|
||||||
ONE_STATE(c)->Freq = (ONE_STATE(c)->Freq + 11) >> 3;
|
ONE_STATE(c)->Freq = (Byte)(((unsigned)ONE_STATE(c)->Freq + 11) >> 3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Refresh(p, c, (c->NumStats+3) >> 1, 0);
|
Refresh(p, c, (c->NumStats+3) >> 1, 0);
|
||||||
|
|
||||||
for (; c != p->MinContext; c = SUFFIX(c))
|
for (; c != p->MinContext; c = SUFFIX(c))
|
||||||
if (!c->NumStats)
|
if (!c->NumStats)
|
||||||
ONE_STATE(c)->Freq -= ONE_STATE(c)->Freq >> 1;
|
ONE_STATE(c)->Freq = (Byte)(ONE_STATE(c)->Freq - (ONE_STATE(c)->Freq >> 1));
|
||||||
else if ((c->SummFreq += 4) > 128 + 4 * c->NumStats)
|
else if ((c->SummFreq += 4) > 128 + 4 * c->NumStats)
|
||||||
Refresh(p, c, (c->NumStats + 2) >> 1, 1);
|
Refresh(p, c, (c->NumStats + 2) >> 1, 1);
|
||||||
|
|
||||||
@@ -636,7 +639,7 @@ static CTX_PTR CreateSuccessors(CPpmd8 *p, Bool skip, CPpmd_State *s1, CTX_PTR c
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = ONE_STATE(c);
|
s = ONE_STATE(c);
|
||||||
s->Freq += (!SUFFIX(c)->NumStats & (s->Freq < 24));
|
s->Freq = (Byte)(s->Freq + (!SUFFIX(c)->NumStats & (s->Freq < 24)));
|
||||||
}
|
}
|
||||||
successor = SUCCESSOR(s);
|
successor = SUCCESSOR(s);
|
||||||
if (successor != upBranch)
|
if (successor != upBranch)
|
||||||
@@ -651,7 +654,7 @@ static CTX_PTR CreateSuccessors(CPpmd8 *p, Bool skip, CPpmd_State *s1, CTX_PTR c
|
|||||||
|
|
||||||
upState.Symbol = *(const Byte *)Ppmd8_GetPtr(p, upBranch);
|
upState.Symbol = *(const Byte *)Ppmd8_GetPtr(p, upBranch);
|
||||||
SetSuccessor(&upState, upBranch + 1);
|
SetSuccessor(&upState, upBranch + 1);
|
||||||
flags = 0x10 * (p->FoundState->Symbol >= 0x40) + 0x08 * (upState.Symbol >= 0x40);
|
flags = (Byte)(0x10 * (p->FoundState->Symbol >= 0x40) + 0x08 * (upState.Symbol >= 0x40));
|
||||||
|
|
||||||
if (c->NumStats == 0)
|
if (c->NumStats == 0)
|
||||||
upState.Freq = ONE_STATE(c)->Freq;
|
upState.Freq = ONE_STATE(c)->Freq;
|
||||||
@@ -743,7 +746,7 @@ static CTX_PTR ReduceOrder(CPpmd8 *p, CPpmd_State *s1, CTX_PTR c)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = ONE_STATE(c);
|
s = ONE_STATE(c);
|
||||||
s->Freq += (s->Freq < 32);
|
s->Freq = (Byte)(s->Freq + (s->Freq < 32));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SUCCESSOR(s))
|
if (SUCCESSOR(s))
|
||||||
@@ -889,7 +892,7 @@ static void UpdateModel(CPpmd8 *p)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - fFreq;
|
s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - fFreq;
|
||||||
flag = 0x08 * (fSymbol >= 0x40);
|
flag = (Byte)(0x08 * (fSymbol >= 0x40));
|
||||||
|
|
||||||
for (; c != p->MinContext; c = SUFFIX(c))
|
for (; c != p->MinContext; c = SUFFIX(c))
|
||||||
{
|
{
|
||||||
@@ -1012,7 +1015,7 @@ static void Rescale(CPpmd8 *p)
|
|||||||
if (tmp.Freq > MAX_FREQ / 3)
|
if (tmp.Freq > MAX_FREQ / 3)
|
||||||
tmp.Freq = MAX_FREQ / 3;
|
tmp.Freq = MAX_FREQ / 3;
|
||||||
InsertNode(p, stats, U2I((numStats + 2) >> 1));
|
InsertNode(p, stats, U2I((numStats + 2) >> 1));
|
||||||
p->MinContext->Flags = (p->MinContext->Flags & 0x10) + 0x08 * (tmp.Symbol >= 0x40);
|
p->MinContext->Flags = (Byte)((p->MinContext->Flags & 0x10) + 0x08 * (tmp.Symbol >= 0x40));
|
||||||
*(p->FoundState = ONE_STATE(p->MinContext)) = tmp;
|
*(p->FoundState = ONE_STATE(p->MinContext)) = tmp;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
6
C/Ppmd8.h
Executable file → Normal file
6
C/Ppmd8.h
Executable file → Normal file
@@ -1,5 +1,5 @@
|
|||||||
/* Ppmd8.h -- PPMdI codec
|
/* Ppmd8.h -- PPMdI codec
|
||||||
2010-03-24 : Igor Pavlov : Public domain
|
2011-01-27 : Igor Pavlov : Public domain
|
||||||
This code is based on:
|
This code is based on:
|
||||||
PPMd var.I (2002): Dmitry Shkarin : Public domain
|
PPMd var.I (2002): Dmitry Shkarin : Public domain
|
||||||
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
|
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
|
||||||
@@ -24,6 +24,8 @@ typedef
|
|||||||
#endif
|
#endif
|
||||||
CPpmd8_Context_Ref;
|
CPpmd8_Context_Ref;
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
typedef struct CPpmd8_Context_
|
typedef struct CPpmd8_Context_
|
||||||
{
|
{
|
||||||
Byte NumStats;
|
Byte NumStats;
|
||||||
@@ -33,6 +35,8 @@ typedef struct CPpmd8_Context_
|
|||||||
CPpmd8_Context_Ref Suffix;
|
CPpmd8_Context_Ref Suffix;
|
||||||
} CPpmd8_Context;
|
} CPpmd8_Context;
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
#define Ppmd8Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq)
|
#define Ppmd8Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq)
|
||||||
|
|
||||||
/* The BUG in Shkarin's code for FREEZE mode was fixed, but that fixed
|
/* The BUG in Shkarin's code for FREEZE mode was fixed, but that fixed
|
||||||
|
|||||||
6
C/Ppmd8Dec.c
Executable file → Normal file
6
C/Ppmd8Dec.c
Executable file → Normal file
@@ -1,9 +1,11 @@
|
|||||||
/* Ppmd8Dec.c -- PPMdI Decoder
|
/* Ppmd8Dec.c -- PPMdI Decoder
|
||||||
2010-03-12 : Igor Pavlov : Public domain
|
2010-04-16 : Igor Pavlov : Public domain
|
||||||
This code is based on:
|
This code is based on:
|
||||||
PPMd var.I (2002): Dmitry Shkarin : Public domain
|
PPMd var.I (2002): Dmitry Shkarin : Public domain
|
||||||
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
|
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Ppmd8.h"
|
#include "Ppmd8.h"
|
||||||
|
|
||||||
#define kTop (1 << 24)
|
#define kTop (1 << 24)
|
||||||
@@ -33,7 +35,7 @@ static void RangeDec_Decode(CPpmd8 *p, UInt32 start, UInt32 size)
|
|||||||
p->Range *= size;
|
p->Range *= size;
|
||||||
|
|
||||||
while ((p->Low ^ (p->Low + p->Range)) < kTop ||
|
while ((p->Low ^ (p->Low + p->Range)) < kTop ||
|
||||||
p->Range < kBot && ((p->Range = (0 - p->Low) & (kBot - 1)), 1))
|
(p->Range < kBot && ((p->Range = (0 - p->Low) & (kBot - 1)), 1)))
|
||||||
{
|
{
|
||||||
p->Code = (p->Code << 8) | p->Stream.In->Read(p->Stream.In);
|
p->Code = (p->Code << 8) | p->Stream.In->Read(p->Stream.In);
|
||||||
p->Range <<= 8;
|
p->Range <<= 8;
|
||||||
|
|||||||
6
C/Ppmd8Enc.c
Executable file → Normal file
6
C/Ppmd8Enc.c
Executable file → Normal file
@@ -1,9 +1,11 @@
|
|||||||
/* Ppmd8Enc.c -- PPMdI Encoder
|
/* Ppmd8Enc.c -- PPMdI Encoder
|
||||||
2010-03-12 : Igor Pavlov : Public domain
|
2010-04-16 : Igor Pavlov : Public domain
|
||||||
This code is based on:
|
This code is based on:
|
||||||
PPMd var.I (2002): Dmitry Shkarin : Public domain
|
PPMd var.I (2002): Dmitry Shkarin : Public domain
|
||||||
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
|
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Ppmd8.h"
|
#include "Ppmd8.h"
|
||||||
|
|
||||||
#define kTop (1 << 24)
|
#define kTop (1 << 24)
|
||||||
@@ -19,7 +21,7 @@ void Ppmd8_RangeEnc_FlushData(CPpmd8 *p)
|
|||||||
static void RangeEnc_Normalize(CPpmd8 *p)
|
static void RangeEnc_Normalize(CPpmd8 *p)
|
||||||
{
|
{
|
||||||
while ((p->Low ^ (p->Low + p->Range)) < kTop ||
|
while ((p->Low ^ (p->Low + p->Range)) < kTop ||
|
||||||
p->Range < kBot && ((p->Range = (0 - p->Low) & (kBot - 1)), 1))
|
(p->Range < kBot && ((p->Range = (0 - p->Low) & (kBot - 1)), 1)))
|
||||||
{
|
{
|
||||||
p->Stream.Out->Write(p->Stream.Out, (Byte)(p->Low >> 24));
|
p->Stream.Out->Write(p->Stream.Out, (Byte)(p->Low >> 24));
|
||||||
p->Range <<= 8;
|
p->Range <<= 8;
|
||||||
|
|||||||
10
C/Precomp.h
Normal file
10
C/Precomp.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/* Precomp.h -- StdAfx
|
||||||
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __7Z_PRECOMP_H
|
||||||
|
#define __7Z_PRECOMP_H
|
||||||
|
|
||||||
|
#include "Compiler.h"
|
||||||
|
/* #include "7zTypes.h" */
|
||||||
|
|
||||||
|
#endif
|
||||||
8
C/RotateDefs.h
Executable file → Normal file
8
C/RotateDefs.h
Executable file → Normal file
@@ -1,5 +1,5 @@
|
|||||||
/* RotateDefs.h -- Rotate functions
|
/* RotateDefs.h -- Rotate functions
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __ROTATE_DEFS_H
|
#ifndef __ROTATE_DEFS_H
|
||||||
#define __ROTATE_DEFS_H
|
#define __ROTATE_DEFS_H
|
||||||
@@ -7,6 +7,12 @@
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
// #if (_MSC_VER >= 1200)
|
||||||
|
#pragma intrinsic(_rotl)
|
||||||
|
#pragma intrinsic(_rotr)
|
||||||
|
// #endif
|
||||||
|
|
||||||
#define rotlFixed(x, n) _rotl((x), (n))
|
#define rotlFixed(x, n) _rotl((x), (n))
|
||||||
#define rotrFixed(x, n) _rotr((x), (n))
|
#define rotrFixed(x, n) _rotr((x), (n))
|
||||||
|
|
||||||
|
|||||||
10
C/Sha256.c
Executable file → Normal file
10
C/Sha256.c
Executable file → Normal file
@@ -1,9 +1,11 @@
|
|||||||
/* Crypto/Sha256.c -- SHA-256 Hash function
|
/* Crypto/Sha256.c -- SHA-256 Hash
|
||||||
2008-11-06 : Igor Pavlov : Public domain
|
2010-06-11 : Igor Pavlov : Public domain
|
||||||
This code is based on public domain code from Wei Dai's Crypto++ library. */
|
This code is based on public domain code from Wei Dai's Crypto++ library. */
|
||||||
|
|
||||||
#include "Sha256.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "RotateDefs.h"
|
#include "RotateDefs.h"
|
||||||
|
#include "Sha256.h"
|
||||||
|
|
||||||
/* define it for speed optimization */
|
/* define it for speed optimization */
|
||||||
/* #define _SHA256_UNROLL */
|
/* #define _SHA256_UNROLL */
|
||||||
@@ -71,7 +73,7 @@ void Sha256_Init(CSha256 *p)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const UInt32 K[64] = {
|
static const UInt32 K[64] = {
|
||||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
||||||
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
||||||
|
|||||||
12
C/Sha256.h
Executable file → Normal file
12
C/Sha256.h
Executable file → Normal file
@@ -1,14 +1,12 @@
|
|||||||
/* Sha256.h -- SHA-256 Hash
|
/* Sha256.h -- SHA-256 Hash
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2013-01-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __CRYPTO_SHA256_H
|
#ifndef __CRYPTO_SHA256_H
|
||||||
#define __CRYPTO_SHA256_H
|
#define __CRYPTO_SHA256_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SHA256_DIGEST_SIZE 32
|
#define SHA256_DIGEST_SIZE 32
|
||||||
|
|
||||||
@@ -23,8 +21,6 @@ void Sha256_Init(CSha256 *p);
|
|||||||
void Sha256_Update(CSha256 *p, const Byte *data, size_t size);
|
void Sha256_Update(CSha256 *p, const Byte *data, size_t size);
|
||||||
void Sha256_Final(CSha256 *p, Byte *digest);
|
void Sha256_Final(CSha256 *p, Byte *digest);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
72
C/Sort.c
Executable file → Normal file
72
C/Sort.c
Executable file → Normal file
@@ -1,30 +1,30 @@
|
|||||||
/* Sort.c -- Sort functions
|
/* Sort.c -- Sort functions
|
||||||
2008-08-17
|
2014-04-05 : Igor Pavlov : Public domain */
|
||||||
Igor Pavlov
|
|
||||||
Public domain */
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "Sort.h"
|
#include "Sort.h"
|
||||||
|
|
||||||
#define HeapSortDown(p, k, size, temp) \
|
#define HeapSortDown(p, k, size, temp) \
|
||||||
{ for (;;) { \
|
{ for (;;) { \
|
||||||
UInt32 s = (k << 1); \
|
size_t s = (k << 1); \
|
||||||
if (s > size) break; \
|
if (s > size) break; \
|
||||||
if (s < size && p[s + 1] > p[s]) s++; \
|
if (s < size && p[s + 1] > p[s]) s++; \
|
||||||
if (temp >= p[s]) break; \
|
if (temp >= p[s]) break; \
|
||||||
p[k] = p[s]; k = s; \
|
p[k] = p[s]; k = s; \
|
||||||
} p[k] = temp; }
|
} p[k] = temp; }
|
||||||
|
|
||||||
void HeapSort(UInt32 *p, UInt32 size)
|
void HeapSort(UInt32 *p, size_t size)
|
||||||
{
|
{
|
||||||
if (size <= 1)
|
if (size <= 1)
|
||||||
return;
|
return;
|
||||||
p--;
|
p--;
|
||||||
{
|
{
|
||||||
UInt32 i = size / 2;
|
size_t i = size / 2;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
UInt32 temp = p[i];
|
UInt32 temp = p[i];
|
||||||
UInt32 k = i;
|
size_t k = i;
|
||||||
HeapSortDown(p, k, size, temp)
|
HeapSortDown(p, k, size, temp)
|
||||||
}
|
}
|
||||||
while (--i != 0);
|
while (--i != 0);
|
||||||
@@ -32,7 +32,7 @@ void HeapSort(UInt32 *p, UInt32 size)
|
|||||||
/*
|
/*
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
UInt32 k = 1;
|
size_t k = 1;
|
||||||
UInt32 temp = p[size];
|
UInt32 temp = p[size];
|
||||||
p[size--] = p[1];
|
p[size--] = p[1];
|
||||||
HeapSortDown(p, k, size, temp)
|
HeapSortDown(p, k, size, temp)
|
||||||
@@ -42,7 +42,7 @@ void HeapSort(UInt32 *p, UInt32 size)
|
|||||||
while (size > 3)
|
while (size > 3)
|
||||||
{
|
{
|
||||||
UInt32 temp = p[size];
|
UInt32 temp = p[size];
|
||||||
UInt32 k = (p[3] > p[2]) ? 3 : 2;
|
size_t k = (p[3] > p[2]) ? 3 : 2;
|
||||||
p[size--] = p[1];
|
p[size--] = p[1];
|
||||||
p[1] = p[k];
|
p[1] = p[k];
|
||||||
HeapSortDown(p, k, size, temp)
|
HeapSortDown(p, k, size, temp)
|
||||||
@@ -60,23 +60,69 @@ void HeapSort(UInt32 *p, UInt32 size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HeapSort64(UInt64 *p, size_t size)
|
||||||
|
{
|
||||||
|
if (size <= 1)
|
||||||
|
return;
|
||||||
|
p--;
|
||||||
|
{
|
||||||
|
size_t i = size / 2;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
UInt64 temp = p[i];
|
||||||
|
size_t k = i;
|
||||||
|
HeapSortDown(p, k, size, temp)
|
||||||
|
}
|
||||||
|
while (--i != 0);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
do
|
||||||
|
{
|
||||||
|
size_t k = 1;
|
||||||
|
UInt64 temp = p[size];
|
||||||
|
p[size--] = p[1];
|
||||||
|
HeapSortDown(p, k, size, temp)
|
||||||
|
}
|
||||||
|
while (size > 1);
|
||||||
|
*/
|
||||||
|
while (size > 3)
|
||||||
|
{
|
||||||
|
UInt64 temp = p[size];
|
||||||
|
size_t k = (p[3] > p[2]) ? 3 : 2;
|
||||||
|
p[size--] = p[1];
|
||||||
|
p[1] = p[k];
|
||||||
|
HeapSortDown(p, k, size, temp)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
UInt64 temp = p[size];
|
||||||
|
p[size] = p[1];
|
||||||
|
if (size > 2 && p[2] < temp)
|
||||||
|
{
|
||||||
|
p[1] = p[2];
|
||||||
|
p[2] = temp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
p[1] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define HeapSortRefDown(p, vals, n, size, temp) \
|
#define HeapSortRefDown(p, vals, n, size, temp) \
|
||||||
{ UInt32 k = n; UInt32 val = vals[temp]; for (;;) { \
|
{ size_t k = n; UInt32 val = vals[temp]; for (;;) { \
|
||||||
UInt32 s = (k << 1); \
|
size_t s = (k << 1); \
|
||||||
if (s > size) break; \
|
if (s > size) break; \
|
||||||
if (s < size && vals[p[s + 1]] > vals[p[s]]) s++; \
|
if (s < size && vals[p[s + 1]] > vals[p[s]]) s++; \
|
||||||
if (val >= vals[p[s]]) break; \
|
if (val >= vals[p[s]]) break; \
|
||||||
p[k] = p[s]; k = s; \
|
p[k] = p[s]; k = s; \
|
||||||
} p[k] = temp; }
|
} p[k] = temp; }
|
||||||
|
|
||||||
void HeapSortRef(UInt32 *p, UInt32 *vals, UInt32 size)
|
void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size)
|
||||||
{
|
{
|
||||||
if (size <= 1)
|
if (size <= 1)
|
||||||
return;
|
return;
|
||||||
p--;
|
p--;
|
||||||
{
|
{
|
||||||
UInt32 i = size / 2;
|
size_t i = size / 2;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
UInt32 temp = p[i];
|
UInt32 temp = p[i];
|
||||||
|
|||||||
18
C/Sort.h
Executable file → Normal file
18
C/Sort.h
Executable file → Normal file
@@ -1,20 +1,18 @@
|
|||||||
/* Sort.h -- Sort functions
|
/* Sort.h -- Sort functions
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2014-04-05 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_SORT_H
|
#ifndef __7Z_SORT_H
|
||||||
#define __7Z_SORT_H
|
#define __7Z_SORT_H
|
||||||
|
|
||||||
#include "Types.h"
|
#include "7zTypes.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_BEGIN
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void HeapSort(UInt32 *p, UInt32 size);
|
void HeapSort(UInt32 *p, size_t size);
|
||||||
/* void HeapSortRef(UInt32 *p, UInt32 *vals, UInt32 size); */
|
void HeapSort64(UInt64 *p, size_t size);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
/* void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size); */
|
||||||
}
|
|
||||||
#endif
|
EXTERN_C_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
27
C/Threads.c
Executable file → Normal file
27
C/Threads.c
Executable file → Normal file
@@ -1,5 +1,7 @@
|
|||||||
/* Threads.c -- multithreading library
|
/* Threads.c -- multithreading library
|
||||||
2009-09-20 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
#ifndef _WIN32_WCE
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
@@ -29,14 +31,21 @@ WRes Handle_WaitObject(HANDLE h) { return (WRes)WaitForSingleObject(h, INFINITE)
|
|||||||
|
|
||||||
WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param)
|
WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param)
|
||||||
{
|
{
|
||||||
unsigned threadId; /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */
|
/* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */
|
||||||
*p =
|
|
||||||
#ifdef UNDER_CE
|
#ifdef UNDER_CE
|
||||||
CreateThread(0, 0, func, param, 0, &threadId);
|
|
||||||
#else
|
DWORD threadId;
|
||||||
(HANDLE)_beginthreadex(NULL, 0, func, param, 0, &threadId);
|
*p = CreateThread(0, 0, func, param, 0, &threadId);
|
||||||
#endif
|
|
||||||
/* maybe we must use errno here, but probably GetLastError() is also OK. */
|
#else
|
||||||
|
|
||||||
|
unsigned threadId;
|
||||||
|
*p = (HANDLE)_beginthreadex(NULL, 0, func, param, 0, &threadId);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* maybe we must use errno here, but probably GetLastError() is also OK. */
|
||||||
return HandleToWRes(*p);
|
return HandleToWRes(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
26
C/Threads.h
Executable file → Normal file
26
C/Threads.h
Executable file → Normal file
@@ -1,15 +1,17 @@
|
|||||||
/* Threads.h -- multithreading library
|
/* Threads.h -- multithreading library
|
||||||
2009-03-27 : Igor Pavlov : Public domain */
|
2013-11-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_THREADS_H
|
#ifndef __7Z_THREADS_H
|
||||||
#define __7Z_THREADS_H
|
#define __7Z_THREADS_H
|
||||||
|
|
||||||
#include "Types.h"
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
WRes HandlePtr_Close(HANDLE *h);
|
WRes HandlePtr_Close(HANDLE *h);
|
||||||
WRes Handle_WaitObject(HANDLE h);
|
WRes Handle_WaitObject(HANDLE h);
|
||||||
|
|
||||||
@@ -18,7 +20,15 @@ typedef HANDLE CThread;
|
|||||||
#define Thread_WasCreated(p) (*(p) != NULL)
|
#define Thread_WasCreated(p) (*(p) != NULL)
|
||||||
#define Thread_Close(p) HandlePtr_Close(p)
|
#define Thread_Close(p) HandlePtr_Close(p)
|
||||||
#define Thread_Wait(p) Handle_WaitObject(*(p))
|
#define Thread_Wait(p) Handle_WaitObject(*(p))
|
||||||
typedef unsigned THREAD_FUNC_RET_TYPE;
|
|
||||||
|
typedef
|
||||||
|
#ifdef UNDER_CE
|
||||||
|
DWORD
|
||||||
|
#else
|
||||||
|
unsigned
|
||||||
|
#endif
|
||||||
|
THREAD_FUNC_RET_TYPE;
|
||||||
|
|
||||||
#define THREAD_FUNC_CALL_TYPE MY_STD_CALL
|
#define THREAD_FUNC_CALL_TYPE MY_STD_CALL
|
||||||
#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE
|
#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE
|
||||||
typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *);
|
typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *);
|
||||||
@@ -52,8 +62,6 @@ WRes CriticalSection_Init(CCriticalSection *p);
|
|||||||
#define CriticalSection_Enter(p) EnterCriticalSection(p)
|
#define CriticalSection_Enter(p) EnterCriticalSection(p)
|
||||||
#define CriticalSection_Leave(p) LeaveCriticalSection(p)
|
#define CriticalSection_Leave(p) LeaveCriticalSection(p)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EXTERN_C_END
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
47
C/Util/7z/7z.dsp
Executable file → Normal file
47
C/Util/7z/7z.dsp
Executable file → Normal file
@@ -42,7 +42,7 @@ RSC=rc.exe
|
|||||||
# PROP Ignore_Export_Lib 0
|
# PROP Ignore_Export_Lib 0
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FAs /YX /FD /c
|
# ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FAs /Yu"Precomp.h" /FD /c
|
||||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||||
BSC32=bscmake.exe
|
BSC32=bscmake.exe
|
||||||
@@ -50,7 +50,7 @@ BSC32=bscmake.exe
|
|||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"Release/7zDec.exe" /opt:NOWIN98
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\util\7zDec.exe" /opt:NOWIN98
|
||||||
# SUBTRACT LINK32 /pdb:none
|
# SUBTRACT LINK32 /pdb:none
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "7z - Win32 Debug"
|
!ELSEIF "$(CFG)" == "7z - Win32 Debug"
|
||||||
@@ -67,7 +67,7 @@ LINK32=link.exe
|
|||||||
# PROP Ignore_Export_Lib 0
|
# PROP Ignore_Export_Lib 0
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||||
# ADD CPP /nologo /W4 /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /YX /FD /GZ /c
|
# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c
|
||||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||||
BSC32=bscmake.exe
|
BSC32=bscmake.exe
|
||||||
@@ -75,7 +75,7 @@ BSC32=bscmake.exe
|
|||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug/7zDec.exe" /pdbtype:sept
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\util\7zDec.exe" /pdbtype:sept
|
||||||
|
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
||||||
@@ -92,6 +92,18 @@ SOURCE=..\..\7z.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\7zAlloc.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\7zAlloc.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\7zArcIn.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\7zBuf.c
|
SOURCE=..\..\7zBuf.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -125,11 +137,11 @@ SOURCE=..\..\7zFile.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\7zIn.c
|
SOURCE=..\..\7zStream.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\7zStream.c
|
SOURCE=..\..\7zTypes.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
@@ -141,6 +153,10 @@ SOURCE=..\..\Bcj2.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\Bra.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\Bra.h
|
SOURCE=..\..\Bra.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -178,7 +194,6 @@ SOURCE=..\..\Ppmd.h
|
|||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\Ppmd7.c
|
SOURCE=..\..\Ppmd7.c
|
||||||
# SUBTRACT CPP /YX
|
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
@@ -187,23 +202,27 @@ SOURCE=..\..\Ppmd7.h
|
|||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\Ppmd7Dec.c
|
SOURCE=..\..\Ppmd7Dec.c
|
||||||
# SUBTRACT CPP /YX
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Types.h
|
|
||||||
# End Source File
|
# End Source File
|
||||||
# End Group
|
# End Group
|
||||||
|
# Begin Group "Spec"
|
||||||
|
|
||||||
|
# PROP Default_Filter ""
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\7zAlloc.c
|
SOURCE=..\..\Compiler.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\7zAlloc.h
|
SOURCE=.\Precomp.c
|
||||||
|
# ADD CPP /Yc"Precomp.h"
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\Precomp.h
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\7zMain.c
|
SOURCE=.\7zMain.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# End Target
|
# End Target
|
||||||
|
|||||||
0
C/Util/7z/7z.dsw
Executable file → Normal file
0
C/Util/7z/7z.dsw
Executable file → Normal file
177
C/Util/7z/7zMain.c
Executable file → Normal file
177
C/Util/7z/7zMain.c
Executable file → Normal file
@@ -1,16 +1,18 @@
|
|||||||
/* 7zMain.c - Test application for 7z Decoder
|
/* 7zMain.c - Test application for 7z Decoder
|
||||||
2010-03-12 : Igor Pavlov : Public domain */
|
2014-06-17 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../../7z.h"
|
#include "../../7z.h"
|
||||||
|
#include "../../7zAlloc.h"
|
||||||
|
#include "../../7zBuf.h"
|
||||||
#include "../../7zCrc.h"
|
#include "../../7zCrc.h"
|
||||||
#include "../../7zFile.h"
|
#include "../../7zFile.h"
|
||||||
#include "../../7zVersion.h"
|
#include "../../7zVersion.h"
|
||||||
|
|
||||||
#include "7zAlloc.h"
|
|
||||||
|
|
||||||
#ifndef USE_WINDOWS_FILE
|
#ifndef USE_WINDOWS_FILE
|
||||||
/* for mkdir */
|
/* for mkdir */
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -21,12 +23,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define CHAR_PATH_SEPARATOR '\\'
|
|
||||||
#else
|
|
||||||
#define CHAR_PATH_SEPARATOR '/'
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static ISzAlloc g_Alloc = { SzAlloc, SzFree };
|
static ISzAlloc g_Alloc = { SzAlloc, SzFree };
|
||||||
|
|
||||||
static int Buf_EnsureSize(CBuf *dest, size_t size)
|
static int Buf_EnsureSize(CBuf *dest, size_t size)
|
||||||
@@ -102,35 +98,52 @@ static SRes Utf16_To_Utf8Buf(CBuf *dest, const UInt16 *src, size_t srcLen)
|
|||||||
dest->data[destLen] = 0;
|
dest->data[destLen] = 0;
|
||||||
return res ? SZ_OK : SZ_ERROR_FAIL;
|
return res ? SZ_OK : SZ_ERROR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static WRes Utf16_To_Char(CBuf *buf, const UInt16 *s, int fileMode)
|
static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s
|
||||||
|
#ifdef _WIN32
|
||||||
|
, UINT codePage
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
int len = 0;
|
unsigned len = 0;
|
||||||
for (len = 0; s[len] != '\0'; len++);
|
for (len = 0; s[len] != 0; len++);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
{
|
{
|
||||||
int size = len * 3 + 100;
|
unsigned size = len * 3 + 100;
|
||||||
if (!Buf_EnsureSize(buf, size))
|
if (!Buf_EnsureSize(buf, size))
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
{
|
{
|
||||||
char defaultChar = '_';
|
buf->data[0] = 0;
|
||||||
BOOL defUsed;
|
if (len != 0)
|
||||||
int numChars = WideCharToMultiByte(fileMode ? (AreFileApisANSI() ? CP_ACP : CP_OEMCP) : CP_OEMCP,
|
{
|
||||||
0, s, len, (char *)buf->data, size, &defaultChar, &defUsed);
|
char defaultChar = '_';
|
||||||
if (numChars == 0 || numChars >= size)
|
BOOL defUsed;
|
||||||
return SZ_ERROR_FAIL;
|
unsigned numChars = 0;
|
||||||
buf->data[numChars] = 0;
|
numChars = WideCharToMultiByte(codePage, 0, s, len, (char *)buf->data, size, &defaultChar, &defUsed);
|
||||||
|
if (numChars == 0 || numChars >= size)
|
||||||
|
return SZ_ERROR_FAIL;
|
||||||
|
buf->data[numChars] = 0;
|
||||||
|
}
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fileMode = fileMode;
|
|
||||||
return Utf16_To_Utf8Buf(buf, s, len);
|
return Utf16_To_Utf8Buf(buf, s, len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifndef USE_WINDOWS_FILE
|
||||||
|
static UINT g_FileCodePage = CP_ACP;
|
||||||
|
#endif
|
||||||
|
#define MY_FILE_CODE_PAGE_PARAM ,g_FileCodePage
|
||||||
|
#else
|
||||||
|
#define MY_FILE_CODE_PAGE_PARAM
|
||||||
|
#endif
|
||||||
|
|
||||||
static WRes MyCreateDir(const UInt16 *name)
|
static WRes MyCreateDir(const UInt16 *name)
|
||||||
{
|
{
|
||||||
#ifdef USE_WINDOWS_FILE
|
#ifdef USE_WINDOWS_FILE
|
||||||
@@ -142,7 +155,7 @@ static WRes MyCreateDir(const UInt16 *name)
|
|||||||
CBuf buf;
|
CBuf buf;
|
||||||
WRes res;
|
WRes res;
|
||||||
Buf_Init(&buf);
|
Buf_Init(&buf);
|
||||||
RINOK(Utf16_To_Char(&buf, name, 1));
|
RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM));
|
||||||
|
|
||||||
res =
|
res =
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -165,22 +178,27 @@ static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name)
|
|||||||
CBuf buf;
|
CBuf buf;
|
||||||
WRes res;
|
WRes res;
|
||||||
Buf_Init(&buf);
|
Buf_Init(&buf);
|
||||||
RINOK(Utf16_To_Char(&buf, name, 1));
|
RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM));
|
||||||
res = OutFile_Open(p, (const char *)buf.data);
|
res = OutFile_Open(p, (const char *)buf.data);
|
||||||
Buf_Free(&buf, &g_Alloc);
|
Buf_Free(&buf, &g_Alloc);
|
||||||
return res;
|
return res;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintString(const UInt16 *s)
|
static SRes PrintString(const UInt16 *s)
|
||||||
{
|
{
|
||||||
CBuf buf;
|
CBuf buf;
|
||||||
|
SRes res;
|
||||||
Buf_Init(&buf);
|
Buf_Init(&buf);
|
||||||
if (Utf16_To_Char(&buf, s, 0) == 0)
|
res = Utf16_To_Char(&buf, s
|
||||||
{
|
#ifdef _WIN32
|
||||||
printf("%s", buf.data);
|
, CP_OEMCP
|
||||||
Buf_Free(&buf, &g_Alloc);
|
#endif
|
||||||
}
|
);
|
||||||
|
if (res == SZ_OK)
|
||||||
|
fputs((const char *)buf.data, stdout);
|
||||||
|
Buf_Free(&buf, &g_Alloc);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UInt64ToStr(UInt64 value, char *s)
|
static void UInt64ToStr(UInt64 value, char *s)
|
||||||
@@ -215,17 +233,24 @@ static char *UIntToStr(char *s, unsigned value, int numDigits)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void UIntToStr_2(char *s, unsigned value)
|
||||||
|
{
|
||||||
|
s[0] = (char)('0' + (value / 10));
|
||||||
|
s[1] = (char)('0' + (value % 10));
|
||||||
|
}
|
||||||
|
|
||||||
#define PERIOD_4 (4 * 365 + 1)
|
#define PERIOD_4 (4 * 365 + 1)
|
||||||
#define PERIOD_100 (PERIOD_4 * 25 - 1)
|
#define PERIOD_100 (PERIOD_4 * 25 - 1)
|
||||||
#define PERIOD_400 (PERIOD_100 * 4 + 1)
|
#define PERIOD_400 (PERIOD_100 * 4 + 1)
|
||||||
|
|
||||||
static void ConvertFileTimeToString(const CNtfsFileTime *ft, char *s)
|
static void ConvertFileTimeToString(const CNtfsFileTime *nt, char *s)
|
||||||
{
|
{
|
||||||
unsigned year, mon, day, hour, min, sec;
|
unsigned year, mon, hour, min, sec;
|
||||||
UInt64 v64 = (ft->Low | ((UInt64)ft->High << 32)) / 10000000;
|
|
||||||
Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||||
unsigned t;
|
unsigned t;
|
||||||
UInt32 v;
|
UInt32 v;
|
||||||
|
UInt64 v64 = nt->Low | ((UInt64)nt->High << 32);
|
||||||
|
v64 /= 10000000;
|
||||||
sec = (unsigned)(v64 % 60); v64 /= 60;
|
sec = (unsigned)(v64 % 60); v64 /= 60;
|
||||||
min = (unsigned)(v64 % 60); v64 /= 60;
|
min = (unsigned)(v64 % 60); v64 /= 60;
|
||||||
hour = (unsigned)(v64 % 24); v64 /= 24;
|
hour = (unsigned)(v64 % 24); v64 /= 24;
|
||||||
@@ -241,20 +266,19 @@ static void ConvertFileTimeToString(const CNtfsFileTime *ft, char *s)
|
|||||||
|
|
||||||
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
|
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
|
||||||
ms[1] = 29;
|
ms[1] = 29;
|
||||||
for (mon = 1; mon <= 12; mon++)
|
for (mon = 0;; mon++)
|
||||||
{
|
{
|
||||||
unsigned s = ms[mon - 1];
|
unsigned s = ms[mon];
|
||||||
if (v < s)
|
if (v < s)
|
||||||
break;
|
break;
|
||||||
v -= s;
|
v -= s;
|
||||||
}
|
}
|
||||||
day = (unsigned)v + 1;
|
|
||||||
s = UIntToStr(s, year, 4); *s++ = '-';
|
s = UIntToStr(s, year, 4); *s++ = '-';
|
||||||
s = UIntToStr(s, mon, 2); *s++ = '-';
|
UIntToStr_2(s, mon + 1); s[2] = '-'; s += 3;
|
||||||
s = UIntToStr(s, day, 2); *s++ = ' ';
|
UIntToStr_2(s, (unsigned)v + 1); s[2] = ' '; s += 3;
|
||||||
s = UIntToStr(s, hour, 2); *s++ = ':';
|
UIntToStr_2(s, hour); s[2] = ':'; s += 3;
|
||||||
s = UIntToStr(s, min, 2); *s++ = ':';
|
UIntToStr_2(s, min); s[2] = ':'; s += 3;
|
||||||
s = UIntToStr(s, sec, 2);
|
UIntToStr_2(s, sec); s[2] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintError(char *sz)
|
void PrintError(char *sz)
|
||||||
@@ -263,14 +287,13 @@ void PrintError(char *sz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
#ifdef USE_WINDOWS_FILE
|
||||||
#define kEmptyAttribChar '.'
|
|
||||||
static void GetAttribString(UInt32 wa, Bool isDir, char *s)
|
static void GetAttribString(UInt32 wa, Bool isDir, char *s)
|
||||||
{
|
{
|
||||||
s[0] = (char)(((wa & FILE_ATTRIBUTE_DIRECTORY) != 0 || isDir) ? 'D' : kEmptyAttribChar);
|
s[0] = (char)(((wa & FILE_ATTRIBUTE_DIRECTORY) != 0 || isDir) ? 'D' : '.');
|
||||||
s[1] = (char)(((wa & FILE_ATTRIBUTE_READONLY) != 0) ? 'R': kEmptyAttribChar);
|
s[1] = (char)(((wa & FILE_ATTRIBUTE_READONLY ) != 0) ? 'R': '.');
|
||||||
s[2] = (char)(((wa & FILE_ATTRIBUTE_HIDDEN) != 0) ? 'H': kEmptyAttribChar);
|
s[2] = (char)(((wa & FILE_ATTRIBUTE_HIDDEN ) != 0) ? 'H': '.');
|
||||||
s[3] = (char)(((wa & FILE_ATTRIBUTE_SYSTEM) != 0) ? 'S': kEmptyAttribChar);
|
s[3] = (char)(((wa & FILE_ATTRIBUTE_SYSTEM ) != 0) ? 'S': '.');
|
||||||
s[4] = (char)(((wa & FILE_ATTRIBUTE_ARCHIVE) != 0) ? 'A': kEmptyAttribChar);
|
s[4] = (char)(((wa & FILE_ATTRIBUTE_ARCHIVE ) != 0) ? 'A': '.');
|
||||||
s[5] = '\0';
|
s[5] = '\0';
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -280,6 +303,8 @@ static void GetAttribString(UInt32, Bool, char *s)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// #define NUM_PARENTS_MAX 128
|
||||||
|
|
||||||
int MY_CDECL main(int numargs, char *args[])
|
int MY_CDECL main(int numargs, char *args[])
|
||||||
{
|
{
|
||||||
CFileInStream archiveStream;
|
CFileInStream archiveStream;
|
||||||
@@ -290,6 +315,7 @@ int MY_CDECL main(int numargs, char *args[])
|
|||||||
ISzAlloc allocTempImp;
|
ISzAlloc allocTempImp;
|
||||||
UInt16 *temp = NULL;
|
UInt16 *temp = NULL;
|
||||||
size_t tempSize = 0;
|
size_t tempSize = 0;
|
||||||
|
// UInt32 parents[NUM_PARENTS_MAX];
|
||||||
|
|
||||||
printf("\n7z ANSI-C Decoder " MY_VERSION_COPYRIGHT_DATE "\n\n");
|
printf("\n7z ANSI-C Decoder " MY_VERSION_COPYRIGHT_DATE "\n\n");
|
||||||
if (numargs == 1)
|
if (numargs == 1)
|
||||||
@@ -309,13 +335,21 @@ int MY_CDECL main(int numargs, char *args[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(USE_WINDOWS_FILE) && !defined(UNDER_CE)
|
||||||
|
g_FileCodePage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||||
|
#endif
|
||||||
|
|
||||||
allocImp.Alloc = SzAlloc;
|
allocImp.Alloc = SzAlloc;
|
||||||
allocImp.Free = SzFree;
|
allocImp.Free = SzFree;
|
||||||
|
|
||||||
allocTempImp.Alloc = SzAllocTemp;
|
allocTempImp.Alloc = SzAllocTemp;
|
||||||
allocTempImp.Free = SzFreeTemp;
|
allocTempImp.Free = SzFreeTemp;
|
||||||
|
|
||||||
|
#ifdef UNDER_CE
|
||||||
|
if (InFile_OpenW(&archiveStream.file, L"\test.7z"))
|
||||||
|
#else
|
||||||
if (InFile_Open(&archiveStream.file, args[2]))
|
if (InFile_Open(&archiveStream.file, args[2]))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
PrintError("can not open input file");
|
PrintError("can not open input file");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -357,22 +391,24 @@ int MY_CDECL main(int numargs, char *args[])
|
|||||||
Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
|
Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
|
||||||
size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */
|
size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */
|
||||||
|
|
||||||
for (i = 0; i < db.db.NumFiles; i++)
|
for (i = 0; i < db.NumFiles; i++)
|
||||||
{
|
{
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
size_t outSizeProcessed = 0;
|
size_t outSizeProcessed = 0;
|
||||||
const CSzFileItem *f = db.db.Files + i;
|
// const CSzFileItem *f = db.Files + i;
|
||||||
size_t len;
|
size_t len;
|
||||||
if (listCommand == 0 && f->IsDir && !fullPaths)
|
int isDir = SzArEx_IsDir(&db, i);
|
||||||
|
if (listCommand == 0 && isDir && !fullPaths)
|
||||||
continue;
|
continue;
|
||||||
len = SzArEx_GetFileNameUtf16(&db, i, NULL);
|
len = SzArEx_GetFileNameUtf16(&db, i, NULL);
|
||||||
|
// len = SzArEx_GetFullNameLen(&db, i);
|
||||||
|
|
||||||
if (len > tempSize)
|
if (len > tempSize)
|
||||||
{
|
{
|
||||||
SzFree(NULL, temp);
|
SzFree(NULL, temp);
|
||||||
tempSize = len;
|
tempSize = len;
|
||||||
temp = (UInt16 *)SzAlloc(NULL, tempSize * sizeof(temp[0]));
|
temp = (UInt16 *)SzAlloc(NULL, tempSize * sizeof(temp[0]));
|
||||||
if (temp == 0)
|
if (!temp)
|
||||||
{
|
{
|
||||||
res = SZ_ERROR_MEM;
|
res = SZ_ERROR_MEM;
|
||||||
break;
|
break;
|
||||||
@@ -380,15 +416,25 @@ int MY_CDECL main(int numargs, char *args[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
SzArEx_GetFileNameUtf16(&db, i, temp);
|
SzArEx_GetFileNameUtf16(&db, i, temp);
|
||||||
|
/*
|
||||||
|
if (SzArEx_GetFullNameUtf16_Back(&db, i, temp + len) != temp)
|
||||||
|
{
|
||||||
|
res = SZ_ERROR_FAIL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (listCommand)
|
if (listCommand)
|
||||||
{
|
{
|
||||||
char attr[8], s[32], t[32];
|
char attr[8], s[32], t[32];
|
||||||
|
UInt64 fileSize;
|
||||||
|
|
||||||
GetAttribString(f->AttribDefined ? f->Attrib : 0, f->IsDir, attr);
|
GetAttribString(SzBitWithVals_Check(&db.Attribs, i) ? db.Attribs.Vals[i] : 0, isDir, attr);
|
||||||
|
|
||||||
UInt64ToStr(f->Size, s);
|
fileSize = SzArEx_GetFileSize(&db, i);
|
||||||
if (f->MTimeDefined)
|
UInt64ToStr(fileSize, s);
|
||||||
ConvertFileTimeToString(&f->MTime, t);
|
if (SzBitWithVals_Check(&db.MTime, i))
|
||||||
|
ConvertFileTimeToString(&db.MTime.Vals[i], t);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t j;
|
size_t j;
|
||||||
@@ -398,17 +444,22 @@ int MY_CDECL main(int numargs, char *args[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("%s %s %10s ", t, attr, s);
|
printf("%s %s %10s ", t, attr, s);
|
||||||
PrintString(temp);
|
res = PrintString(temp);
|
||||||
if (f->IsDir)
|
if (res != SZ_OK)
|
||||||
|
break;
|
||||||
|
if (isDir)
|
||||||
printf("/");
|
printf("/");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
printf(testCommand ?
|
fputs(testCommand ?
|
||||||
"Testing ":
|
"Testing ":
|
||||||
"Extracting ");
|
"Extracting ",
|
||||||
PrintString(temp);
|
stdout);
|
||||||
if (f->IsDir)
|
res = PrintString(temp);
|
||||||
|
if (res != SZ_OK)
|
||||||
|
break;
|
||||||
|
if (isDir)
|
||||||
printf("/");
|
printf("/");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -439,7 +490,7 @@ int MY_CDECL main(int numargs, char *args[])
|
|||||||
destPath = name + j + 1;
|
destPath = name + j + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f->IsDir)
|
if (isDir)
|
||||||
{
|
{
|
||||||
MyCreateDir(destPath);
|
MyCreateDir(destPath);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -465,8 +516,8 @@ int MY_CDECL main(int numargs, char *args[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef USE_WINDOWS_FILE
|
#ifdef USE_WINDOWS_FILE
|
||||||
if (f->AttribDefined)
|
if (SzBitWithVals_Check(&db.Attribs, i))
|
||||||
SetFileAttributesW(destPath, f->Attrib);
|
SetFileAttributesW(destPath, db.Attribs.Vals[i]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|||||||
4
C/Util/7z/Precomp.c
Normal file
4
C/Util/7z/Precomp.c
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/* Precomp.c -- StdAfx
|
||||||
|
2013-01-21 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
10
C/Util/7z/Precomp.h
Normal file
10
C/Util/7z/Precomp.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/* Precomp.h -- StdAfx
|
||||||
|
2013-06-16 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __7Z_PRECOMP_H
|
||||||
|
#define __7Z_PRECOMP_H
|
||||||
|
|
||||||
|
#include "../../Compiler.h"
|
||||||
|
#include "../../7zTypes.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
15
C/Util/7z/makefile
Executable file → Normal file
15
C/Util/7z/makefile
Executable file → Normal file
@@ -1,18 +1,19 @@
|
|||||||
MY_STATIC_LINK=1
|
# MY_STATIC_LINK=1
|
||||||
CFLAGS = $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT
|
CFLAGS = $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT
|
||||||
|
|
||||||
PROG = 7zDec.exe
|
PROG = 7zDec.exe
|
||||||
|
|
||||||
C_OBJS = \
|
C_OBJS = \
|
||||||
|
$O\7zAlloc.obj \
|
||||||
$O\7zBuf.obj \
|
$O\7zBuf.obj \
|
||||||
$O\7zBuf2.obj \
|
|
||||||
$O\7zCrc.obj \
|
$O\7zCrc.obj \
|
||||||
$O\7zCrcOpt.obj \
|
$O\7zCrcOpt.obj \
|
||||||
$O\7zFile.obj \
|
$O\7zFile.obj \
|
||||||
$O\7zDec.obj \
|
$O\7zDec.obj \
|
||||||
$O\7zIn.obj \
|
$O\7zArcIn.obj \
|
||||||
$O\7zStream.obj \
|
$O\7zStream.obj \
|
||||||
$O\Bcj2.obj \
|
$O\Bcj2.obj \
|
||||||
|
$O\Bra.obj \
|
||||||
$O\Bra86.obj \
|
$O\Bra86.obj \
|
||||||
$O\CpuArch.obj \
|
$O\CpuArch.obj \
|
||||||
$O\Lzma2Dec.obj \
|
$O\Lzma2Dec.obj \
|
||||||
@@ -21,16 +22,18 @@ C_OBJS = \
|
|||||||
$O\Ppmd7Dec.obj \
|
$O\Ppmd7Dec.obj \
|
||||||
|
|
||||||
7Z_OBJS = \
|
7Z_OBJS = \
|
||||||
$O\7zAlloc.obj \
|
|
||||||
$O\7zMain.obj \
|
$O\7zMain.obj \
|
||||||
|
|
||||||
OBJS = \
|
OBJS = \
|
||||||
|
$O\Precomp.obj \
|
||||||
$(7Z_OBJS) \
|
$(7Z_OBJS) \
|
||||||
$(C_OBJS) \
|
$(C_OBJS) \
|
||||||
|
|
||||||
!include "../../../CPP/Build.mak"
|
!include "../../../CPP/Build.mak"
|
||||||
|
|
||||||
$(7Z_OBJS): $(*B).c
|
$(7Z_OBJS): $(*B).c
|
||||||
$(COMPL_O1)
|
$(CCOMPL_USE)
|
||||||
$(C_OBJS): ../../$(*B).c
|
$(C_OBJS): ../../$(*B).c
|
||||||
$(COMPL_O2)
|
$(CCOMPL_USE)
|
||||||
|
$O\Precomp.obj: Precomp.c
|
||||||
|
$(CCOMPL_PCH)
|
||||||
|
|||||||
15
C/Util/7z/makefile.gcc
Executable file → Normal file
15
C/Util/7z/makefile.gcc
Executable file → Normal file
@@ -4,7 +4,7 @@ LIB =
|
|||||||
RM = rm -f
|
RM = rm -f
|
||||||
CFLAGS = -c -O2 -Wall
|
CFLAGS = -c -O2 -Wall
|
||||||
|
|
||||||
OBJS = 7zMain.o 7zAlloc.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zCrcOpt.o 7zDec.o 7zIn.o CpuArch.o LzmaDec.o Lzma2Dec.o Bra86.o Bcj2.o Ppmd7.o Ppmd7Dec.o 7zFile.o 7zStream.o
|
OBJS = 7zMain.o 7zAlloc.o 7zArcIn.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zCrcOpt.o 7zDec.o CpuArch.o LzmaDec.o Lzma2Dec.o Bra.o Bra86.o Bcj2.o Ppmd7.o Ppmd7Dec.o 7zFile.o 7zStream.o
|
||||||
|
|
||||||
all: $(PROG)
|
all: $(PROG)
|
||||||
|
|
||||||
@@ -14,8 +14,11 @@ $(PROG): $(OBJS)
|
|||||||
7zMain.o: 7zMain.c
|
7zMain.o: 7zMain.c
|
||||||
$(CXX) $(CFLAGS) 7zMain.c
|
$(CXX) $(CFLAGS) 7zMain.c
|
||||||
|
|
||||||
7zAlloc.o: 7zAlloc.c
|
7zAlloc.o: ../../7zAlloc.c
|
||||||
$(CXX) $(CFLAGS) 7zAlloc.c
|
$(CXX) $(CFLAGS) ../../7zAlloc.c
|
||||||
|
|
||||||
|
7zArcIn.o: ../../7zArcIn.c
|
||||||
|
$(CXX) $(CFLAGS) ../../7zArcIn.c
|
||||||
|
|
||||||
7zBuf.o: ../../7zBuf.c
|
7zBuf.o: ../../7zBuf.c
|
||||||
$(CXX) $(CFLAGS) ../../7zBuf.c
|
$(CXX) $(CFLAGS) ../../7zBuf.c
|
||||||
@@ -32,9 +35,6 @@ $(PROG): $(OBJS)
|
|||||||
7zDec.o: ../../7zDec.c
|
7zDec.o: ../../7zDec.c
|
||||||
$(CXX) $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT ../../7zDec.c
|
$(CXX) $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT ../../7zDec.c
|
||||||
|
|
||||||
7zIn.o: ../../7zIn.c
|
|
||||||
$(CXX) $(CFLAGS) ../../7zIn.c
|
|
||||||
|
|
||||||
CpuArch.o: ../../CpuArch.c
|
CpuArch.o: ../../CpuArch.c
|
||||||
$(CXX) $(CFLAGS) ../../CpuArch.c
|
$(CXX) $(CFLAGS) ../../CpuArch.c
|
||||||
|
|
||||||
@@ -44,6 +44,9 @@ LzmaDec.o: ../../LzmaDec.c
|
|||||||
Lzma2Dec.o: ../../Lzma2Dec.c
|
Lzma2Dec.o: ../../Lzma2Dec.c
|
||||||
$(CXX) $(CFLAGS) ../../Lzma2Dec.c
|
$(CXX) $(CFLAGS) ../../Lzma2Dec.c
|
||||||
|
|
||||||
|
Bra.o: ../../Bra.c
|
||||||
|
$(CXX) $(CFLAGS) ../../Bra.c
|
||||||
|
|
||||||
Bra86.o: ../../Bra86.c
|
Bra86.o: ../../Bra86.c
|
||||||
$(CXX) $(CFLAGS) ../../Bra86.c
|
$(CXX) $(CFLAGS) ../../Bra86.c
|
||||||
|
|
||||||
|
|||||||
6
C/Util/Lzma/LzmaUtil.c
Executable file → Normal file
6
C/Util/Lzma/LzmaUtil.c
Executable file → Normal file
@@ -1,7 +1,7 @@
|
|||||||
/* LzmaUtil.c -- Test application for LZMA compression
|
/* LzmaUtil.c -- Test application for LZMA compression
|
||||||
2009-08-14 : Igor Pavlov : Public domain */
|
2014-06-17 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#include "../../Precomp.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -249,6 +249,6 @@ int MY_CDECL main(int numArgs, const char *args[])
|
|||||||
{
|
{
|
||||||
char rs[800] = { 0 };
|
char rs[800] = { 0 };
|
||||||
int res = main2(numArgs, args, rs);
|
int res = main2(numArgs, args, rs);
|
||||||
printf(rs);
|
fputs(rs, stdout);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
4
C/Util/Lzma/LzmaUtil.dsp
Executable file → Normal file
4
C/Util/Lzma/LzmaUtil.dsp
Executable file → Normal file
@@ -42,7 +42,7 @@ RSC=rc.exe
|
|||||||
# PROP Ignore_Export_Lib 0
|
# PROP Ignore_Export_Lib 0
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||||
# ADD CPP /nologo /MT /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
|
# ADD CPP /nologo /MT /W4 /WX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
|
||||||
# SUBTRACT CPP /YX
|
# SUBTRACT CPP /YX
|
||||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||||
@@ -67,7 +67,7 @@ LINK32=link.exe
|
|||||||
# PROP Ignore_Export_Lib 0
|
# PROP Ignore_Export_Lib 0
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||||
# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
|
# ADD CPP /nologo /MTd /W4 /WX /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
|
||||||
# SUBTRACT CPP /YX
|
# SUBTRACT CPP /YX
|
||||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||||
|
|||||||
0
C/Util/Lzma/LzmaUtil.dsw
Executable file → Normal file
0
C/Util/Lzma/LzmaUtil.dsw
Executable file → Normal file
2
C/Util/Lzma/makefile
Executable file → Normal file
2
C/Util/Lzma/makefile
Executable file → Normal file
@@ -1,4 +1,4 @@
|
|||||||
MY_STATIC_LINK=1
|
# MY_STATIC_LINK=1
|
||||||
PROG = LZMAc.exe
|
PROG = LZMAc.exe
|
||||||
|
|
||||||
CFLAGS = $(CFLAGS) \
|
CFLAGS = $(CFLAGS) \
|
||||||
|
|||||||
0
C/Util/Lzma/makefile.gcc
Executable file → Normal file
0
C/Util/Lzma/makefile.gcc
Executable file → Normal file
0
C/Util/LzmaLib/LzmaLib.def
Executable file → Normal file
0
C/Util/LzmaLib/LzmaLib.def
Executable file → Normal file
8
C/Util/LzmaLib/LzmaLib.dsp
Executable file → Normal file
8
C/Util/LzmaLib/LzmaLib.dsp
Executable file → Normal file
@@ -104,6 +104,10 @@ SOURCE=.\LzmaLibExports.c
|
|||||||
# End Group
|
# End Group
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\7zTypes.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\Alloc.c
|
SOURCE=..\..\Alloc.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -170,9 +174,5 @@ SOURCE=..\..\Threads.c
|
|||||||
|
|
||||||
SOURCE=..\..\Threads.h
|
SOURCE=..\..\Threads.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Types.h
|
|
||||||
# End Source File
|
|
||||||
# End Target
|
# End Target
|
||||||
# End Project
|
# End Project
|
||||||
|
|||||||
0
C/Util/LzmaLib/LzmaLib.dsw
Executable file → Normal file
0
C/Util/LzmaLib/LzmaLib.dsw
Executable file → Normal file
0
C/Util/LzmaLib/LzmaLibExports.c
Executable file → Normal file
0
C/Util/LzmaLib/LzmaLibExports.c
Executable file → Normal file
0
C/Util/LzmaLib/makefile
Executable file → Normal file
0
C/Util/LzmaLib/makefile
Executable file → Normal file
3
C/Util/LzmaLib/resource.rc
Executable file → Normal file
3
C/Util/LzmaLib/resource.rc
Executable file → Normal file
@@ -1,4 +1,3 @@
|
|||||||
#include "../../../CPP/7zip/MyVersionInfo.rc"
|
#include "../../7zVersion.rc"
|
||||||
|
|
||||||
MY_VERSION_INFO_DLL("LZMA library", "LZMA")
|
MY_VERSION_INFO_DLL("LZMA library", "LZMA")
|
||||||
|
|
||||||
|
|||||||
4
C/Util/SfxSetup/Precomp.c
Normal file
4
C/Util/SfxSetup/Precomp.c
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/* Precomp.c -- StdAfx
|
||||||
|
2013-01-21 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
10
C/Util/SfxSetup/Precomp.h
Normal file
10
C/Util/SfxSetup/Precomp.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/* Precomp.h -- StdAfx
|
||||||
|
2013-06-16 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __7Z_PRECOMP_H
|
||||||
|
#define __7Z_PRECOMP_H
|
||||||
|
|
||||||
|
#include "../../Compiler.h"
|
||||||
|
#include "../../7zTypes.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user