mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-17 10:11:48 -06:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e75ad3d355 | ||
|
|
ff14e3badb | ||
|
|
5c10d25476 | ||
|
|
5d7485c7d9 | ||
|
|
758c3790d3 | ||
|
|
50a695679a | ||
|
|
04d04adea5 | ||
|
|
cb75c2b5bf | ||
|
|
5b2a99c548 | ||
|
|
f623539c73 | ||
|
|
c287fb0519 | ||
|
|
9b07a1847f | ||
|
|
cc9036aad9 | ||
|
|
42fa923138 | ||
|
|
b82b3e5533 | ||
|
|
20e38032e6 | ||
|
|
18dc2b4161 | ||
|
|
801aad2d7c | ||
|
|
f19b649c73 | ||
|
|
e3dc4878fe | ||
|
|
866a06f5a0 | ||
|
|
da28077952 | ||
|
|
b5dc853b24 |
18
.gitignore
vendored
Normal file
18
.gitignore
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
*.o
|
||||||
|
out/
|
||||||
|
7zAll/x64/
|
||||||
|
*.pdb
|
||||||
|
*.tlog
|
||||||
|
*.obj
|
||||||
|
*.user
|
||||||
|
*.log
|
||||||
|
*.pch
|
||||||
|
*.idb
|
||||||
|
x64/
|
||||||
|
*.exe
|
||||||
|
*.res
|
||||||
|
*.dll
|
||||||
|
*.lib
|
||||||
|
*.exp
|
||||||
|
*.sfx
|
||||||
|
*.txt
|
||||||
41
7zAll/7zAll.sln
Normal file
41
7zAll/7zAll.sln
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 15
|
||||||
|
VisualStudioVersion = 15.0.28010.2048
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "7zFM", "..\CPP\7zip\UI\FileManager\FM.vcxproj", "{2628FF64-E1E1-4CB7-B588-08DE7145B630}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "7zG", "..\CPP\7zip\UI\GUI\GUI.vcxproj", "{D4BC12CF-49F2-474D-BAF6-EAC069DB7D6C}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
DebugU|Win32 = DebugU|Win32
|
||||||
|
DebugU|x64 = DebugU|x64
|
||||||
|
ReleaseU|Win32 = ReleaseU|Win32
|
||||||
|
ReleaseU|x64 = ReleaseU|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{2628FF64-E1E1-4CB7-B588-08DE7145B630}.DebugU|Win32.ActiveCfg = DebugU|Win32
|
||||||
|
{2628FF64-E1E1-4CB7-B588-08DE7145B630}.DebugU|Win32.Build.0 = DebugU|Win32
|
||||||
|
{2628FF64-E1E1-4CB7-B588-08DE7145B630}.DebugU|x64.ActiveCfg = DebugU|x64
|
||||||
|
{2628FF64-E1E1-4CB7-B588-08DE7145B630}.DebugU|x64.Build.0 = DebugU|x64
|
||||||
|
{2628FF64-E1E1-4CB7-B588-08DE7145B630}.ReleaseU|Win32.ActiveCfg = ReleaseU|Win32
|
||||||
|
{2628FF64-E1E1-4CB7-B588-08DE7145B630}.ReleaseU|Win32.Build.0 = ReleaseU|Win32
|
||||||
|
{2628FF64-E1E1-4CB7-B588-08DE7145B630}.ReleaseU|x64.ActiveCfg = ReleaseU|x64
|
||||||
|
{2628FF64-E1E1-4CB7-B588-08DE7145B630}.ReleaseU|x64.Build.0 = ReleaseU|x64
|
||||||
|
{D4BC12CF-49F2-474D-BAF6-EAC069DB7D6C}.DebugU|Win32.ActiveCfg = DebugU|Win32
|
||||||
|
{D4BC12CF-49F2-474D-BAF6-EAC069DB7D6C}.DebugU|Win32.Build.0 = DebugU|Win32
|
||||||
|
{D4BC12CF-49F2-474D-BAF6-EAC069DB7D6C}.DebugU|x64.ActiveCfg = DebugU|x64
|
||||||
|
{D4BC12CF-49F2-474D-BAF6-EAC069DB7D6C}.DebugU|x64.Build.0 = DebugU|x64
|
||||||
|
{D4BC12CF-49F2-474D-BAF6-EAC069DB7D6C}.ReleaseU|Win32.ActiveCfg = ReleaseU|Win32
|
||||||
|
{D4BC12CF-49F2-474D-BAF6-EAC069DB7D6C}.ReleaseU|Win32.Build.0 = ReleaseU|Win32
|
||||||
|
{D4BC12CF-49F2-474D-BAF6-EAC069DB7D6C}.ReleaseU|x64.ActiveCfg = ReleaseU|x64
|
||||||
|
{D4BC12CF-49F2-474D-BAF6-EAC069DB7D6C}.ReleaseU|x64.Build.0 = ReleaseU|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {BF7D9E83-83E0-4B40-B356-AA6A664D563E}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
; 7zAsm.asm -- ASM macros
|
; 7zAsm.asm -- ASM macros
|
||||||
; 2012-12-30 : Igor Pavlov : Public domain
|
; 2018-02-03 : Igor Pavlov : Public domain
|
||||||
|
|
||||||
MY_ASM_START macro
|
MY_ASM_START macro
|
||||||
ifdef x64
|
ifdef x64
|
||||||
@@ -52,6 +52,15 @@ endif
|
|||||||
x6 equ ESI
|
x6 equ ESI
|
||||||
x7 equ EDI
|
x7 equ EDI
|
||||||
|
|
||||||
|
x0_W equ AX
|
||||||
|
x1_W equ CX
|
||||||
|
x2_W equ DX
|
||||||
|
x3_W equ BX
|
||||||
|
|
||||||
|
x5_W equ BP
|
||||||
|
x6_W equ SI
|
||||||
|
x7_W equ DI
|
||||||
|
|
||||||
x0_L equ AL
|
x0_L equ AL
|
||||||
x1_L equ CL
|
x1_L equ CL
|
||||||
x2_L equ DL
|
x2_L equ DL
|
||||||
@@ -63,6 +72,10 @@ endif
|
|||||||
x3_H equ BH
|
x3_H equ BH
|
||||||
|
|
||||||
ifdef x64
|
ifdef x64
|
||||||
|
x5_L equ BPL
|
||||||
|
x6_L equ SIL
|
||||||
|
x7_L equ DIL
|
||||||
|
|
||||||
r0 equ RAX
|
r0 equ RAX
|
||||||
r1 equ RCX
|
r1 equ RCX
|
||||||
r2 equ RDX
|
r2 equ RDX
|
||||||
@@ -103,3 +116,32 @@ MY_POP_4_REGS macro
|
|||||||
pop r5
|
pop r5
|
||||||
pop r3
|
pop r3
|
||||||
endm
|
endm
|
||||||
|
|
||||||
|
|
||||||
|
ifdef x64
|
||||||
|
|
||||||
|
; for WIN64-x64 ABI:
|
||||||
|
|
||||||
|
REG_PARAM_0 equ r1
|
||||||
|
REG_PARAM_1 equ r2
|
||||||
|
REG_PARAM_2 equ r8
|
||||||
|
REG_PARAM_3 equ r9
|
||||||
|
|
||||||
|
MY_PUSH_PRESERVED_REGS macro
|
||||||
|
MY_PUSH_4_REGS
|
||||||
|
push r12
|
||||||
|
push r13
|
||||||
|
push r14
|
||||||
|
push r15
|
||||||
|
endm
|
||||||
|
|
||||||
|
|
||||||
|
MY_POP_PRESERVED_REGS macro
|
||||||
|
pop r15
|
||||||
|
pop r14
|
||||||
|
pop r13
|
||||||
|
pop r12
|
||||||
|
MY_POP_4_REGS
|
||||||
|
endm
|
||||||
|
|
||||||
|
endif
|
||||||
|
|||||||
1258
Asm/x86/LzmaDecOpt.asm
Normal file
1258
Asm/x86/LzmaDecOpt.asm
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
/* 7zArcIn.c -- 7z Input functions
|
/* 7zArcIn.c -- 7z Input functions
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -1744,7 +1744,7 @@ size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex)
|
|||||||
|
|
||||||
UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest)
|
UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest)
|
||||||
{
|
{
|
||||||
Bool needSlash;
|
BoolInt needSlash;
|
||||||
if (!p->FileNameOffsets)
|
if (!p->FileNameOffsets)
|
||||||
{
|
{
|
||||||
*(--dest) = 0;
|
*(--dest) = 0;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* 7zCrc.c -- CRC32 init
|
/* 7zCrc.c -- CRC32 init
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2017-06-06 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -86,8 +86,8 @@ void MY_FAST_CALL CrcGenerateTable()
|
|||||||
|
|
||||||
#ifdef MY_CPU_X86_OR_AMD64
|
#ifdef MY_CPU_X86_OR_AMD64
|
||||||
if (!CPU_Is_InOrder())
|
if (!CPU_Is_InOrder())
|
||||||
g_CrcUpdate = CrcUpdateT8;
|
|
||||||
#endif
|
#endif
|
||||||
|
g_CrcUpdate = CrcUpdateT8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -101,7 +101,7 @@ void MY_FAST_CALL CrcGenerateTable()
|
|||||||
g_CrcUpdate = CrcUpdateT4;
|
g_CrcUpdate = CrcUpdateT4;
|
||||||
#if CRC_NUM_TABLES >= 8
|
#if CRC_NUM_TABLES >= 8
|
||||||
g_CrcUpdateT8 = CrcUpdateT8;
|
g_CrcUpdateT8 = CrcUpdateT8;
|
||||||
// g_CrcUpdate = CrcUpdateT8;
|
g_CrcUpdate = CrcUpdateT8;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (p[0] != 1 || p[1] != 2)
|
else if (p[0] != 1 || p[1] != 2)
|
||||||
@@ -118,7 +118,7 @@ void MY_FAST_CALL CrcGenerateTable()
|
|||||||
g_CrcUpdate = CrcUpdateT1_BeT4;
|
g_CrcUpdate = CrcUpdateT1_BeT4;
|
||||||
#if CRC_NUM_TABLES >= 8
|
#if CRC_NUM_TABLES >= 8
|
||||||
g_CrcUpdateT8 = CrcUpdateT1_BeT8;
|
g_CrcUpdateT8 = CrcUpdateT1_BeT8;
|
||||||
// g_CrcUpdate = CrcUpdateT1_BeT8;
|
g_CrcUpdate = CrcUpdateT1_BeT8;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* 7zDec.c -- Decoding from 7z folder
|
/* 7zDec.c -- Decoding from 7z folder
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ typedef struct
|
|||||||
const Byte *end;
|
const Byte *end;
|
||||||
const Byte *begin;
|
const Byte *begin;
|
||||||
UInt64 processed;
|
UInt64 processed;
|
||||||
Bool extra;
|
BoolInt extra;
|
||||||
SRes res;
|
SRes res;
|
||||||
const ILookInStream *inStream;
|
const ILookInStream *inStream;
|
||||||
} CByteInToLook;
|
} CByteInToLook;
|
||||||
@@ -269,7 +269,7 @@ static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer
|
|||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool IS_MAIN_METHOD(UInt32 m)
|
static BoolInt IS_MAIN_METHOD(UInt32 m)
|
||||||
{
|
{
|
||||||
switch (m)
|
switch (m)
|
||||||
{
|
{
|
||||||
@@ -286,7 +286,7 @@ static Bool IS_MAIN_METHOD(UInt32 m)
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool IS_SUPPORTED_CODER(const CSzCoderInfo *c)
|
static BoolInt IS_SUPPORTED_CODER(const CSzCoderInfo *c)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
c->NumStreams == 1
|
c->NumStreams == 1
|
||||||
|
|||||||
15
C/7zTypes.h
15
C/7zTypes.h
@@ -1,5 +1,5 @@
|
|||||||
/* 7zTypes.h -- Basic types
|
/* 7zTypes.h -- Basic types
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-08-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_TYPES_H
|
#ifndef __7Z_TYPES_H
|
||||||
#define __7Z_TYPES_H
|
#define __7Z_TYPES_H
|
||||||
@@ -42,13 +42,23 @@ EXTERN_C_BEGIN
|
|||||||
|
|
||||||
typedef int SRes;
|
typedef int SRes;
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
/* typedef DWORD WRes; */
|
/* typedef DWORD WRes; */
|
||||||
typedef unsigned WRes;
|
typedef unsigned WRes;
|
||||||
|
#define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
typedef int WRes;
|
typedef int WRes;
|
||||||
|
#define MY__FACILITY_WIN32 7
|
||||||
|
#define MY__FACILITY__WRes MY__FACILITY_WIN32
|
||||||
|
#define MY_SRes_HRESULT_FROM_WRes(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (MY__FACILITY__WRes << 16) | 0x80000000)))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef RINOK
|
#ifndef RINOK
|
||||||
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
|
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
|
||||||
#endif
|
#endif
|
||||||
@@ -93,7 +103,8 @@ typedef UInt32 SizeT;
|
|||||||
typedef size_t SizeT;
|
typedef size_t SizeT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int Bool;
|
typedef int BoolInt;
|
||||||
|
/* typedef BoolInt Bool; */
|
||||||
#define True 1
|
#define True 1
|
||||||
#define False 0
|
#define False 0
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#define MY_VER_MAJOR 17
|
#define MY_VER_MAJOR 19
|
||||||
#define MY_VER_MINOR 00
|
#define MY_VER_MINOR 00
|
||||||
#define MY_VER_BUILD 0
|
#define MY_VER_BUILD 0
|
||||||
#define MY_VERSION_NUMBERS "17.00 beta"
|
#define MY_VERSION_NUMBERS "19.00"
|
||||||
#define MY_VERSION MY_VERSION_NUMBERS
|
#define MY_VERSION MY_VERSION_NUMBERS
|
||||||
|
|
||||||
#ifdef MY_CPU_NAME
|
#ifdef MY_CPU_NAME
|
||||||
@@ -10,12 +10,12 @@
|
|||||||
#define MY_VERSION_CPU MY_VERSION
|
#define MY_VERSION_CPU MY_VERSION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MY_DATE "2017-04-29"
|
#define MY_DATE "2019-02-21"
|
||||||
#undef MY_COPYRIGHT
|
#undef MY_COPYRIGHT
|
||||||
#undef MY_VERSION_COPYRIGHT_DATE
|
#undef MY_VERSION_COPYRIGHT_DATE
|
||||||
#define MY_AUTHOR_NAME "Igor Pavlov"
|
#define MY_AUTHOR_NAME "Igor Pavlov"
|
||||||
#define MY_COPYRIGHT_PD "Igor Pavlov : Public domain"
|
#define MY_COPYRIGHT_PD "Igor Pavlov : Public domain"
|
||||||
#define MY_COPYRIGHT_CR "Copyright (c) 1999-2017 Igor Pavlov"
|
#define MY_COPYRIGHT_CR "Copyright (c) 1999-2018 Igor Pavlov"
|
||||||
|
|
||||||
#ifdef USE_COPYRIGHT_CR
|
#ifdef USE_COPYRIGHT_CR
|
||||||
#define MY_COPYRIGHT MY_COPYRIGHT_CR
|
#define MY_COPYRIGHT MY_COPYRIGHT_CR
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/* AesOpt.c -- Intel's AES
|
/* AesOpt.c -- Intel's AES
|
||||||
2013-11-12 : Igor Pavlov : Public domain */
|
2017-06-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
|
|
||||||
#ifdef MY_CPU_X86_OR_AMD64
|
#ifdef MY_CPU_X86_OR_AMD64
|
||||||
#if _MSC_VER >= 1500
|
#if (_MSC_VER > 1500) || (_MSC_FULL_VER >= 150030729)
|
||||||
#define USE_INTEL_AES
|
#define USE_INTEL_AES
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
391
C/Alloc.c
391
C/Alloc.c
@@ -1,8 +1,10 @@
|
|||||||
/* Alloc.c -- Memory allocation functions
|
/* Alloc.c -- Memory allocation functions
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-04-27 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -14,20 +16,127 @@
|
|||||||
|
|
||||||
/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
|
/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
int g_allocCount = 0;
|
int g_allocCount = 0;
|
||||||
int g_allocCountMid = 0;
|
int g_allocCountMid = 0;
|
||||||
int g_allocCountBig = 0;
|
int g_allocCountBig = 0;
|
||||||
|
|
||||||
|
|
||||||
|
#define CONVERT_INT_TO_STR(charType, tempSize) \
|
||||||
|
unsigned char temp[tempSize]; unsigned i = 0; \
|
||||||
|
while (val >= 10) { temp[i++] = (unsigned char)('0' + (unsigned)(val % 10)); val /= 10; } \
|
||||||
|
*s++ = (charType)('0' + (unsigned)val); \
|
||||||
|
while (i != 0) { i--; *s++ = temp[i]; } \
|
||||||
|
*s = 0;
|
||||||
|
|
||||||
|
static void ConvertUInt64ToString(UInt64 val, char *s)
|
||||||
|
{
|
||||||
|
CONVERT_INT_TO_STR(char, 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GET_HEX_CHAR(t) ((char)(((t < 10) ? ('0' + t) : ('A' + (t - 10)))))
|
||||||
|
|
||||||
|
static void ConvertUInt64ToHex(UInt64 val, char *s)
|
||||||
|
{
|
||||||
|
UInt64 v = val;
|
||||||
|
unsigned i;
|
||||||
|
for (i = 1;; i++)
|
||||||
|
{
|
||||||
|
v >>= 4;
|
||||||
|
if (v == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s[i] = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned t = (unsigned)(val & 0xF);
|
||||||
|
val >>= 4;
|
||||||
|
s[--i] = GET_HEX_CHAR(t);
|
||||||
|
}
|
||||||
|
while (i);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEBUG_OUT_STREAM stderr
|
||||||
|
|
||||||
|
static void Print(const char *s)
|
||||||
|
{
|
||||||
|
fputs(s, DEBUG_OUT_STREAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrintAligned(const char *s, size_t align)
|
||||||
|
{
|
||||||
|
size_t len = strlen(s);
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
fputc(' ', DEBUG_OUT_STREAM);
|
||||||
|
if (len >= align)
|
||||||
|
break;
|
||||||
|
++len;
|
||||||
|
}
|
||||||
|
Print(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrintLn()
|
||||||
|
{
|
||||||
|
Print("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrintHex(UInt64 v, size_t align)
|
||||||
|
{
|
||||||
|
char s[32];
|
||||||
|
ConvertUInt64ToHex(v, s);
|
||||||
|
PrintAligned(s, align);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrintDec(UInt64 v, size_t align)
|
||||||
|
{
|
||||||
|
char s[32];
|
||||||
|
ConvertUInt64ToString(v, s);
|
||||||
|
PrintAligned(s, align);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrintAddr(void *p)
|
||||||
|
{
|
||||||
|
PrintHex((UInt64)(size_t)(ptrdiff_t)p, 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define PRINT_ALLOC(name, cnt, size, ptr) \
|
||||||
|
Print(name " "); \
|
||||||
|
PrintDec(cnt++, 10); \
|
||||||
|
PrintHex(size, 10); \
|
||||||
|
PrintAddr(ptr); \
|
||||||
|
PrintLn();
|
||||||
|
|
||||||
|
#define PRINT_FREE(name, cnt, ptr) if (ptr) { \
|
||||||
|
Print(name " "); \
|
||||||
|
PrintDec(--cnt, 10); \
|
||||||
|
PrintAddr(ptr); \
|
||||||
|
PrintLn(); }
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define PRINT_ALLOC(name, cnt, size, ptr)
|
||||||
|
#define PRINT_FREE(name, cnt, ptr)
|
||||||
|
#define Print(s)
|
||||||
|
#define PrintLn()
|
||||||
|
#define PrintHex(v, align)
|
||||||
|
#define PrintDec(v, align)
|
||||||
|
#define PrintAddr(p)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *MyAlloc(size_t size)
|
void *MyAlloc(size_t size)
|
||||||
{
|
{
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return 0;
|
return NULL;
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
#ifdef _SZ_ALLOC_DEBUG
|
||||||
{
|
{
|
||||||
void *p = malloc(size);
|
void *p = malloc(size);
|
||||||
fprintf(stderr, "\nAlloc %10d bytes, count = %10d, addr = %8X", size, g_allocCount++, (unsigned)p);
|
PRINT_ALLOC("Alloc ", g_allocCount, size, p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -37,10 +146,8 @@ void *MyAlloc(size_t size)
|
|||||||
|
|
||||||
void MyFree(void *address)
|
void MyFree(void *address)
|
||||||
{
|
{
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
PRINT_FREE("Free ", g_allocCount, address);
|
||||||
if (address != 0)
|
|
||||||
fprintf(stderr, "\nFree; count = %10d, addr = %8X", --g_allocCount, (unsigned)address);
|
|
||||||
#endif
|
|
||||||
free(address);
|
free(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,20 +156,18 @@ void MyFree(void *address)
|
|||||||
void *MidAlloc(size_t size)
|
void *MidAlloc(size_t size)
|
||||||
{
|
{
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return 0;
|
return NULL;
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
|
||||||
fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++);
|
PRINT_ALLOC("Alloc-Mid", g_allocCountMid, size, NULL);
|
||||||
#endif
|
|
||||||
return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MidFree(void *address)
|
void MidFree(void *address)
|
||||||
{
|
{
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
PRINT_FREE("Free-Mid", g_allocCountMid, address);
|
||||||
if (address != 0)
|
|
||||||
fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);
|
if (!address)
|
||||||
#endif
|
|
||||||
if (address == 0)
|
|
||||||
return;
|
return;
|
||||||
VirtualFree(address, 0, MEM_RELEASE);
|
VirtualFree(address, 0, MEM_RELEASE);
|
||||||
}
|
}
|
||||||
@@ -79,10 +184,10 @@ typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
|
|||||||
void SetLargePageSize()
|
void SetLargePageSize()
|
||||||
{
|
{
|
||||||
#ifdef _7ZIP_LARGE_PAGES
|
#ifdef _7ZIP_LARGE_PAGES
|
||||||
SIZE_T size = 0;
|
SIZE_T size;
|
||||||
GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
|
GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
|
||||||
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
|
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
|
||||||
if (largePageMinimum == 0)
|
if (!largePageMinimum)
|
||||||
return;
|
return;
|
||||||
size = largePageMinimum();
|
size = largePageMinimum();
|
||||||
if (size == 0 || (size & (size - 1)) != 0)
|
if (size == 0 || (size & (size - 1)) != 0)
|
||||||
@@ -95,31 +200,36 @@ void SetLargePageSize()
|
|||||||
void *BigAlloc(size_t size)
|
void *BigAlloc(size_t size)
|
||||||
{
|
{
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return 0;
|
return NULL;
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
|
||||||
fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
|
PRINT_ALLOC("Alloc-Big", g_allocCountBig, size, NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _7ZIP_LARGE_PAGES
|
#ifdef _7ZIP_LARGE_PAGES
|
||||||
if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18))
|
|
||||||
{
|
{
|
||||||
void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
|
SIZE_T ps = g_LargePageSize;
|
||||||
MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
|
if (ps != 0 && ps <= (1 << 30) && size > (ps / 2))
|
||||||
if (res != 0)
|
{
|
||||||
return res;
|
size_t size2;
|
||||||
|
ps--;
|
||||||
|
size2 = (size + ps) & ~ps;
|
||||||
|
if (size2 >= size)
|
||||||
|
{
|
||||||
|
void *res = VirtualAlloc(NULL, size2, MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
|
||||||
|
if (res)
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
|
||||||
|
return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BigFree(void *address)
|
void BigFree(void *address)
|
||||||
{
|
{
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
PRINT_FREE("Free-Big", g_allocCountBig, address);
|
||||||
if (address != 0)
|
|
||||||
fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (address == 0)
|
if (!address)
|
||||||
return;
|
return;
|
||||||
VirtualFree(address, 0, MEM_RELEASE);
|
VirtualFree(address, 0, MEM_RELEASE);
|
||||||
}
|
}
|
||||||
@@ -129,8 +239,217 @@ void BigFree(void *address)
|
|||||||
|
|
||||||
static void *SzAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
|
static void *SzAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }
|
||||||
static void SzFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); MyFree(address); }
|
static void SzFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); MyFree(address); }
|
||||||
ISzAlloc const g_Alloc = { SzAlloc, SzFree };
|
const ISzAlloc g_Alloc = { SzAlloc, SzFree };
|
||||||
|
|
||||||
|
static void *SzMidAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return MidAlloc(size); }
|
||||||
|
static void SzMidFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); MidFree(address); }
|
||||||
|
const ISzAlloc g_MidAlloc = { SzMidAlloc, SzMidFree };
|
||||||
|
|
||||||
static void *SzBigAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return BigAlloc(size); }
|
static void *SzBigAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return BigAlloc(size); }
|
||||||
static void SzBigFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); BigFree(address); }
|
static void SzBigFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); BigFree(address); }
|
||||||
ISzAlloc const g_BigAlloc = { SzBigAlloc, SzBigFree };
|
const ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree };
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
uintptr_t : <stdint.h> C99 (optional)
|
||||||
|
: unsupported in VS6
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
typedef UINT_PTR UIntPtr;
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
typedef uintptr_t UIntPtr;
|
||||||
|
*/
|
||||||
|
typedef ptrdiff_t UIntPtr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define ADJUST_ALLOC_SIZE 0
|
||||||
|
/*
|
||||||
|
#define ADJUST_ALLOC_SIZE (sizeof(void *) - 1)
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
Use (ADJUST_ALLOC_SIZE = (sizeof(void *) - 1)), if
|
||||||
|
MyAlloc() can return address that is NOT multiple of sizeof(void *).
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((char *)(p) - ((size_t)(UIntPtr)(p) & ((align) - 1))))
|
||||||
|
*/
|
||||||
|
#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((((UIntPtr)(p)) & ~((UIntPtr)(align) - 1))))
|
||||||
|
|
||||||
|
#define MY_ALIGN_PTR_UP_PLUS(p, align) MY_ALIGN_PTR_DOWN(((char *)(p) + (align) + ADJUST_ALLOC_SIZE), align)
|
||||||
|
|
||||||
|
|
||||||
|
#if (_POSIX_C_SOURCE >= 200112L) && !defined(_WIN32)
|
||||||
|
#define USE_posix_memalign
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
This posix_memalign() is for test purposes only.
|
||||||
|
We also need special Free() function instead of free(),
|
||||||
|
if this posix_memalign() is used.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
static int posix_memalign(void **ptr, size_t align, size_t size)
|
||||||
|
{
|
||||||
|
size_t newSize = size + align;
|
||||||
|
void *p;
|
||||||
|
void *pAligned;
|
||||||
|
*ptr = NULL;
|
||||||
|
if (newSize < size)
|
||||||
|
return 12; // ENOMEM
|
||||||
|
p = MyAlloc(newSize);
|
||||||
|
if (!p)
|
||||||
|
return 12; // ENOMEM
|
||||||
|
pAligned = MY_ALIGN_PTR_UP_PLUS(p, align);
|
||||||
|
((void **)pAligned)[-1] = p;
|
||||||
|
*ptr = pAligned;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
ALLOC_ALIGN_SIZE >= sizeof(void *)
|
||||||
|
ALLOC_ALIGN_SIZE >= cache_line_size
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ALLOC_ALIGN_SIZE ((size_t)1 << 7)
|
||||||
|
|
||||||
|
static void *SzAlignedAlloc(ISzAllocPtr pp, size_t size)
|
||||||
|
{
|
||||||
|
#ifndef USE_posix_memalign
|
||||||
|
|
||||||
|
void *p;
|
||||||
|
void *pAligned;
|
||||||
|
size_t newSize;
|
||||||
|
UNUSED_VAR(pp);
|
||||||
|
|
||||||
|
/* also we can allocate additional dummy ALLOC_ALIGN_SIZE bytes after aligned
|
||||||
|
block to prevent cache line sharing with another allocated blocks */
|
||||||
|
|
||||||
|
newSize = size + ALLOC_ALIGN_SIZE * 1 + ADJUST_ALLOC_SIZE;
|
||||||
|
if (newSize < size)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
p = MyAlloc(newSize);
|
||||||
|
|
||||||
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
pAligned = MY_ALIGN_PTR_UP_PLUS(p, ALLOC_ALIGN_SIZE);
|
||||||
|
|
||||||
|
Print(" size="); PrintHex(size, 8);
|
||||||
|
Print(" a_size="); PrintHex(newSize, 8);
|
||||||
|
Print(" ptr="); PrintAddr(p);
|
||||||
|
Print(" a_ptr="); PrintAddr(pAligned);
|
||||||
|
PrintLn();
|
||||||
|
|
||||||
|
((void **)pAligned)[-1] = p;
|
||||||
|
|
||||||
|
return pAligned;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void *p;
|
||||||
|
UNUSED_VAR(pp);
|
||||||
|
if (posix_memalign(&p, ALLOC_ALIGN_SIZE, size))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Print(" posix_memalign="); PrintAddr(p);
|
||||||
|
PrintLn();
|
||||||
|
|
||||||
|
return p;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void SzAlignedFree(ISzAllocPtr pp, void *address)
|
||||||
|
{
|
||||||
|
UNUSED_VAR(pp);
|
||||||
|
#ifndef USE_posix_memalign
|
||||||
|
if (address)
|
||||||
|
MyFree(((void **)address)[-1]);
|
||||||
|
#else
|
||||||
|
free(address);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const ISzAlloc g_AlignedAlloc = { SzAlignedAlloc, SzAlignedFree };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define MY_ALIGN_PTR_DOWN_1(p) MY_ALIGN_PTR_DOWN(p, sizeof(void *))
|
||||||
|
|
||||||
|
/* we align ptr to support cases where CAlignOffsetAlloc::offset is not multiply of sizeof(void *) */
|
||||||
|
#define REAL_BLOCK_PTR_VAR(p) ((void **)MY_ALIGN_PTR_DOWN_1(p))[-1]
|
||||||
|
/*
|
||||||
|
#define REAL_BLOCK_PTR_VAR(p) ((void **)(p))[-1]
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void *AlignOffsetAlloc_Alloc(ISzAllocPtr pp, size_t size)
|
||||||
|
{
|
||||||
|
CAlignOffsetAlloc *p = CONTAINER_FROM_VTBL(pp, CAlignOffsetAlloc, vt);
|
||||||
|
void *adr;
|
||||||
|
void *pAligned;
|
||||||
|
size_t newSize;
|
||||||
|
size_t extra;
|
||||||
|
size_t alignSize = (size_t)1 << p->numAlignBits;
|
||||||
|
|
||||||
|
if (alignSize < sizeof(void *))
|
||||||
|
alignSize = sizeof(void *);
|
||||||
|
|
||||||
|
if (p->offset >= alignSize)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* also we can allocate additional dummy ALLOC_ALIGN_SIZE bytes after aligned
|
||||||
|
block to prevent cache line sharing with another allocated blocks */
|
||||||
|
extra = p->offset & (sizeof(void *) - 1);
|
||||||
|
newSize = size + alignSize + extra + ADJUST_ALLOC_SIZE;
|
||||||
|
if (newSize < size)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
adr = ISzAlloc_Alloc(p->baseAlloc, newSize);
|
||||||
|
|
||||||
|
if (!adr)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
pAligned = (char *)MY_ALIGN_PTR_DOWN((char *)adr +
|
||||||
|
alignSize - p->offset + extra + ADJUST_ALLOC_SIZE, alignSize) + p->offset;
|
||||||
|
|
||||||
|
PrintLn();
|
||||||
|
Print("- Aligned: ");
|
||||||
|
Print(" size="); PrintHex(size, 8);
|
||||||
|
Print(" a_size="); PrintHex(newSize, 8);
|
||||||
|
Print(" ptr="); PrintAddr(adr);
|
||||||
|
Print(" a_ptr="); PrintAddr(pAligned);
|
||||||
|
PrintLn();
|
||||||
|
|
||||||
|
REAL_BLOCK_PTR_VAR(pAligned) = adr;
|
||||||
|
|
||||||
|
return pAligned;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void AlignOffsetAlloc_Free(ISzAllocPtr pp, void *address)
|
||||||
|
{
|
||||||
|
if (address)
|
||||||
|
{
|
||||||
|
CAlignOffsetAlloc *p = CONTAINER_FROM_VTBL(pp, CAlignOffsetAlloc, vt);
|
||||||
|
PrintLn();
|
||||||
|
Print("- Aligned Free: ");
|
||||||
|
PrintLn();
|
||||||
|
ISzAlloc_Free(p->baseAlloc, REAL_BLOCK_PTR_VAR(address));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p)
|
||||||
|
{
|
||||||
|
p->vt.Alloc = AlignOffsetAlloc_Alloc;
|
||||||
|
p->vt.Free = AlignOffsetAlloc_Free;
|
||||||
|
}
|
||||||
|
|||||||
16
C/Alloc.h
16
C/Alloc.h
@@ -1,5 +1,5 @@
|
|||||||
/* Alloc.h -- Memory allocation functions
|
/* Alloc.h -- Memory allocation functions
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-02-19 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __COMMON_ALLOC_H
|
#ifndef __COMMON_ALLOC_H
|
||||||
#define __COMMON_ALLOC_H
|
#define __COMMON_ALLOC_H
|
||||||
@@ -31,6 +31,20 @@ void BigFree(void *address);
|
|||||||
|
|
||||||
extern const ISzAlloc g_Alloc;
|
extern const ISzAlloc g_Alloc;
|
||||||
extern const ISzAlloc g_BigAlloc;
|
extern const ISzAlloc g_BigAlloc;
|
||||||
|
extern const ISzAlloc g_MidAlloc;
|
||||||
|
extern const ISzAlloc g_AlignedAlloc;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ISzAlloc vt;
|
||||||
|
ISzAllocPtr baseAlloc;
|
||||||
|
unsigned numAlignBits; /* ((1 << numAlignBits) >= sizeof(void *)) */
|
||||||
|
size_t offset; /* (offset == (k * sizeof(void *)) && offset < (1 << numAlignBits) */
|
||||||
|
} CAlignOffsetAlloc;
|
||||||
|
|
||||||
|
void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p);
|
||||||
|
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
|
||||||
|
|||||||
10
C/Bcj2.c
10
C/Bcj2.c
@@ -1,5 +1,5 @@
|
|||||||
/* Bcj2.c -- BCJ2 Decoder (Converter for x86 code)
|
/* Bcj2.c -- BCJ2 Decoder (Converter for x86 code)
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-04-28 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -232,10 +232,10 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
|
|||||||
|
|
||||||
if (rem < 4)
|
if (rem < 4)
|
||||||
{
|
{
|
||||||
SizeT i;
|
p->temp[0] = (Byte)val; if (rem > 0) dest[0] = (Byte)val; val >>= 8;
|
||||||
SetUi32(p->temp, val);
|
p->temp[1] = (Byte)val; if (rem > 1) dest[1] = (Byte)val; val >>= 8;
|
||||||
for (i = 0; i < rem; i++)
|
p->temp[2] = (Byte)val; if (rem > 2) dest[2] = (Byte)val; val >>= 8;
|
||||||
dest[i] = p->temp[i];
|
p->temp[3] = (Byte)val;
|
||||||
p->dest = dest + rem;
|
p->dest = dest + rem;
|
||||||
p->state = BCJ2_DEC_STATE_ORIG_0 + (unsigned)rem;
|
p->state = BCJ2_DEC_STATE_ORIG_0 + (unsigned)rem;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Bcj2Enc.c -- BCJ2 Encoder (Converter for x86 code)
|
/* Bcj2Enc.c -- BCJ2 Encoder (Converter for x86 code)
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2019-02-02 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
#define PRF(x)
|
#define PRF(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "Bcj2.h"
|
#include "Bcj2.h"
|
||||||
@@ -53,7 +52,7 @@ void Bcj2Enc_Init(CBcj2Enc *p)
|
|||||||
p->probs[i] = kBitModelTotal >> 1;
|
p->probs[i] = kBitModelTotal >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool MY_FAST_CALL RangeEnc_ShiftLow(CBcj2Enc *p)
|
static BoolInt MY_FAST_CALL RangeEnc_ShiftLow(CBcj2Enc *p)
|
||||||
{
|
{
|
||||||
if ((UInt32)p->low < (UInt32)0xFF000000 || (UInt32)(p->low >> 32) != 0)
|
if ((UInt32)p->low < (UInt32)0xFF000000 || (UInt32)(p->low >> 32) != 0)
|
||||||
{
|
{
|
||||||
@@ -166,7 +165,7 @@ static void Bcj2Enc_Encode_2(CBcj2Enc *p)
|
|||||||
|
|
||||||
{
|
{
|
||||||
Byte context = (Byte)(num == 0 ? p->prevByte : src[-1]);
|
Byte context = (Byte)(num == 0 ? p->prevByte : src[-1]);
|
||||||
Bool needConvert;
|
BoolInt needConvert;
|
||||||
|
|
||||||
p->bufs[BCJ2_STREAM_MAIN] = dest + 1;
|
p->bufs[BCJ2_STREAM_MAIN] = dest + 1;
|
||||||
p->ip += (UInt32)num + 1;
|
p->ip += (UInt32)num + 1;
|
||||||
@@ -254,7 +253,7 @@ void Bcj2Enc_Encode(CBcj2Enc *p)
|
|||||||
{
|
{
|
||||||
const Byte *src = p->src;
|
const Byte *src = p->src;
|
||||||
const Byte *srcLim = p->srcLim;
|
const Byte *srcLim = p->srcLim;
|
||||||
unsigned finishMode = p->finishMode;
|
EBcj2Enc_FinishMode finishMode = p->finishMode;
|
||||||
|
|
||||||
p->src = p->temp;
|
p->src = p->temp;
|
||||||
p->srcLim = p->temp + p->tempPos;
|
p->srcLim = p->temp + p->tempPos;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* BwtSort.c -- BWT block sorting
|
/* BwtSort.c -- BWT block sorting
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -448,7 +448,7 @@ UInt32 BlockSort(UInt32 *Indices, const Byte *data, UInt32 blockSize)
|
|||||||
|
|
||||||
groupSize = ((Indices[i] & ~0xC0000000) >> kNumBitsMax);
|
groupSize = ((Indices[i] & ~0xC0000000) >> kNumBitsMax);
|
||||||
{
|
{
|
||||||
Bool finishedGroup = ((Indices[i] & 0x80000000) == 0);
|
BoolInt finishedGroup = ((Indices[i] & 0x80000000) == 0);
|
||||||
if ((Indices[i] & 0x40000000) != 0)
|
if ((Indices[i] & 0x40000000) != 0)
|
||||||
{
|
{
|
||||||
groupSize += ((Indices[(size_t)i + 1] >> kNumBitsMax) << kNumExtra0Bits);
|
groupSize += ((Indices[(size_t)i + 1] >> kNumBitsMax) << kNumExtra0Bits);
|
||||||
|
|||||||
28
C/CpuArch.c
28
C/CpuArch.c
@@ -1,5 +1,5 @@
|
|||||||
/* CpuArch.c -- CPU specific code
|
/* CpuArch.c -- CPU specific code
|
||||||
2016-02-25: Igor Pavlov : Public domain */
|
2018-02-18: Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool x86cpuid_CheckAndRead(Cx86cpuid *p)
|
BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p)
|
||||||
{
|
{
|
||||||
CHECK_CPUID_IS_SUPPORTED
|
CHECK_CPUID_IS_SUPPORTED
|
||||||
MyCPUID(0, &p->maxFunc, &p->vendor[0], &p->vendor[2], &p->vendor[1]);
|
MyCPUID(0, &p->maxFunc, &p->vendor[0], &p->vendor[2], &p->vendor[1]);
|
||||||
@@ -144,7 +144,7 @@ int x86cpuid_GetFirm(const Cx86cpuid *p)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool CPU_Is_InOrder()
|
BoolInt CPU_Is_InOrder()
|
||||||
{
|
{
|
||||||
Cx86cpuid p;
|
Cx86cpuid p;
|
||||||
int firm;
|
int firm;
|
||||||
@@ -175,7 +175,7 @@ Bool CPU_Is_InOrder()
|
|||||||
|
|
||||||
#if !defined(MY_CPU_AMD64) && defined(_WIN32)
|
#if !defined(MY_CPU_AMD64) && defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
static Bool CPU_Sys_Is_SSE_Supported()
|
static BoolInt CPU_Sys_Is_SSE_Supported()
|
||||||
{
|
{
|
||||||
OSVERSIONINFO vi;
|
OSVERSIONINFO vi;
|
||||||
vi.dwOSVersionInfoSize = sizeof(vi);
|
vi.dwOSVersionInfoSize = sizeof(vi);
|
||||||
@@ -188,7 +188,7 @@ static Bool CPU_Sys_Is_SSE_Supported()
|
|||||||
#define CHECK_SYS_SSE_SUPPORT
|
#define CHECK_SYS_SSE_SUPPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Bool CPU_Is_Aes_Supported()
|
BoolInt CPU_Is_Aes_Supported()
|
||||||
{
|
{
|
||||||
Cx86cpuid p;
|
Cx86cpuid p;
|
||||||
CHECK_SYS_SSE_SUPPORT
|
CHECK_SYS_SSE_SUPPORT
|
||||||
@@ -197,4 +197,22 @@ Bool CPU_Is_Aes_Supported()
|
|||||||
return (p.c >> 25) & 1;
|
return (p.c >> 25) & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BoolInt CPU_IsSupported_PageGB()
|
||||||
|
{
|
||||||
|
Cx86cpuid cpuid;
|
||||||
|
if (!x86cpuid_CheckAndRead(&cpuid))
|
||||||
|
return False;
|
||||||
|
{
|
||||||
|
UInt32 d[4] = { 0 };
|
||||||
|
MyCPUID(0x80000000, &d[0], &d[1], &d[2], &d[3]);
|
||||||
|
if (d[0] < 0x80000001)
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
UInt32 d[4] = { 0 };
|
||||||
|
MyCPUID(0x80000001, &d[0], &d[1], &d[2], &d[3]);
|
||||||
|
return (d[3] >> 26) & 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
31
C/CpuArch.h
31
C/CpuArch.h
@@ -1,5 +1,5 @@
|
|||||||
/* CpuArch.h -- CPU specific code
|
/* CpuArch.h -- CPU specific code
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-02-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __CPU_ARCH_H
|
#ifndef __CPU_ARCH_H
|
||||||
#define __CPU_ARCH_H
|
#define __CPU_ARCH_H
|
||||||
@@ -174,7 +174,7 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
|
|||||||
#ifndef MY_CPU_NAME
|
#ifndef MY_CPU_NAME
|
||||||
#ifdef MY_CPU_LE
|
#ifdef MY_CPU_LE
|
||||||
#define MY_CPU_NAME "LE"
|
#define MY_CPU_NAME "LE"
|
||||||
#elif MY_CPU_BE
|
#elif defined(MY_CPU_BE)
|
||||||
#define MY_CPU_NAME "BE"
|
#define MY_CPU_NAME "BE"
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
@@ -190,8 +190,7 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
|
|||||||
#ifdef MY_CPU_LE
|
#ifdef MY_CPU_LE
|
||||||
#if defined(MY_CPU_X86_OR_AMD64) \
|
#if defined(MY_CPU_X86_OR_AMD64) \
|
||||||
|| defined(MY_CPU_ARM64) \
|
|| defined(MY_CPU_ARM64) \
|
||||||
|| defined(__ARM_FEATURE_UNALIGNED) \
|
|| defined(__ARM_FEATURE_UNALIGNED)
|
||||||
|| defined(__AARCH64EL__)
|
|
||||||
#define MY_CPU_LE_UNALIGN
|
#define MY_CPU_LE_UNALIGN
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -237,6 +236,11 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __has_builtin
|
||||||
|
#define MY__has_builtin(x) __has_builtin(x)
|
||||||
|
#else
|
||||||
|
#define MY__has_builtin(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ (_MSC_VER >= 1300)
|
#if defined(MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ (_MSC_VER >= 1300)
|
||||||
|
|
||||||
@@ -244,15 +248,21 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#pragma intrinsic(_byteswap_ushort)
|
||||||
#pragma intrinsic(_byteswap_ulong)
|
#pragma intrinsic(_byteswap_ulong)
|
||||||
#pragma intrinsic(_byteswap_uint64)
|
#pragma intrinsic(_byteswap_uint64)
|
||||||
|
|
||||||
|
/* #define GetBe16(p) _byteswap_ushort(*(const UInt16 *)(const Byte *)(p)) */
|
||||||
#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
|
#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
|
||||||
#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))
|
#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))
|
||||||
|
|
||||||
#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)
|
#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)
|
||||||
|
|
||||||
#elif defined(MY_CPU_LE_UNALIGN) && defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
#elif defined(MY_CPU_LE_UNALIGN) && ( \
|
||||||
|
(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \
|
||||||
|
|| (defined(__clang__) && MY__has_builtin(__builtin_bswap16)) )
|
||||||
|
|
||||||
|
/* #define GetBe16(p) __builtin_bswap16(*(const UInt16 *)(const Byte *)(p)) */
|
||||||
#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p))
|
#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p))
|
||||||
#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p))
|
#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p))
|
||||||
|
|
||||||
@@ -277,10 +287,14 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GetBe16
|
||||||
|
|
||||||
#define GetBe16(p) ( (UInt16) ( \
|
#define GetBe16(p) ( (UInt16) ( \
|
||||||
((UInt16)((const Byte *)(p))[0] << 8) | \
|
((UInt16)((const Byte *)(p))[0] << 8) | \
|
||||||
((const Byte *)(p))[1] ))
|
((const Byte *)(p))[1] ))
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MY_CPU_X86_OR_AMD64
|
#ifdef MY_CPU_X86_OR_AMD64
|
||||||
@@ -304,15 +318,16 @@ enum
|
|||||||
|
|
||||||
void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);
|
void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);
|
||||||
|
|
||||||
Bool x86cpuid_CheckAndRead(Cx86cpuid *p);
|
BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p);
|
||||||
int x86cpuid_GetFirm(const Cx86cpuid *p);
|
int x86cpuid_GetFirm(const Cx86cpuid *p);
|
||||||
|
|
||||||
#define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF))
|
#define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF))
|
||||||
#define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) & 0xF))
|
#define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) & 0xF))
|
||||||
#define x86cpuid_GetStepping(ver) (ver & 0xF)
|
#define x86cpuid_GetStepping(ver) (ver & 0xF)
|
||||||
|
|
||||||
Bool CPU_Is_InOrder();
|
BoolInt CPU_Is_InOrder();
|
||||||
Bool CPU_Is_Aes_Supported();
|
BoolInt CPU_Is_Aes_Supported();
|
||||||
|
BoolInt CPU_IsSupported_PageGB();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
25
C/DllSecur.c
25
C/DllSecur.c
@@ -1,5 +1,5 @@
|
|||||||
/* DllSecur.c -- DLL loading security
|
/* DllSecur.c -- DLL loading security
|
||||||
2016-10-04 : Igor Pavlov : Public domain */
|
2018-02-21 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -28,10 +28,31 @@ static const char * const g_Dlls =
|
|||||||
"CRYPTBASE\0"
|
"CRYPTBASE\0"
|
||||||
"OLEACC\0"
|
"OLEACC\0"
|
||||||
"CLBCATQ\0"
|
"CLBCATQ\0"
|
||||||
|
"VERSION\0"
|
||||||
;
|
;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void My_SetDefaultDllDirectories()
|
||||||
|
{
|
||||||
|
#ifndef UNDER_CE
|
||||||
|
|
||||||
|
OSVERSIONINFO vi;
|
||||||
|
vi.dwOSVersionInfoSize = sizeof(vi);
|
||||||
|
GetVersionEx(&vi);
|
||||||
|
if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0)
|
||||||
|
{
|
||||||
|
Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories)
|
||||||
|
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
|
||||||
|
if (setDllDirs)
|
||||||
|
if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LoadSecurityDlls()
|
void LoadSecurityDlls()
|
||||||
{
|
{
|
||||||
#ifndef UNDER_CE
|
#ifndef UNDER_CE
|
||||||
@@ -70,7 +91,7 @@ void LoadSecurityDlls()
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
char c = *dll++;
|
char c = *dll++;
|
||||||
buf[pos + k] = c;
|
buf[pos + k] = (Byte)c;
|
||||||
k++;
|
k++;
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* DllSecur.h -- DLL loading for security
|
/* DllSecur.h -- DLL loading for security
|
||||||
2016-06-08 : Igor Pavlov : Public domain */
|
2018-02-19 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __DLL_SECUR_H
|
#ifndef __DLL_SECUR_H
|
||||||
#define __DLL_SECUR_H
|
#define __DLL_SECUR_H
|
||||||
@@ -10,6 +10,7 @@ EXTERN_C_BEGIN
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
void My_SetDefaultDllDirectories();
|
||||||
void LoadSecurityDlls();
|
void LoadSecurityDlls();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
209
C/LzFind.c
209
C/LzFind.c
@@ -1,5 +1,5 @@
|
|||||||
/* LzFind.c -- Match finder for LZ algorithms
|
/* LzFind.c -- Match finder for LZ algorithms
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -138,15 +138,16 @@ static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
|
|||||||
|
|
||||||
void MatchFinder_Construct(CMatchFinder *p)
|
void MatchFinder_Construct(CMatchFinder *p)
|
||||||
{
|
{
|
||||||
UInt32 i;
|
unsigned i;
|
||||||
p->bufferBase = NULL;
|
p->bufferBase = NULL;
|
||||||
p->directInput = 0;
|
p->directInput = 0;
|
||||||
p->hash = NULL;
|
p->hash = NULL;
|
||||||
|
p->expectedDataSize = (UInt64)(Int64)-1;
|
||||||
MatchFinder_SetDefaultSettings(p);
|
MatchFinder_SetDefaultSettings(p);
|
||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
UInt32 r = i;
|
UInt32 r = (UInt32)i;
|
||||||
unsigned j;
|
unsigned j;
|
||||||
for (j = 0; j < 8; j++)
|
for (j = 0; j < 8; j++)
|
||||||
r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1)));
|
r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1)));
|
||||||
@@ -208,7 +209,11 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
|
|||||||
hs = (1 << 16) - 1;
|
hs = (1 << 16) - 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hs = historySize - 1;
|
hs = historySize;
|
||||||
|
if (hs > p->expectedDataSize)
|
||||||
|
hs = (UInt32)p->expectedDataSize;
|
||||||
|
if (hs != 0)
|
||||||
|
hs--;
|
||||||
hs |= (hs >> 1);
|
hs |= (hs >> 1);
|
||||||
hs |= (hs >> 2);
|
hs |= (hs >> 2);
|
||||||
hs |= (hs >> 4);
|
hs |= (hs >> 4);
|
||||||
@@ -292,17 +297,33 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
|
|||||||
p->posLimit = p->pos + limit;
|
p->posLimit = p->pos + limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatchFinder_Init_2(CMatchFinder *p, int readData)
|
|
||||||
{
|
|
||||||
UInt32 i;
|
|
||||||
UInt32 *hash = p->hash;
|
|
||||||
UInt32 num = p->hashSizeSum;
|
|
||||||
for (i = 0; i < num; i++)
|
|
||||||
hash[i] = kEmptyHashValue;
|
|
||||||
|
|
||||||
|
void MatchFinder_Init_LowHash(CMatchFinder *p)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
CLzRef *items = p->hash;
|
||||||
|
size_t numItems = p->fixedHashSize;
|
||||||
|
for (i = 0; i < numItems; i++)
|
||||||
|
items[i] = kEmptyHashValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MatchFinder_Init_HighHash(CMatchFinder *p)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
CLzRef *items = p->hash + p->fixedHashSize;
|
||||||
|
size_t numItems = (size_t)p->hashMask + 1;
|
||||||
|
for (i = 0; i < numItems; i++)
|
||||||
|
items[i] = kEmptyHashValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MatchFinder_Init_3(CMatchFinder *p, int readData)
|
||||||
|
{
|
||||||
p->cyclicBufferPos = 0;
|
p->cyclicBufferPos = 0;
|
||||||
p->buffer = p->bufferBase;
|
p->buffer = p->bufferBase;
|
||||||
p->pos = p->streamPos = p->cyclicBufferSize;
|
p->pos =
|
||||||
|
p->streamPos = p->cyclicBufferSize;
|
||||||
p->result = SZ_OK;
|
p->result = SZ_OK;
|
||||||
p->streamEndWasReached = 0;
|
p->streamEndWasReached = 0;
|
||||||
|
|
||||||
@@ -312,11 +333,15 @@ void MatchFinder_Init_2(CMatchFinder *p, int readData)
|
|||||||
MatchFinder_SetLimits(p);
|
MatchFinder_SetLimits(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MatchFinder_Init(CMatchFinder *p)
|
void MatchFinder_Init(CMatchFinder *p)
|
||||||
{
|
{
|
||||||
MatchFinder_Init_2(p, True);
|
MatchFinder_Init_HighHash(p);
|
||||||
|
MatchFinder_Init_LowHash(p);
|
||||||
|
MatchFinder_Init_3(p, True);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
|
static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
|
||||||
{
|
{
|
||||||
return (p->pos - p->historySize - 1) & kNormalizeMask;
|
return (p->pos - p->historySize - 1) & kNormalizeMask;
|
||||||
@@ -343,6 +368,8 @@ static void MatchFinder_Normalize(CMatchFinder *p)
|
|||||||
MatchFinder_ReduceOffsets(p, subValue);
|
MatchFinder_ReduceOffsets(p, subValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MY_NO_INLINE
|
||||||
static void MatchFinder_CheckLimits(CMatchFinder *p)
|
static void MatchFinder_CheckLimits(CMatchFinder *p)
|
||||||
{
|
{
|
||||||
if (p->pos == kMaxValForNormalize)
|
if (p->pos == kMaxValForNormalize)
|
||||||
@@ -354,10 +381,16 @@ static void MatchFinder_CheckLimits(CMatchFinder *p)
|
|||||||
MatchFinder_SetLimits(p);
|
MatchFinder_SetLimits(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
|
||||||
|
/*
|
||||||
|
(lenLimit > maxLen)
|
||||||
|
*/
|
||||||
|
MY_FORCE_INLINE
|
||||||
|
static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
||||||
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
|
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
|
||||||
UInt32 *distances, UInt32 maxLen)
|
UInt32 *distances, unsigned maxLen)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
son[_cyclicBufferPos] = curMatch;
|
son[_cyclicBufferPos] = curMatch;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@@ -375,7 +408,8 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos,
|
|||||||
break;
|
break;
|
||||||
if (maxLen < len)
|
if (maxLen < len)
|
||||||
{
|
{
|
||||||
*distances++ = maxLen = len;
|
maxLen = len;
|
||||||
|
*distances++ = len;
|
||||||
*distances++ = delta - 1;
|
*distances++ = delta - 1;
|
||||||
if (len == lenLimit)
|
if (len == lenLimit)
|
||||||
return distances;
|
return distances;
|
||||||
@@ -383,15 +417,58 @@ static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
const Byte *lim = cur + lenLimit;
|
||||||
|
son[_cyclicBufferPos] = curMatch;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
UInt32 delta = pos - curMatch;
|
||||||
|
if (delta >= _cyclicBufferSize)
|
||||||
|
break;
|
||||||
|
{
|
||||||
|
ptrdiff_t diff;
|
||||||
|
curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
|
||||||
|
diff = (ptrdiff_t)0 - delta;
|
||||||
|
if (cur[maxLen] == cur[maxLen + diff])
|
||||||
|
{
|
||||||
|
const Byte *c = cur;
|
||||||
|
while (*c == c[diff])
|
||||||
|
{
|
||||||
|
if (++c == lim)
|
||||||
|
{
|
||||||
|
distances[0] = (UInt32)(lim - cur);
|
||||||
|
distances[1] = delta - 1;
|
||||||
|
return distances + 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
unsigned len = (unsigned)(c - cur);
|
||||||
|
if (maxLen < len)
|
||||||
|
{
|
||||||
|
maxLen = len;
|
||||||
|
distances[0] = (UInt32)len;
|
||||||
|
distances[1] = delta - 1;
|
||||||
|
distances += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (--cutValue);
|
||||||
|
|
||||||
|
return distances;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MY_FORCE_INLINE
|
||||||
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
||||||
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
|
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
|
||||||
UInt32 *distances, UInt32 maxLen)
|
UInt32 *distances, UInt32 maxLen)
|
||||||
{
|
{
|
||||||
CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
|
CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
|
||||||
CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
|
CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
|
||||||
UInt32 len0 = 0, len1 = 0;
|
unsigned len0 = 0, len1 = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
UInt32 delta = pos - curMatch;
|
UInt32 delta = pos - curMatch;
|
||||||
@@ -401,9 +478,10 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
|
|||||||
return distances;
|
return distances;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
|
CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
|
||||||
const Byte *pb = cur - delta;
|
const Byte *pb = cur - delta;
|
||||||
UInt32 len = (len0 < len1 ? len0 : len1);
|
unsigned len = (len0 < len1 ? len0 : len1);
|
||||||
|
UInt32 pair0 = pair[0];
|
||||||
if (pb[len] == cur[len])
|
if (pb[len] == cur[len])
|
||||||
{
|
{
|
||||||
if (++len != lenLimit && pb[len] == cur[len])
|
if (++len != lenLimit && pb[len] == cur[len])
|
||||||
@@ -412,11 +490,12 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
|
|||||||
break;
|
break;
|
||||||
if (maxLen < len)
|
if (maxLen < len)
|
||||||
{
|
{
|
||||||
*distances++ = maxLen = len;
|
maxLen = (UInt32)len;
|
||||||
|
*distances++ = (UInt32)len;
|
||||||
*distances++ = delta - 1;
|
*distances++ = delta - 1;
|
||||||
if (len == lenLimit)
|
if (len == lenLimit)
|
||||||
{
|
{
|
||||||
*ptr1 = pair[0];
|
*ptr1 = pair0;
|
||||||
*ptr0 = pair[1];
|
*ptr0 = pair[1];
|
||||||
return distances;
|
return distances;
|
||||||
}
|
}
|
||||||
@@ -443,9 +522,9 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
|
|||||||
static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
||||||
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
|
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
|
||||||
{
|
{
|
||||||
CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
|
CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
|
||||||
CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
|
CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
|
||||||
UInt32 len0 = 0, len1 = 0;
|
unsigned len0 = 0, len1 = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
UInt32 delta = pos - curMatch;
|
UInt32 delta = pos - curMatch;
|
||||||
@@ -455,9 +534,9 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
|
CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
|
||||||
const Byte *pb = cur - delta;
|
const Byte *pb = cur - delta;
|
||||||
UInt32 len = (len0 < len1 ? len0 : len1);
|
unsigned len = (len0 < len1 ? len0 : len1);
|
||||||
if (pb[len] == cur[len])
|
if (pb[len] == cur[len])
|
||||||
{
|
{
|
||||||
while (++len != lenLimit)
|
while (++len != lenLimit)
|
||||||
@@ -495,13 +574,13 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
|
|||||||
p->buffer++; \
|
p->buffer++; \
|
||||||
if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
|
if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
|
||||||
|
|
||||||
#define MOVE_POS_RET MOVE_POS return offset;
|
#define MOVE_POS_RET MOVE_POS return (UInt32)offset;
|
||||||
|
|
||||||
static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
|
static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
|
||||||
|
|
||||||
#define GET_MATCHES_HEADER2(minLen, ret_op) \
|
#define GET_MATCHES_HEADER2(minLen, ret_op) \
|
||||||
UInt32 lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \
|
unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \
|
||||||
lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
|
lenLimit = (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
|
||||||
cur = p->buffer;
|
cur = p->buffer;
|
||||||
|
|
||||||
#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
|
#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
|
||||||
@@ -510,22 +589,22 @@ static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
|
|||||||
#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
|
#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
|
||||||
|
|
||||||
#define GET_MATCHES_FOOTER(offset, maxLen) \
|
#define GET_MATCHES_FOOTER(offset, maxLen) \
|
||||||
offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \
|
offset = (unsigned)(GetMatchesSpec1((UInt32)lenLimit, curMatch, MF_PARAMS(p), \
|
||||||
distances + offset, maxLen) - distances); MOVE_POS_RET;
|
distances + offset, (UInt32)maxLen) - distances); MOVE_POS_RET;
|
||||||
|
|
||||||
#define SKIP_FOOTER \
|
#define SKIP_FOOTER \
|
||||||
SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
|
SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
|
||||||
|
|
||||||
#define UPDATE_maxLen { \
|
#define UPDATE_maxLen { \
|
||||||
ptrdiff_t diff = (ptrdiff_t)0 - d2; \
|
ptrdiff_t diff = (ptrdiff_t)0 - d2; \
|
||||||
const Byte *c = cur + maxLen; \
|
const Byte *c = cur + maxLen; \
|
||||||
const Byte *lim = cur + lenLimit; \
|
const Byte *lim = cur + lenLimit; \
|
||||||
for (; c != lim; c++) if (*(c + diff) != *c) break; \
|
for (; c != lim; c++) if (*(c + diff) != *c) break; \
|
||||||
maxLen = (UInt32)(c - cur); }
|
maxLen = (unsigned)(c - cur); }
|
||||||
|
|
||||||
static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 offset;
|
unsigned offset;
|
||||||
GET_MATCHES_HEADER(2)
|
GET_MATCHES_HEADER(2)
|
||||||
HASH2_CALC;
|
HASH2_CALC;
|
||||||
curMatch = p->hash[hv];
|
curMatch = p->hash[hv];
|
||||||
@@ -536,7 +615,7 @@ static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 offset;
|
unsigned offset;
|
||||||
GET_MATCHES_HEADER(3)
|
GET_MATCHES_HEADER(3)
|
||||||
HASH_ZIP_CALC;
|
HASH_ZIP_CALC;
|
||||||
curMatch = p->hash[hv];
|
curMatch = p->hash[hv];
|
||||||
@@ -547,7 +626,8 @@ UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 h2, d2, maxLen, offset, pos;
|
UInt32 h2, d2, pos;
|
||||||
|
unsigned maxLen, offset;
|
||||||
UInt32 *hash;
|
UInt32 *hash;
|
||||||
GET_MATCHES_HEADER(3)
|
GET_MATCHES_HEADER(3)
|
||||||
|
|
||||||
@@ -569,12 +649,12 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
||||||
{
|
{
|
||||||
UPDATE_maxLen
|
UPDATE_maxLen
|
||||||
distances[0] = maxLen;
|
distances[0] = (UInt32)maxLen;
|
||||||
distances[1] = d2 - 1;
|
distances[1] = d2 - 1;
|
||||||
offset = 2;
|
offset = 2;
|
||||||
if (maxLen == lenLimit)
|
if (maxLen == lenLimit)
|
||||||
{
|
{
|
||||||
SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
|
SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));
|
||||||
MOVE_POS_RET;
|
MOVE_POS_RET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -584,7 +664,8 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 h2, h3, d2, d3, maxLen, offset, pos;
|
UInt32 h2, h3, d2, d3, pos;
|
||||||
|
unsigned maxLen, offset;
|
||||||
UInt32 *hash;
|
UInt32 *hash;
|
||||||
GET_MATCHES_HEADER(4)
|
GET_MATCHES_HEADER(4)
|
||||||
|
|
||||||
@@ -593,12 +674,12 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
pos = p->pos;
|
pos = p->pos;
|
||||||
|
|
||||||
d2 = pos - hash[ h2];
|
d2 = pos - hash [h2];
|
||||||
d3 = pos - (hash + kFix3HashSize)[h3];
|
d3 = pos - (hash + kFix3HashSize)[h3];
|
||||||
|
|
||||||
curMatch = (hash + kFix4HashSize)[hv];
|
curMatch = (hash + kFix4HashSize)[hv];
|
||||||
|
|
||||||
hash[ h2] = pos;
|
hash [h2] = pos;
|
||||||
(hash + kFix3HashSize)[h3] = pos;
|
(hash + kFix3HashSize)[h3] = pos;
|
||||||
(hash + kFix4HashSize)[hv] = pos;
|
(hash + kFix4HashSize)[hv] = pos;
|
||||||
|
|
||||||
@@ -607,7 +688,8 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
||||||
{
|
{
|
||||||
distances[0] = maxLen = 2;
|
maxLen = 2;
|
||||||
|
distances[0] = 2;
|
||||||
distances[1] = d2 - 1;
|
distances[1] = d2 - 1;
|
||||||
offset = 2;
|
offset = 2;
|
||||||
}
|
}
|
||||||
@@ -623,10 +705,10 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
if (offset != 0)
|
if (offset != 0)
|
||||||
{
|
{
|
||||||
UPDATE_maxLen
|
UPDATE_maxLen
|
||||||
distances[(size_t)offset - 2] = maxLen;
|
distances[(size_t)offset - 2] = (UInt32)maxLen;
|
||||||
if (maxLen == lenLimit)
|
if (maxLen == lenLimit)
|
||||||
{
|
{
|
||||||
SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));
|
SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));
|
||||||
MOVE_POS_RET;
|
MOVE_POS_RET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -649,13 +731,13 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
pos = p->pos;
|
pos = p->pos;
|
||||||
|
|
||||||
d2 = pos - hash[ h2];
|
d2 = pos - hash [h2];
|
||||||
d3 = pos - (hash + kFix3HashSize)[h3];
|
d3 = pos - (hash + kFix3HashSize)[h3];
|
||||||
d4 = pos - (hash + kFix4HashSize)[h4];
|
d4 = pos - (hash + kFix4HashSize)[h4];
|
||||||
|
|
||||||
curMatch = (hash + kFix5HashSize)[hv];
|
curMatch = (hash + kFix5HashSize)[hv];
|
||||||
|
|
||||||
hash[ h2] = pos;
|
hash [h2] = pos;
|
||||||
(hash + kFix3HashSize)[h3] = pos;
|
(hash + kFix3HashSize)[h3] = pos;
|
||||||
(hash + kFix4HashSize)[h4] = pos;
|
(hash + kFix4HashSize)[h4] = pos;
|
||||||
(hash + kFix5HashSize)[hv] = pos;
|
(hash + kFix5HashSize)[hv] = pos;
|
||||||
@@ -716,7 +798,8 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 h2, h3, d2, d3, maxLen, offset, pos;
|
UInt32 h2, h3, d2, d3, pos;
|
||||||
|
unsigned maxLen, offset;
|
||||||
UInt32 *hash;
|
UInt32 *hash;
|
||||||
GET_MATCHES_HEADER(4)
|
GET_MATCHES_HEADER(4)
|
||||||
|
|
||||||
@@ -725,12 +808,11 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
pos = p->pos;
|
pos = p->pos;
|
||||||
|
|
||||||
d2 = pos - hash[ h2];
|
d2 = pos - hash [h2];
|
||||||
d3 = pos - (hash + kFix3HashSize)[h3];
|
d3 = pos - (hash + kFix3HashSize)[h3];
|
||||||
|
|
||||||
curMatch = (hash + kFix4HashSize)[hv];
|
curMatch = (hash + kFix4HashSize)[hv];
|
||||||
|
|
||||||
hash[ h2] = pos;
|
hash [h2] = pos;
|
||||||
(hash + kFix3HashSize)[h3] = pos;
|
(hash + kFix3HashSize)[h3] = pos;
|
||||||
(hash + kFix4HashSize)[hv] = pos;
|
(hash + kFix4HashSize)[hv] = pos;
|
||||||
|
|
||||||
@@ -739,7 +821,8 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
|
||||||
{
|
{
|
||||||
distances[0] = maxLen = 2;
|
maxLen = 2;
|
||||||
|
distances[0] = 2;
|
||||||
distances[1] = d2 - 1;
|
distances[1] = d2 - 1;
|
||||||
offset = 2;
|
offset = 2;
|
||||||
}
|
}
|
||||||
@@ -755,7 +838,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
if (offset != 0)
|
if (offset != 0)
|
||||||
{
|
{
|
||||||
UPDATE_maxLen
|
UPDATE_maxLen
|
||||||
distances[(size_t)offset - 2] = maxLen;
|
distances[(size_t)offset - 2] = (UInt32)maxLen;
|
||||||
if (maxLen == lenLimit)
|
if (maxLen == lenLimit)
|
||||||
{
|
{
|
||||||
p->son[p->cyclicBufferPos] = curMatch;
|
p->son[p->cyclicBufferPos] = curMatch;
|
||||||
@@ -766,7 +849,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
if (maxLen < 3)
|
if (maxLen < 3)
|
||||||
maxLen = 3;
|
maxLen = 3;
|
||||||
|
|
||||||
offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
|
offset = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
|
||||||
distances + offset, maxLen) - (distances));
|
distances + offset, maxLen) - (distances));
|
||||||
MOVE_POS_RET
|
MOVE_POS_RET
|
||||||
}
|
}
|
||||||
@@ -783,13 +866,13 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
pos = p->pos;
|
pos = p->pos;
|
||||||
|
|
||||||
d2 = pos - hash[ h2];
|
d2 = pos - hash [h2];
|
||||||
d3 = pos - (hash + kFix3HashSize)[h3];
|
d3 = pos - (hash + kFix3HashSize)[h3];
|
||||||
d4 = pos - (hash + kFix4HashSize)[h4];
|
d4 = pos - (hash + kFix4HashSize)[h4];
|
||||||
|
|
||||||
curMatch = (hash + kFix5HashSize)[hv];
|
curMatch = (hash + kFix5HashSize)[hv];
|
||||||
|
|
||||||
hash[ h2] = pos;
|
hash [h2] = pos;
|
||||||
(hash + kFix3HashSize)[h3] = pos;
|
(hash + kFix3HashSize)[h3] = pos;
|
||||||
(hash + kFix4HashSize)[h4] = pos;
|
(hash + kFix4HashSize)[h4] = pos;
|
||||||
(hash + kFix5HashSize)[hv] = pos;
|
(hash + kFix5HashSize)[hv] = pos;
|
||||||
@@ -852,12 +935,12 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
|||||||
|
|
||||||
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 offset;
|
unsigned offset;
|
||||||
GET_MATCHES_HEADER(3)
|
GET_MATCHES_HEADER(3)
|
||||||
HASH_ZIP_CALC;
|
HASH_ZIP_CALC;
|
||||||
curMatch = p->hash[hv];
|
curMatch = p->hash[hv];
|
||||||
p->hash[hv] = p->pos;
|
p->hash[hv] = p->pos;
|
||||||
offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
|
offset = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
|
||||||
distances, 2) - (distances));
|
distances, 2) - (distances));
|
||||||
MOVE_POS_RET
|
MOVE_POS_RET
|
||||||
}
|
}
|
||||||
@@ -915,7 +998,7 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
|||||||
HASH4_CALC;
|
HASH4_CALC;
|
||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
curMatch = (hash + kFix4HashSize)[hv];
|
curMatch = (hash + kFix4HashSize)[hv];
|
||||||
hash[ h2] =
|
hash [h2] =
|
||||||
(hash + kFix3HashSize)[h3] =
|
(hash + kFix3HashSize)[h3] =
|
||||||
(hash + kFix4HashSize)[hv] = p->pos;
|
(hash + kFix4HashSize)[hv] = p->pos;
|
||||||
SKIP_FOOTER
|
SKIP_FOOTER
|
||||||
@@ -934,7 +1017,7 @@ static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
|||||||
HASH5_CALC;
|
HASH5_CALC;
|
||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
curMatch = (hash + kFix5HashSize)[hv];
|
curMatch = (hash + kFix5HashSize)[hv];
|
||||||
hash[ h2] =
|
hash [h2] =
|
||||||
(hash + kFix3HashSize)[h3] =
|
(hash + kFix3HashSize)[h3] =
|
||||||
(hash + kFix4HashSize)[h4] =
|
(hash + kFix4HashSize)[h4] =
|
||||||
(hash + kFix5HashSize)[hv] = p->pos;
|
(hash + kFix5HashSize)[hv] = p->pos;
|
||||||
@@ -954,7 +1037,7 @@ static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
|||||||
HASH4_CALC;
|
HASH4_CALC;
|
||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
curMatch = (hash + kFix4HashSize)[hv];
|
curMatch = (hash + kFix4HashSize)[hv];
|
||||||
hash[ h2] =
|
hash [h2] =
|
||||||
(hash + kFix3HashSize)[h3] =
|
(hash + kFix3HashSize)[h3] =
|
||||||
(hash + kFix4HashSize)[hv] = p->pos;
|
(hash + kFix4HashSize)[hv] = p->pos;
|
||||||
p->son[p->cyclicBufferPos] = curMatch;
|
p->son[p->cyclicBufferPos] = curMatch;
|
||||||
@@ -974,7 +1057,7 @@ static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
|||||||
HASH5_CALC;
|
HASH5_CALC;
|
||||||
hash = p->hash;
|
hash = p->hash;
|
||||||
curMatch = hash + kFix5HashSize)[hv];
|
curMatch = hash + kFix5HashSize)[hv];
|
||||||
hash[ h2] =
|
hash [h2] =
|
||||||
(hash + kFix3HashSize)[h3] =
|
(hash + kFix3HashSize)[h3] =
|
||||||
(hash + kFix4HashSize)[h4] =
|
(hash + kFix4HashSize)[h4] =
|
||||||
(hash + kFix5HashSize)[hv] = p->pos;
|
(hash + kFix5HashSize)[hv] = p->pos;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* LzFind.h -- Match finder for LZ algorithms
|
/* LzFind.h -- Match finder for LZ algorithms
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2017-06-10 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZ_FIND_H
|
#ifndef __LZ_FIND_H
|
||||||
#define __LZ_FIND_H
|
#define __LZ_FIND_H
|
||||||
@@ -47,6 +47,8 @@ typedef struct _CMatchFinder
|
|||||||
SRes result;
|
SRes result;
|
||||||
UInt32 crc[256];
|
UInt32 crc[256];
|
||||||
size_t numRefs;
|
size_t numRefs;
|
||||||
|
|
||||||
|
UInt64 expectedDataSize;
|
||||||
} CMatchFinder;
|
} CMatchFinder;
|
||||||
|
|
||||||
#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
|
#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
|
||||||
@@ -103,7 +105,9 @@ typedef struct _IMatchFinder
|
|||||||
|
|
||||||
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
|
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
|
||||||
|
|
||||||
void MatchFinder_Init_2(CMatchFinder *p, int readData);
|
void MatchFinder_Init_LowHash(CMatchFinder *p);
|
||||||
|
void MatchFinder_Init_HighHash(CMatchFinder *p);
|
||||||
|
void MatchFinder_Init_3(CMatchFinder *p, int readData);
|
||||||
void MatchFinder_Init(CMatchFinder *p);
|
void MatchFinder_Init(CMatchFinder *p);
|
||||||
|
|
||||||
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
||||||
|
|||||||
154
C/LzFindMt.c
154
C/LzFindMt.c
@@ -1,5 +1,5 @@
|
|||||||
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
|
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-12-29 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -33,6 +33,8 @@ static void MtSync_GetNextBlock(CMtSync *p)
|
|||||||
|
|
||||||
Event_Set(&p->canStart);
|
Event_Set(&p->canStart);
|
||||||
Event_Wait(&p->wasStarted);
|
Event_Wait(&p->wasStarted);
|
||||||
|
|
||||||
|
// if (mt) MatchFinder_Init_LowHash(mt->MatchFinder);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -155,6 +157,9 @@ static void HashThreadFunc(CMatchFinderMt *mt)
|
|||||||
UInt32 numProcessedBlocks = 0;
|
UInt32 numProcessedBlocks = 0;
|
||||||
Event_Wait(&p->canStart);
|
Event_Wait(&p->canStart);
|
||||||
Event_Set(&p->wasStarted);
|
Event_Set(&p->wasStarted);
|
||||||
|
|
||||||
|
MatchFinder_Init_HighHash(mt->MatchFinder);
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (p->exit)
|
if (p->exit)
|
||||||
@@ -205,7 +210,7 @@ static void HashThreadFunc(CMatchFinderMt *mt)
|
|||||||
if (num > kMtHashBlockSize - 2)
|
if (num > kMtHashBlockSize - 2)
|
||||||
num = kMtHashBlockSize - 2;
|
num = kMtHashBlockSize - 2;
|
||||||
mt->GetHeadsFunc(mf->buffer, mf->pos, mf->hash + mf->fixedHashSize, mf->hashMask, heads + 2, num, mf->crc);
|
mt->GetHeadsFunc(mf->buffer, mf->pos, mf->hash + mf->fixedHashSize, mf->hashMask, heads + 2, num, mf->crc);
|
||||||
heads[0] += num;
|
heads[0] = 2 + num;
|
||||||
}
|
}
|
||||||
mf->pos += num;
|
mf->pos += num;
|
||||||
mf->buffer += num;
|
mf->buffer += num;
|
||||||
@@ -227,38 +232,57 @@ static void MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt *p)
|
|||||||
|
|
||||||
#define kEmptyHashValue 0
|
#define kEmptyHashValue 0
|
||||||
|
|
||||||
/* #define MFMT_GM_INLINE */
|
#define MFMT_GM_INLINE
|
||||||
|
|
||||||
#ifdef MFMT_GM_INLINE
|
#ifdef MFMT_GM_INLINE
|
||||||
|
|
||||||
#define NO_INLINE MY_FAST_CALL
|
/*
|
||||||
|
we use size_t for _cyclicBufferPos instead of UInt32
|
||||||
|
to eliminate "movsx" BUG in old MSVC x64 compiler.
|
||||||
|
*/
|
||||||
|
|
||||||
static Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CLzRef *son,
|
MY_NO_INLINE
|
||||||
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
|
static UInt32 *GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CLzRef *son,
|
||||||
UInt32 *_distances, UInt32 _maxLen, const UInt32 *hash, Int32 limit, UInt32 size, UInt32 *posRes)
|
size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
|
||||||
|
UInt32 *distances, UInt32 _maxLen, const UInt32 *hash, const UInt32 *limit, UInt32 size, UInt32 *posRes)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
UInt32 *distances = _distances + 1;
|
UInt32 *_distances = ++distances;
|
||||||
UInt32 curMatch = pos - *hash++;
|
UInt32 delta = *hash++;
|
||||||
|
|
||||||
CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;
|
CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
|
||||||
CLzRef *ptr1 = son + (_cyclicBufferPos << 1);
|
CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
|
||||||
UInt32 len0 = 0, len1 = 0;
|
unsigned len0 = 0, len1 = 0;
|
||||||
UInt32 cutValue = _cutValue;
|
UInt32 cutValue = _cutValue;
|
||||||
UInt32 maxLen = _maxLen;
|
unsigned maxLen = (unsigned)_maxLen;
|
||||||
for (;;)
|
|
||||||
|
/*
|
||||||
|
if (size > 1)
|
||||||
{
|
{
|
||||||
UInt32 delta = pos - curMatch;
|
UInt32 delta = *hash;
|
||||||
if (cutValue-- == 0 || delta >= _cyclicBufferSize)
|
if (delta < _cyclicBufferSize)
|
||||||
{
|
{
|
||||||
*ptr0 = *ptr1 = kEmptyHashValue;
|
UInt32 cyc1 = _cyclicBufferPos + 1;
|
||||||
break;
|
CLzRef *pair = son + ((size_t)(cyc1 - delta + ((delta > cyc1) ? _cyclicBufferSize : 0)) << 1);
|
||||||
|
Byte b = *(cur + 1 - delta);
|
||||||
|
_distances[0] = pair[0];
|
||||||
|
_distances[1] = b;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (cutValue == 0 || delta >= _cyclicBufferSize)
|
||||||
|
{
|
||||||
|
*ptr0 = *ptr1 = kEmptyHashValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
{
|
{
|
||||||
CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
|
CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((_cyclicBufferPos < delta) ? _cyclicBufferSize : 0)) << 1);
|
||||||
const Byte *pb = cur - delta;
|
const Byte *pb = cur - delta;
|
||||||
UInt32 len = (len0 < len1 ? len0 : len1);
|
unsigned len = (len0 < len1 ? len0 : len1);
|
||||||
|
UInt32 pair0 = *pair;
|
||||||
if (pb[len] == cur[len])
|
if (pb[len] == cur[len])
|
||||||
{
|
{
|
||||||
if (++len != lenLimit && pb[len] == cur[len])
|
if (++len != lenLimit && pb[len] == cur[len])
|
||||||
@@ -267,54 +291,66 @@ static Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *
|
|||||||
break;
|
break;
|
||||||
if (maxLen < len)
|
if (maxLen < len)
|
||||||
{
|
{
|
||||||
*distances++ = maxLen = len;
|
maxLen = len;
|
||||||
|
*distances++ = (UInt32)len;
|
||||||
*distances++ = delta - 1;
|
*distances++ = delta - 1;
|
||||||
if (len == lenLimit)
|
if (len == lenLimit)
|
||||||
{
|
{
|
||||||
*ptr1 = pair[0];
|
UInt32 pair1 = pair[1];
|
||||||
*ptr0 = pair[1];
|
*ptr1 = pair0;
|
||||||
|
*ptr0 = pair1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pb[len] < cur[len])
|
|
||||||
{
|
{
|
||||||
*ptr1 = curMatch;
|
UInt32 curMatch = pos - delta;
|
||||||
ptr1 = pair + 1;
|
// delta = pos - *pair;
|
||||||
curMatch = *ptr1;
|
// delta = pos - pair[((UInt32)pb[len] - (UInt32)cur[len]) >> 31];
|
||||||
len1 = len;
|
if (pb[len] < cur[len])
|
||||||
}
|
{
|
||||||
else
|
delta = pos - pair[1];
|
||||||
{
|
*ptr1 = curMatch;
|
||||||
*ptr0 = curMatch;
|
ptr1 = pair + 1;
|
||||||
ptr0 = pair;
|
len1 = len;
|
||||||
curMatch = *ptr0;
|
}
|
||||||
len0 = len;
|
else
|
||||||
|
{
|
||||||
|
delta = pos - *pair;
|
||||||
|
*ptr0 = curMatch;
|
||||||
|
ptr0 = pair;
|
||||||
|
len0 = len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (--cutValue == 0 || delta >= _cyclicBufferSize)
|
||||||
|
{
|
||||||
|
*ptr0 = *ptr1 = kEmptyHashValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pos++;
|
pos++;
|
||||||
_cyclicBufferPos++;
|
_cyclicBufferPos++;
|
||||||
cur++;
|
cur++;
|
||||||
{
|
{
|
||||||
UInt32 num = (UInt32)(distances - _distances);
|
UInt32 num = (UInt32)(distances - _distances);
|
||||||
*_distances = num - 1;
|
_distances[-1] = num;
|
||||||
_distances += num;
|
|
||||||
limit -= num;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (limit > 0 && --size != 0);
|
while (distances < limit && --size != 0);
|
||||||
*posRes = pos;
|
*posRes = pos;
|
||||||
return limit;
|
return distances;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)
|
static void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)
|
||||||
{
|
{
|
||||||
UInt32 numProcessed = 0;
|
UInt32 numProcessed = 0;
|
||||||
UInt32 curPos = 2;
|
UInt32 curPos = 2;
|
||||||
UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2);
|
UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2); // * 2
|
||||||
|
|
||||||
distances[1] = p->hashNumAvail;
|
distances[1] = p->hashNumAvail;
|
||||||
|
|
||||||
@@ -364,8 +400,10 @@ static void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)
|
|||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
UInt32 posRes;
|
UInt32 posRes;
|
||||||
curPos = limit - GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
|
curPos = (UInt32)(GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,
|
||||||
distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos, (Int32)(limit - curPos), size, &posRes);
|
distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos,
|
||||||
|
distances + limit,
|
||||||
|
size, &posRes) - distances);
|
||||||
p->hashBufPos += posRes - pos;
|
p->hashBufPos += posRes - pos;
|
||||||
cyclicBufferPos += posRes - pos;
|
cyclicBufferPos += posRes - pos;
|
||||||
p->buffer += posRes - pos;
|
p->buffer += posRes - pos;
|
||||||
@@ -496,14 +534,18 @@ SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddB
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Call it after ReleaseStream / SetStream */
|
/* Call it after ReleaseStream / SetStream */
|
||||||
void MatchFinderMt_Init(CMatchFinderMt *p)
|
static void MatchFinderMt_Init(CMatchFinderMt *p)
|
||||||
{
|
{
|
||||||
CMatchFinder *mf = p->MatchFinder;
|
CMatchFinder *mf = p->MatchFinder;
|
||||||
p->btBufPos = p->btBufPosLimit = 0;
|
|
||||||
p->hashBufPos = p->hashBufPosLimit = 0;
|
p->btBufPos =
|
||||||
|
p->btBufPosLimit = 0;
|
||||||
|
p->hashBufPos =
|
||||||
|
p->hashBufPosLimit = 0;
|
||||||
|
|
||||||
/* Init without data reading. We don't want to read data in this thread */
|
/* Init without data reading. We don't want to read data in this thread */
|
||||||
MatchFinder_Init_2(mf, False);
|
MatchFinder_Init_3(mf, False);
|
||||||
|
MatchFinder_Init_LowHash(mf);
|
||||||
|
|
||||||
p->pointerToCurPos = Inline_MatchFinder_GetPointerToCurrentPos(mf);
|
p->pointerToCurPos = Inline_MatchFinder_GetPointerToCurrentPos(mf);
|
||||||
p->btNumAvailBytes = 0;
|
p->btNumAvailBytes = 0;
|
||||||
@@ -684,8 +726,12 @@ static UInt32 MatchFinderMt2_GetMatches(CMatchFinderMt *p, UInt32 *distances)
|
|||||||
UInt32 i;
|
UInt32 i;
|
||||||
for (i = 0; i < len; i += 2)
|
for (i = 0; i < len; i += 2)
|
||||||
{
|
{
|
||||||
*distances++ = *btBuf++;
|
UInt32 v0 = btBuf[0];
|
||||||
*distances++ = *btBuf++;
|
UInt32 v1 = btBuf[1];
|
||||||
|
btBuf += 2;
|
||||||
|
distances[0] = v0;
|
||||||
|
distances[1] = v1;
|
||||||
|
distances += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
INCREASE_LZ_POS
|
INCREASE_LZ_POS
|
||||||
@@ -712,8 +758,12 @@ static UInt32 MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *distances)
|
|||||||
distances2 = p->MixMatchesFunc(p, p->lzPos - btBuf[1], distances);
|
distances2 = p->MixMatchesFunc(p, p->lzPos - btBuf[1], distances);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
*distances2++ = *btBuf++;
|
UInt32 v0 = btBuf[0];
|
||||||
*distances2++ = *btBuf++;
|
UInt32 v1 = btBuf[1];
|
||||||
|
btBuf += 2;
|
||||||
|
distances2[0] = v0;
|
||||||
|
distances2[1] = v1;
|
||||||
|
distances2 += 2;
|
||||||
}
|
}
|
||||||
while ((len -= 2) != 0);
|
while ((len -= 2) != 0);
|
||||||
len = (UInt32)(distances2 - (distances));
|
len = (UInt32)(distances2 - (distances));
|
||||||
@@ -777,7 +827,7 @@ void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable)
|
|||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
p->GetHeadsFunc = GetHeads2;
|
p->GetHeadsFunc = GetHeads2;
|
||||||
p->MixMatchesFunc = (Mf_Mix_Matches)0;
|
p->MixMatchesFunc = (Mf_Mix_Matches)NULL;
|
||||||
vTable->Skip = (Mf_Skip_Func)MatchFinderMt0_Skip;
|
vTable->Skip = (Mf_Skip_Func)MatchFinderMt0_Skip;
|
||||||
vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt2_GetMatches;
|
vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt2_GetMatches;
|
||||||
break;
|
break;
|
||||||
|
|||||||
14
C/LzFindMt.h
14
C/LzFindMt.h
@@ -1,5 +1,5 @@
|
|||||||
/* LzFindMt.h -- multithreaded Match finder for LZ algorithms
|
/* LzFindMt.h -- multithreaded Match finder for LZ algorithms
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZ_FIND_MT_H
|
#ifndef __LZ_FIND_MT_H
|
||||||
#define __LZ_FIND_MT_H
|
#define __LZ_FIND_MT_H
|
||||||
@@ -19,10 +19,10 @@ EXTERN_C_BEGIN
|
|||||||
|
|
||||||
typedef struct _CMtSync
|
typedef struct _CMtSync
|
||||||
{
|
{
|
||||||
Bool wasCreated;
|
BoolInt wasCreated;
|
||||||
Bool needStart;
|
BoolInt needStart;
|
||||||
Bool exit;
|
BoolInt exit;
|
||||||
Bool stopWriting;
|
BoolInt stopWriting;
|
||||||
|
|
||||||
CThread thread;
|
CThread thread;
|
||||||
CAutoResetEvent canStart;
|
CAutoResetEvent canStart;
|
||||||
@@ -30,8 +30,8 @@ typedef struct _CMtSync
|
|||||||
CAutoResetEvent wasStopped;
|
CAutoResetEvent wasStopped;
|
||||||
CSemaphore freeSemaphore;
|
CSemaphore freeSemaphore;
|
||||||
CSemaphore filledSemaphore;
|
CSemaphore filledSemaphore;
|
||||||
Bool csWasInitialized;
|
BoolInt csWasInitialized;
|
||||||
Bool csWasEntered;
|
BoolInt csWasEntered;
|
||||||
CCriticalSection cs;
|
CCriticalSection cs;
|
||||||
UInt32 numProcessedBlocks;
|
UInt32 numProcessedBlocks;
|
||||||
} CMtSync;
|
} CMtSync;
|
||||||
|
|||||||
206
C/Lzma2Dec.c
206
C/Lzma2Dec.c
@@ -1,5 +1,5 @@
|
|||||||
/* Lzma2Dec.c -- LZMA2 Decoder
|
/* Lzma2Dec.c -- LZMA2 Decoder
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2019-02-02 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
/* #define SHOW_DEBUG_INFO */
|
/* #define SHOW_DEBUG_INFO */
|
||||||
|
|
||||||
@@ -14,28 +14,22 @@
|
|||||||
#include "Lzma2Dec.h"
|
#include "Lzma2Dec.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
00000000 - EOS
|
00000000 - End of data
|
||||||
00000001 U U - Uncompressed Reset Dic
|
00000001 U U - Uncompressed, reset dic, need reset state and set new prop
|
||||||
00000010 U U - Uncompressed No Reset
|
00000010 U U - Uncompressed, no reset
|
||||||
100uuuuu U U P P - LZMA no reset
|
100uuuuu U U P P - LZMA, no reset
|
||||||
101uuuuu U U P P - LZMA reset state
|
101uuuuu U U P P - LZMA, reset state
|
||||||
110uuuuu U U P P S - LZMA reset state + new prop
|
110uuuuu U U P P S - LZMA, reset state + set new prop
|
||||||
111uuuuu U U P P S - LZMA reset state + new prop + reset dic
|
111uuuuu U U P P S - LZMA, reset state + set new prop, reset dic
|
||||||
|
|
||||||
u, U - Unpack Size
|
u, U - Unpack Size
|
||||||
P - Pack Size
|
P - Pack Size
|
||||||
S - Props
|
S - Props
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LZMA2_CONTROL_LZMA (1 << 7)
|
|
||||||
#define LZMA2_CONTROL_COPY_NO_RESET 2
|
|
||||||
#define LZMA2_CONTROL_COPY_RESET_DIC 1
|
#define LZMA2_CONTROL_COPY_RESET_DIC 1
|
||||||
#define LZMA2_CONTROL_EOF 0
|
|
||||||
|
|
||||||
#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & LZMA2_CONTROL_LZMA) == 0)
|
#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & (1 << 7)) == 0)
|
||||||
|
|
||||||
#define LZMA2_GET_LZMA_MODE(p) (((p)->control >> 5) & 3)
|
|
||||||
#define LZMA2_IS_THERE_PROP(mode) ((mode) >= 2)
|
|
||||||
|
|
||||||
#define LZMA2_LCLP_MAX 4
|
#define LZMA2_LCLP_MAX 4
|
||||||
#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11))
|
#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11))
|
||||||
@@ -91,9 +85,11 @@ SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc)
|
|||||||
void Lzma2Dec_Init(CLzma2Dec *p)
|
void Lzma2Dec_Init(CLzma2Dec *p)
|
||||||
{
|
{
|
||||||
p->state = LZMA2_STATE_CONTROL;
|
p->state = LZMA2_STATE_CONTROL;
|
||||||
p->needInitDic = True;
|
p->needInitLevel = 0xE0;
|
||||||
p->needInitState = True;
|
p->isExtraMode = False;
|
||||||
p->needInitProp = True;
|
p->unpackSize = 0;
|
||||||
|
|
||||||
|
// p->decoder.dicPos = 0; // we can use it instead of full init
|
||||||
LzmaDec_Init(&p->decoder);
|
LzmaDec_Init(&p->decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,19 +98,26 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
|||||||
switch (p->state)
|
switch (p->state)
|
||||||
{
|
{
|
||||||
case LZMA2_STATE_CONTROL:
|
case LZMA2_STATE_CONTROL:
|
||||||
|
p->isExtraMode = False;
|
||||||
p->control = b;
|
p->control = b;
|
||||||
PRF(printf("\n %4X ", (unsigned)p->decoder.dicPos));
|
PRF(printf("\n %8X", (unsigned)p->decoder.dicPos));
|
||||||
PRF(printf(" %2X", (unsigned)b));
|
PRF(printf(" %02X", (unsigned)b));
|
||||||
if (b == 0)
|
if (b == 0)
|
||||||
return LZMA2_STATE_FINISHED;
|
return LZMA2_STATE_FINISHED;
|
||||||
if (LZMA2_IS_UNCOMPRESSED_STATE(p))
|
if (LZMA2_IS_UNCOMPRESSED_STATE(p))
|
||||||
{
|
{
|
||||||
if (b > 2)
|
if (b == LZMA2_CONTROL_COPY_RESET_DIC)
|
||||||
|
p->needInitLevel = 0xC0;
|
||||||
|
else if (b > 2 || p->needInitLevel == 0xE0)
|
||||||
return LZMA2_STATE_ERROR;
|
return LZMA2_STATE_ERROR;
|
||||||
p->unpackSize = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (b < p->needInitLevel)
|
||||||
|
return LZMA2_STATE_ERROR;
|
||||||
|
p->needInitLevel = 0;
|
||||||
p->unpackSize = (UInt32)(b & 0x1F) << 16;
|
p->unpackSize = (UInt32)(b & 0x1F) << 16;
|
||||||
|
}
|
||||||
return LZMA2_STATE_UNPACK0;
|
return LZMA2_STATE_UNPACK0;
|
||||||
|
|
||||||
case LZMA2_STATE_UNPACK0:
|
case LZMA2_STATE_UNPACK0:
|
||||||
@@ -124,8 +127,8 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
|||||||
case LZMA2_STATE_UNPACK1:
|
case LZMA2_STATE_UNPACK1:
|
||||||
p->unpackSize |= (UInt32)b;
|
p->unpackSize |= (UInt32)b;
|
||||||
p->unpackSize++;
|
p->unpackSize++;
|
||||||
PRF(printf(" %8u", (unsigned)p->unpackSize));
|
PRF(printf(" %7u", (unsigned)p->unpackSize));
|
||||||
return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;
|
return LZMA2_IS_UNCOMPRESSED_STATE(p) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;
|
||||||
|
|
||||||
case LZMA2_STATE_PACK0:
|
case LZMA2_STATE_PACK0:
|
||||||
p->packSize = (UInt32)b << 8;
|
p->packSize = (UInt32)b << 8;
|
||||||
@@ -134,9 +137,9 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
|||||||
case LZMA2_STATE_PACK1:
|
case LZMA2_STATE_PACK1:
|
||||||
p->packSize |= (UInt32)b;
|
p->packSize |= (UInt32)b;
|
||||||
p->packSize++;
|
p->packSize++;
|
||||||
PRF(printf(" %8u", (unsigned)p->packSize));
|
// if (p->packSize < 5) return LZMA2_STATE_ERROR;
|
||||||
return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP:
|
PRF(printf(" %5u", (unsigned)p->packSize));
|
||||||
(p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA);
|
return (p->control & 0x40) ? LZMA2_STATE_PROP : LZMA2_STATE_DATA;
|
||||||
|
|
||||||
case LZMA2_STATE_PROP:
|
case LZMA2_STATE_PROP:
|
||||||
{
|
{
|
||||||
@@ -145,13 +148,12 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
|
|||||||
return LZMA2_STATE_ERROR;
|
return LZMA2_STATE_ERROR;
|
||||||
lc = b % 9;
|
lc = b % 9;
|
||||||
b /= 9;
|
b /= 9;
|
||||||
p->decoder.prop.pb = b / 5;
|
p->decoder.prop.pb = (Byte)(b / 5);
|
||||||
lp = b % 5;
|
lp = b % 5;
|
||||||
if (lc + lp > LZMA2_LCLP_MAX)
|
if (lc + lp > LZMA2_LCLP_MAX)
|
||||||
return LZMA2_STATE_ERROR;
|
return LZMA2_STATE_ERROR;
|
||||||
p->decoder.prop.lc = lc;
|
p->decoder.prop.lc = (Byte)lc;
|
||||||
p->decoder.prop.lp = lp;
|
p->decoder.prop.lp = (Byte)lp;
|
||||||
p->needInitProp = False;
|
|
||||||
return LZMA2_STATE_DATA;
|
return LZMA2_STATE_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,7 +169,7 @@ static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const Byte *src, SizeT s
|
|||||||
p->processedPos += (UInt32)size;
|
p->processedPos += (UInt32)size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState);
|
void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState);
|
||||||
|
|
||||||
|
|
||||||
SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
|
SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
|
||||||
@@ -230,12 +232,7 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
|
|||||||
|
|
||||||
if (p->state == LZMA2_STATE_DATA)
|
if (p->state == LZMA2_STATE_DATA)
|
||||||
{
|
{
|
||||||
Bool initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC);
|
BoolInt initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC);
|
||||||
if (initDic)
|
|
||||||
p->needInitProp = p->needInitState = True;
|
|
||||||
else if (p->needInitDic)
|
|
||||||
break;
|
|
||||||
p->needInitDic = False;
|
|
||||||
LzmaDec_InitDicAndState(&p->decoder, initDic, False);
|
LzmaDec_InitDicAndState(&p->decoder, initDic, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,15 +254,9 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
|
|||||||
|
|
||||||
if (p->state == LZMA2_STATE_DATA)
|
if (p->state == LZMA2_STATE_DATA)
|
||||||
{
|
{
|
||||||
unsigned mode = LZMA2_GET_LZMA_MODE(p);
|
BoolInt initDic = (p->control >= 0xE0);
|
||||||
Bool initDic = (mode == 3);
|
BoolInt initState = (p->control >= 0xA0);
|
||||||
Bool initState = (mode != 0);
|
|
||||||
if ((!initDic && p->needInitDic) || (!initState && p->needInitState))
|
|
||||||
break;
|
|
||||||
|
|
||||||
LzmaDec_InitDicAndState(&p->decoder, initDic, initState);
|
LzmaDec_InitDicAndState(&p->decoder, initDic, initState);
|
||||||
p->needInitDic = False;
|
|
||||||
p->needInitState = False;
|
|
||||||
p->state = LZMA2_STATE_DATA_CONT;
|
p->state = LZMA2_STATE_DATA_CONT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,6 +301,129 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p,
|
||||||
|
SizeT outSize,
|
||||||
|
const Byte *src, SizeT *srcLen,
|
||||||
|
int checkFinishBlock)
|
||||||
|
{
|
||||||
|
SizeT inSize = *srcLen;
|
||||||
|
*srcLen = 0;
|
||||||
|
|
||||||
|
while (p->state != LZMA2_STATE_ERROR)
|
||||||
|
{
|
||||||
|
if (p->state == LZMA2_STATE_FINISHED)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_FINISHED_WITH_MARK;
|
||||||
|
|
||||||
|
if (outSize == 0 && !checkFinishBlock)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED;
|
||||||
|
|
||||||
|
if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT)
|
||||||
|
{
|
||||||
|
if (*srcLen == inSize)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
|
(*srcLen)++;
|
||||||
|
|
||||||
|
p->state = Lzma2Dec_UpdateState(p, *src++);
|
||||||
|
|
||||||
|
if (p->state == LZMA2_STATE_UNPACK0)
|
||||||
|
{
|
||||||
|
// if (p->decoder.dicPos != 0)
|
||||||
|
if (p->control == LZMA2_CONTROL_COPY_RESET_DIC || p->control >= 0xE0)
|
||||||
|
return LZMA2_PARSE_STATUS_NEW_BLOCK;
|
||||||
|
// if (outSize == 0) return LZMA_STATUS_NOT_FINISHED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The following code can be commented.
|
||||||
|
// It's not big problem, if we read additional input bytes.
|
||||||
|
// It will be stopped later in LZMA2_STATE_DATA / LZMA2_STATE_DATA_CONT state.
|
||||||
|
|
||||||
|
if (outSize == 0 && p->state != LZMA2_STATE_FINISHED)
|
||||||
|
{
|
||||||
|
// checkFinishBlock is true. So we expect that block must be finished,
|
||||||
|
// We can return LZMA_STATUS_NOT_SPECIFIED or LZMA_STATUS_NOT_FINISHED here
|
||||||
|
// break;
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->state == LZMA2_STATE_DATA)
|
||||||
|
return LZMA2_PARSE_STATUS_NEW_CHUNK;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outSize == 0)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED;
|
||||||
|
|
||||||
|
{
|
||||||
|
SizeT inCur = inSize - *srcLen;
|
||||||
|
|
||||||
|
if (LZMA2_IS_UNCOMPRESSED_STATE(p))
|
||||||
|
{
|
||||||
|
if (inCur == 0)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
|
if (inCur > p->unpackSize)
|
||||||
|
inCur = p->unpackSize;
|
||||||
|
if (inCur > outSize)
|
||||||
|
inCur = outSize;
|
||||||
|
p->decoder.dicPos += inCur;
|
||||||
|
src += inCur;
|
||||||
|
*srcLen += inCur;
|
||||||
|
outSize -= inCur;
|
||||||
|
p->unpackSize -= (UInt32)inCur;
|
||||||
|
p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p->isExtraMode = True;
|
||||||
|
|
||||||
|
if (inCur == 0)
|
||||||
|
{
|
||||||
|
if (p->packSize != 0)
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
|
}
|
||||||
|
else if (p->state == LZMA2_STATE_DATA)
|
||||||
|
{
|
||||||
|
p->state = LZMA2_STATE_DATA_CONT;
|
||||||
|
if (*src != 0)
|
||||||
|
{
|
||||||
|
// first byte of lzma chunk must be Zero
|
||||||
|
*srcLen += 1;
|
||||||
|
p->packSize--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inCur > p->packSize)
|
||||||
|
inCur = (SizeT)p->packSize;
|
||||||
|
|
||||||
|
src += inCur;
|
||||||
|
*srcLen += inCur;
|
||||||
|
p->packSize -= (UInt32)inCur;
|
||||||
|
|
||||||
|
if (p->packSize == 0)
|
||||||
|
{
|
||||||
|
SizeT rem = outSize;
|
||||||
|
if (rem > p->unpackSize)
|
||||||
|
rem = p->unpackSize;
|
||||||
|
p->decoder.dicPos += rem;
|
||||||
|
p->unpackSize -= (UInt32)rem;
|
||||||
|
outSize -= rem;
|
||||||
|
if (p->unpackSize == 0)
|
||||||
|
p->state = LZMA2_STATE_CONTROL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p->state = LZMA2_STATE_ERROR;
|
||||||
|
return (ELzma2ParseStatus)LZMA_STATUS_NOT_SPECIFIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
|
SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
|
||||||
{
|
{
|
||||||
SizeT outSize = *destLen, inSize = *srcLen;
|
SizeT outSize = *destLen, inSize = *srcLen;
|
||||||
|
|||||||
60
C/Lzma2Dec.h
60
C/Lzma2Dec.h
@@ -1,5 +1,5 @@
|
|||||||
/* Lzma2Dec.h -- LZMA2 Decoder
|
/* Lzma2Dec.h -- LZMA2 Decoder
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-02-19 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA2_DEC_H
|
#ifndef __LZMA2_DEC_H
|
||||||
#define __LZMA2_DEC_H
|
#define __LZMA2_DEC_H
|
||||||
@@ -12,25 +12,24 @@ EXTERN_C_BEGIN
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CLzmaDec decoder;
|
|
||||||
UInt32 packSize;
|
|
||||||
UInt32 unpackSize;
|
|
||||||
unsigned state;
|
unsigned state;
|
||||||
Byte control;
|
Byte control;
|
||||||
Bool needInitDic;
|
Byte needInitLevel;
|
||||||
Bool needInitState;
|
Byte isExtraMode;
|
||||||
Bool needInitProp;
|
Byte _pad_;
|
||||||
|
UInt32 packSize;
|
||||||
|
UInt32 unpackSize;
|
||||||
|
CLzmaDec decoder;
|
||||||
} CLzma2Dec;
|
} CLzma2Dec;
|
||||||
|
|
||||||
#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder)
|
#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder)
|
||||||
#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc);
|
#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc)
|
||||||
#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc);
|
#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc)
|
||||||
|
|
||||||
SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc);
|
SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc);
|
||||||
SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc);
|
SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc);
|
||||||
void Lzma2Dec_Init(CLzma2Dec *p);
|
void Lzma2Dec_Init(CLzma2Dec *p);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
finishMode:
|
finishMode:
|
||||||
It has meaning only if the decoding reaches output limit (*destLen or dicLimit).
|
It has meaning only if the decoding reaches output limit (*destLen or dicLimit).
|
||||||
@@ -53,6 +52,47 @@ SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen,
|
|||||||
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- LZMA2 block and chunk parsing ---------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
Lzma2Dec_Parse() parses compressed data stream up to next independent block or next chunk data.
|
||||||
|
It can return LZMA_STATUS_* code or LZMA2_PARSE_STATUS_* code:
|
||||||
|
- LZMA2_PARSE_STATUS_NEW_BLOCK - there is new block, and 1 additional byte (control byte of next block header) was read from input.
|
||||||
|
- LZMA2_PARSE_STATUS_NEW_CHUNK - there is new chunk, and only lzma2 header of new chunk was read.
|
||||||
|
CLzma2Dec::unpackSize contains unpack size of that chunk
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
LZMA_STATUS_NOT_SPECIFIED // data error
|
||||||
|
LZMA_STATUS_FINISHED_WITH_MARK
|
||||||
|
LZMA_STATUS_NOT_FINISHED //
|
||||||
|
LZMA_STATUS_NEEDS_MORE_INPUT
|
||||||
|
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK // unused
|
||||||
|
*/
|
||||||
|
LZMA2_PARSE_STATUS_NEW_BLOCK = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK + 1,
|
||||||
|
LZMA2_PARSE_STATUS_NEW_CHUNK
|
||||||
|
} ELzma2ParseStatus;
|
||||||
|
|
||||||
|
ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p,
|
||||||
|
SizeT outSize, // output size
|
||||||
|
const Byte *src, SizeT *srcLen,
|
||||||
|
int checkFinishBlock // set (checkFinishBlock = 1), if it must read full input data, if decoder.dicPos reaches blockMax position.
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
LZMA2 parser doesn't decode LZMA chunks, so we must read
|
||||||
|
full input LZMA chunk to decode some part of LZMA chunk.
|
||||||
|
|
||||||
|
Lzma2Dec_GetUnpackExtra() returns the value that shows
|
||||||
|
max possible number of output bytes that can be output by decoder
|
||||||
|
at current input positon.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define Lzma2Dec_GetUnpackExtra(p) ((p)->isExtraMode ? (p)->unpackSize : 0);
|
||||||
|
|
||||||
|
|
||||||
/* ---------- One Call Interface ---------- */
|
/* ---------- One Call Interface ---------- */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
1082
C/Lzma2DecMt.c
Normal file
1082
C/Lzma2DecMt.c
Normal file
File diff suppressed because it is too large
Load Diff
79
C/Lzma2DecMt.h
Normal file
79
C/Lzma2DecMt.h
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/* Lzma2DecMt.h -- LZMA2 Decoder Multi-thread
|
||||||
|
2018-02-17 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __LZMA2_DEC_MT_H
|
||||||
|
#define __LZMA2_DEC_MT_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
size_t inBufSize_ST;
|
||||||
|
size_t outStep_ST;
|
||||||
|
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
unsigned numThreads;
|
||||||
|
size_t inBufSize_MT;
|
||||||
|
size_t outBlockMax;
|
||||||
|
size_t inBlockMax;
|
||||||
|
#endif
|
||||||
|
} CLzma2DecMtProps;
|
||||||
|
|
||||||
|
/* init to single-thread mode */
|
||||||
|
void Lzma2DecMtProps_Init(CLzma2DecMtProps *p);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- CLzma2DecMtHandle Interface ---------- */
|
||||||
|
|
||||||
|
/* Lzma2DecMt_ * functions can return the following exit codes:
|
||||||
|
SRes:
|
||||||
|
SZ_OK - OK
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_PARAM - Incorrect paramater in props
|
||||||
|
SZ_ERROR_WRITE - ISeqOutStream write callback error
|
||||||
|
// SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output
|
||||||
|
SZ_ERROR_PROGRESS - some break from progress callback
|
||||||
|
SZ_ERROR_THREAD - error in multithreading functions (only for Mt version)
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef void * CLzma2DecMtHandle;
|
||||||
|
|
||||||
|
CLzma2DecMtHandle Lzma2DecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid);
|
||||||
|
void Lzma2DecMt_Destroy(CLzma2DecMtHandle p);
|
||||||
|
|
||||||
|
SRes Lzma2DecMt_Decode(CLzma2DecMtHandle p,
|
||||||
|
Byte prop,
|
||||||
|
const CLzma2DecMtProps *props,
|
||||||
|
ISeqOutStream *outStream,
|
||||||
|
const UInt64 *outDataSize, // NULL means undefined
|
||||||
|
int finishMode, // 0 - partial unpacking is allowed, 1 - if lzma2 stream must be finished
|
||||||
|
// Byte *outBuf, size_t *outBufSize,
|
||||||
|
ISeqInStream *inStream,
|
||||||
|
// const Byte *inData, size_t inDataSize,
|
||||||
|
|
||||||
|
// out variables:
|
||||||
|
UInt64 *inProcessed,
|
||||||
|
int *isMT, /* out: (*isMT == 0), if single thread decoding was used */
|
||||||
|
|
||||||
|
// UInt64 *outProcessed,
|
||||||
|
ICompressProgress *progress);
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- Read from CLzma2DecMtHandle Interface ---------- */
|
||||||
|
|
||||||
|
SRes Lzma2DecMt_Init(CLzma2DecMtHandle pp,
|
||||||
|
Byte prop,
|
||||||
|
const CLzma2DecMtProps *props,
|
||||||
|
const UInt64 *outDataSize, int finishMode,
|
||||||
|
ISeqInStream *inStream);
|
||||||
|
|
||||||
|
SRes Lzma2DecMt_Read(CLzma2DecMtHandle pp,
|
||||||
|
Byte *data, size_t *outSize,
|
||||||
|
UInt64 *inStreamProcessed);
|
||||||
|
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
||||||
673
C/Lzma2Enc.c
673
C/Lzma2Enc.c
@@ -1,9 +1,8 @@
|
|||||||
/* Lzma2Enc.c -- LZMA2 Encoder
|
/* Lzma2Enc.c -- LZMA2 Encoder
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
/* #include <stdio.h> */
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* #define _7ZIP_ST */
|
/* #define _7ZIP_ST */
|
||||||
@@ -13,7 +12,7 @@
|
|||||||
#ifndef _7ZIP_ST
|
#ifndef _7ZIP_ST
|
||||||
#include "MtCoder.h"
|
#include "MtCoder.h"
|
||||||
#else
|
#else
|
||||||
#define NUM_MT_CODER_THREADS_MAX 1
|
#define MTCODER__THREADS_MAX 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LZMA2_CONTROL_LZMA (1 << 7)
|
#define LZMA2_CONTROL_LZMA (1 << 7)
|
||||||
@@ -35,41 +34,97 @@
|
|||||||
|
|
||||||
#define PRF(x) /* x */
|
#define PRF(x) /* x */
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- CLimitedSeqInStream ---------- */
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ISeqInStream vt;
|
||||||
|
ISeqInStream *realStream;
|
||||||
|
UInt64 limit;
|
||||||
|
UInt64 processed;
|
||||||
|
int finished;
|
||||||
|
} CLimitedSeqInStream;
|
||||||
|
|
||||||
|
static void LimitedSeqInStream_Init(CLimitedSeqInStream *p)
|
||||||
|
{
|
||||||
|
p->limit = (UInt64)(Int64)-1;
|
||||||
|
p->processed = 0;
|
||||||
|
p->finished = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SRes LimitedSeqInStream_Read(const ISeqInStream *pp, void *data, size_t *size)
|
||||||
|
{
|
||||||
|
CLimitedSeqInStream *p = CONTAINER_FROM_VTBL(pp, CLimitedSeqInStream, vt);
|
||||||
|
size_t size2 = *size;
|
||||||
|
SRes res = SZ_OK;
|
||||||
|
|
||||||
|
if (p->limit != (UInt64)(Int64)-1)
|
||||||
|
{
|
||||||
|
UInt64 rem = p->limit - p->processed;
|
||||||
|
if (size2 > rem)
|
||||||
|
size2 = (size_t)rem;
|
||||||
|
}
|
||||||
|
if (size2 != 0)
|
||||||
|
{
|
||||||
|
res = ISeqInStream_Read(p->realStream, data, &size2);
|
||||||
|
p->finished = (size2 == 0 ? 1 : 0);
|
||||||
|
p->processed += size2;
|
||||||
|
}
|
||||||
|
*size = size2;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ---------- CLzma2EncInt ---------- */
|
/* ---------- CLzma2EncInt ---------- */
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CLzmaEncHandle enc;
|
CLzmaEncHandle enc;
|
||||||
|
Byte propsAreSet;
|
||||||
|
Byte propsByte;
|
||||||
|
Byte needInitState;
|
||||||
|
Byte needInitProp;
|
||||||
UInt64 srcPos;
|
UInt64 srcPos;
|
||||||
Byte props;
|
|
||||||
Bool needInitState;
|
|
||||||
Bool needInitProp;
|
|
||||||
} CLzma2EncInt;
|
} CLzma2EncInt;
|
||||||
|
|
||||||
static SRes Lzma2EncInt_Init(CLzma2EncInt *p, const CLzma2EncProps *props)
|
|
||||||
|
static SRes Lzma2EncInt_InitStream(CLzma2EncInt *p, const CLzma2EncProps *props)
|
||||||
{
|
{
|
||||||
Byte propsEncoded[LZMA_PROPS_SIZE];
|
if (!p->propsAreSet)
|
||||||
SizeT propsSize = LZMA_PROPS_SIZE;
|
{
|
||||||
RINOK(LzmaEnc_SetProps(p->enc, &props->lzmaProps));
|
SizeT propsSize = LZMA_PROPS_SIZE;
|
||||||
RINOK(LzmaEnc_WriteProperties(p->enc, propsEncoded, &propsSize));
|
Byte propsEncoded[LZMA_PROPS_SIZE];
|
||||||
p->srcPos = 0;
|
RINOK(LzmaEnc_SetProps(p->enc, &props->lzmaProps));
|
||||||
p->props = propsEncoded[0];
|
RINOK(LzmaEnc_WriteProperties(p->enc, propsEncoded, &propsSize));
|
||||||
p->needInitState = True;
|
p->propsByte = propsEncoded[0];
|
||||||
p->needInitProp = True;
|
p->propsAreSet = True;
|
||||||
|
}
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Lzma2EncInt_InitBlock(CLzma2EncInt *p)
|
||||||
|
{
|
||||||
|
p->srcPos = 0;
|
||||||
|
p->needInitState = True;
|
||||||
|
p->needInitProp = True;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, ISeqInStream *inStream, UInt32 keepWindowSize,
|
SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, ISeqInStream *inStream, UInt32 keepWindowSize,
|
||||||
ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
||||||
SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
|
SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
|
||||||
UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
||||||
SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
|
SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,
|
||||||
Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize);
|
Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize);
|
||||||
const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp);
|
const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp);
|
||||||
void LzmaEnc_Finish(CLzmaEncHandle pp);
|
void LzmaEnc_Finish(CLzmaEncHandle pp);
|
||||||
void LzmaEnc_SaveState(CLzmaEncHandle pp);
|
void LzmaEnc_SaveState(CLzmaEncHandle pp);
|
||||||
void LzmaEnc_RestoreState(CLzmaEncHandle pp);
|
void LzmaEnc_RestoreState(CLzmaEncHandle pp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp);
|
||||||
|
*/
|
||||||
|
|
||||||
static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
|
static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
|
||||||
size_t *packSizeRes, ISeqOutStream *outStream)
|
size_t *packSizeRes, ISeqOutStream *outStream)
|
||||||
@@ -78,7 +133,7 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
|
|||||||
size_t packSize = packSizeLimit;
|
size_t packSize = packSizeLimit;
|
||||||
UInt32 unpackSize = LZMA2_UNPACK_SIZE_MAX;
|
UInt32 unpackSize = LZMA2_UNPACK_SIZE_MAX;
|
||||||
unsigned lzHeaderSize = 5 + (p->needInitProp ? 1 : 0);
|
unsigned lzHeaderSize = 5 + (p->needInitProp ? 1 : 0);
|
||||||
Bool useCopyBlock;
|
BoolInt useCopyBlock;
|
||||||
SRes res;
|
SRes res;
|
||||||
|
|
||||||
*packSizeRes = 0;
|
*packSizeRes = 0;
|
||||||
@@ -154,7 +209,7 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
|
|||||||
outBuf[destPos++] = (Byte)pm;
|
outBuf[destPos++] = (Byte)pm;
|
||||||
|
|
||||||
if (p->needInitProp)
|
if (p->needInitProp)
|
||||||
outBuf[destPos++] = p->props;
|
outBuf[destPos++] = p->propsByte;
|
||||||
|
|
||||||
p->needInitProp = False;
|
p->needInitProp = False;
|
||||||
p->needInitState = False;
|
p->needInitState = False;
|
||||||
@@ -176,14 +231,16 @@ static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,
|
|||||||
void Lzma2EncProps_Init(CLzma2EncProps *p)
|
void Lzma2EncProps_Init(CLzma2EncProps *p)
|
||||||
{
|
{
|
||||||
LzmaEncProps_Init(&p->lzmaProps);
|
LzmaEncProps_Init(&p->lzmaProps);
|
||||||
|
p->blockSize = LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO;
|
||||||
|
p->numBlockThreads_Reduced = -1;
|
||||||
|
p->numBlockThreads_Max = -1;
|
||||||
p->numTotalThreads = -1;
|
p->numTotalThreads = -1;
|
||||||
p->numBlockThreads = -1;
|
|
||||||
p->blockSize = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lzma2EncProps_Normalize(CLzma2EncProps *p)
|
void Lzma2EncProps_Normalize(CLzma2EncProps *p)
|
||||||
{
|
{
|
||||||
int t1, t1n, t2, t3;
|
UInt64 fileSize;
|
||||||
|
int t1, t1n, t2, t2r, t3;
|
||||||
{
|
{
|
||||||
CLzmaEncProps lzmaProps = p->lzmaProps;
|
CLzmaEncProps lzmaProps = p->lzmaProps;
|
||||||
LzmaEncProps_Normalize(&lzmaProps);
|
LzmaEncProps_Normalize(&lzmaProps);
|
||||||
@@ -191,11 +248,11 @@ void Lzma2EncProps_Normalize(CLzma2EncProps *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
t1 = p->lzmaProps.numThreads;
|
t1 = p->lzmaProps.numThreads;
|
||||||
t2 = p->numBlockThreads;
|
t2 = p->numBlockThreads_Max;
|
||||||
t3 = p->numTotalThreads;
|
t3 = p->numTotalThreads;
|
||||||
|
|
||||||
if (t2 > NUM_MT_CODER_THREADS_MAX)
|
if (t2 > MTCODER__THREADS_MAX)
|
||||||
t2 = NUM_MT_CODER_THREADS_MAX;
|
t2 = MTCODER__THREADS_MAX;
|
||||||
|
|
||||||
if (t3 <= 0)
|
if (t3 <= 0)
|
||||||
{
|
{
|
||||||
@@ -211,8 +268,8 @@ void Lzma2EncProps_Normalize(CLzma2EncProps *p)
|
|||||||
t1 = 1;
|
t1 = 1;
|
||||||
t2 = t3;
|
t2 = t3;
|
||||||
}
|
}
|
||||||
if (t2 > NUM_MT_CODER_THREADS_MAX)
|
if (t2 > MTCODER__THREADS_MAX)
|
||||||
t2 = NUM_MT_CODER_THREADS_MAX;
|
t2 = MTCODER__THREADS_MAX;
|
||||||
}
|
}
|
||||||
else if (t1 <= 0)
|
else if (t1 <= 0)
|
||||||
{
|
{
|
||||||
@@ -225,39 +282,64 @@ void Lzma2EncProps_Normalize(CLzma2EncProps *p)
|
|||||||
|
|
||||||
p->lzmaProps.numThreads = t1;
|
p->lzmaProps.numThreads = t1;
|
||||||
|
|
||||||
|
t2r = t2;
|
||||||
|
|
||||||
|
fileSize = p->lzmaProps.reduceSize;
|
||||||
|
|
||||||
|
if ( p->blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID
|
||||||
|
&& p->blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO
|
||||||
|
&& (p->blockSize < fileSize || fileSize == (UInt64)(Int64)-1))
|
||||||
|
p->lzmaProps.reduceSize = p->blockSize;
|
||||||
|
|
||||||
LzmaEncProps_Normalize(&p->lzmaProps);
|
LzmaEncProps_Normalize(&p->lzmaProps);
|
||||||
|
|
||||||
|
p->lzmaProps.reduceSize = fileSize;
|
||||||
|
|
||||||
t1 = p->lzmaProps.numThreads;
|
t1 = p->lzmaProps.numThreads;
|
||||||
|
|
||||||
if (p->blockSize == 0)
|
if (p->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID)
|
||||||
{
|
{
|
||||||
UInt32 dictSize = p->lzmaProps.dictSize;
|
t2r = t2 = 1;
|
||||||
UInt64 blockSize = (UInt64)dictSize << 2;
|
t3 = t1;
|
||||||
const UInt32 kMinSize = (UInt32)1 << 20;
|
|
||||||
const UInt32 kMaxSize = (UInt32)1 << 28;
|
|
||||||
if (blockSize < kMinSize) blockSize = kMinSize;
|
|
||||||
if (blockSize > kMaxSize) blockSize = kMaxSize;
|
|
||||||
if (blockSize < dictSize) blockSize = dictSize;
|
|
||||||
p->blockSize = (size_t)blockSize;
|
|
||||||
}
|
}
|
||||||
|
else if (p->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO && t2 <= 1)
|
||||||
if (t2 > 1 && p->lzmaProps.reduceSize != (UInt64)(Int64)-1)
|
|
||||||
{
|
{
|
||||||
UInt64 temp = p->lzmaProps.reduceSize + p->blockSize - 1;
|
/* if there is no block multi-threading, we use SOLID block */
|
||||||
if (temp > p->lzmaProps.reduceSize)
|
p->blockSize = LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (p->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO)
|
||||||
{
|
{
|
||||||
UInt64 numBlocks = temp / p->blockSize;
|
const UInt32 kMinSize = (UInt32)1 << 20;
|
||||||
|
const UInt32 kMaxSize = (UInt32)1 << 28;
|
||||||
|
const UInt32 dictSize = p->lzmaProps.dictSize;
|
||||||
|
UInt64 blockSize = (UInt64)dictSize << 2;
|
||||||
|
if (blockSize < kMinSize) blockSize = kMinSize;
|
||||||
|
if (blockSize > kMaxSize) blockSize = kMaxSize;
|
||||||
|
if (blockSize < dictSize) blockSize = dictSize;
|
||||||
|
blockSize += (kMinSize - 1);
|
||||||
|
blockSize &= ~(UInt64)(kMinSize - 1);
|
||||||
|
p->blockSize = blockSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t2 > 1 && fileSize != (UInt64)(Int64)-1)
|
||||||
|
{
|
||||||
|
UInt64 numBlocks = fileSize / p->blockSize;
|
||||||
|
if (numBlocks * p->blockSize != fileSize)
|
||||||
|
numBlocks++;
|
||||||
if (numBlocks < (unsigned)t2)
|
if (numBlocks < (unsigned)t2)
|
||||||
{
|
{
|
||||||
t2 = (unsigned)numBlocks;
|
t2r = (unsigned)numBlocks;
|
||||||
if (t2 == 0)
|
if (t2r == 0)
|
||||||
t2 = 1;
|
t2r = 1;
|
||||||
t3 = t1 * t2;
|
t3 = t1 * t2r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p->numBlockThreads = t2;
|
p->numBlockThreads_Max = t2;
|
||||||
|
p->numBlockThreads_Reduced = t2r;
|
||||||
p->numTotalThreads = t3;
|
p->numTotalThreads = t3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,134 +356,32 @@ typedef struct
|
|||||||
{
|
{
|
||||||
Byte propEncoded;
|
Byte propEncoded;
|
||||||
CLzma2EncProps props;
|
CLzma2EncProps props;
|
||||||
|
UInt64 expectedDataSize;
|
||||||
|
|
||||||
Byte *outBuf;
|
Byte *tempBufLzma;
|
||||||
|
|
||||||
ISzAllocPtr alloc;
|
ISzAllocPtr alloc;
|
||||||
ISzAllocPtr allocBig;
|
ISzAllocPtr allocBig;
|
||||||
|
|
||||||
CLzma2EncInt coders[NUM_MT_CODER_THREADS_MAX];
|
CLzma2EncInt coders[MTCODER__THREADS_MAX];
|
||||||
|
|
||||||
#ifndef _7ZIP_ST
|
#ifndef _7ZIP_ST
|
||||||
|
|
||||||
|
ISeqOutStream *outStream;
|
||||||
|
Byte *outBuf;
|
||||||
|
size_t outBuf_Rem; /* remainder in outBuf */
|
||||||
|
|
||||||
|
size_t outBufSize; /* size of allocated outBufs[i] */
|
||||||
|
size_t outBufsDataSizes[MTCODER__BLOCKS_MAX];
|
||||||
|
BoolInt mtCoder_WasConstructed;
|
||||||
CMtCoder mtCoder;
|
CMtCoder mtCoder;
|
||||||
|
Byte *outBufs[MTCODER__BLOCKS_MAX];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} CLzma2Enc;
|
} CLzma2Enc;
|
||||||
|
|
||||||
|
|
||||||
/* ---------- Lzma2EncThread ---------- */
|
|
||||||
|
|
||||||
static SRes Lzma2Enc_EncodeMt1(CLzma2EncInt *p, CLzma2Enc *mainEncoder,
|
|
||||||
ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress)
|
|
||||||
{
|
|
||||||
UInt64 packTotal = 0;
|
|
||||||
SRes res = SZ_OK;
|
|
||||||
|
|
||||||
if (!mainEncoder->outBuf)
|
|
||||||
{
|
|
||||||
mainEncoder->outBuf = (Byte *)ISzAlloc_Alloc(mainEncoder->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
|
|
||||||
if (!mainEncoder->outBuf)
|
|
||||||
return SZ_ERROR_MEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
RINOK(Lzma2EncInt_Init(p, &mainEncoder->props));
|
|
||||||
RINOK(LzmaEnc_PrepareForLzma2(p->enc, inStream, LZMA2_KEEP_WINDOW_SIZE,
|
|
||||||
mainEncoder->alloc, mainEncoder->allocBig));
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
size_t packSize = LZMA2_CHUNK_SIZE_COMPRESSED_MAX;
|
|
||||||
res = Lzma2EncInt_EncodeSubblock(p, mainEncoder->outBuf, &packSize, outStream);
|
|
||||||
if (res != SZ_OK)
|
|
||||||
break;
|
|
||||||
packTotal += packSize;
|
|
||||||
res = Progress(progress, p->srcPos, packTotal);
|
|
||||||
if (res != SZ_OK)
|
|
||||||
break;
|
|
||||||
if (packSize == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
LzmaEnc_Finish(p->enc);
|
|
||||||
|
|
||||||
if (res == SZ_OK)
|
|
||||||
{
|
|
||||||
Byte b = 0;
|
|
||||||
if (ISeqOutStream_Write(outStream, &b, 1) != 1)
|
|
||||||
return SZ_ERROR_WRITE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _7ZIP_ST
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
IMtCoderCallback funcTable;
|
|
||||||
CLzma2Enc *lzma2Enc;
|
|
||||||
} CMtCallbackImp;
|
|
||||||
|
|
||||||
static SRes MtCallbackImp_Code(const IMtCoderCallback *pp, unsigned index, Byte *dest, size_t *destSize,
|
|
||||||
const Byte *src, size_t srcSize, int finished)
|
|
||||||
{
|
|
||||||
CMtCallbackImp *imp = CONTAINER_FROM_VTBL(pp, CMtCallbackImp, funcTable);
|
|
||||||
CLzma2Enc *mainEncoder = imp->lzma2Enc;
|
|
||||||
CLzma2EncInt *p = &mainEncoder->coders[index];
|
|
||||||
|
|
||||||
SRes res = SZ_OK;
|
|
||||||
{
|
|
||||||
size_t destLim = *destSize;
|
|
||||||
*destSize = 0;
|
|
||||||
|
|
||||||
if (srcSize != 0)
|
|
||||||
{
|
|
||||||
RINOK(Lzma2EncInt_Init(p, &mainEncoder->props));
|
|
||||||
|
|
||||||
RINOK(LzmaEnc_MemPrepare(p->enc, src, srcSize, LZMA2_KEEP_WINDOW_SIZE,
|
|
||||||
mainEncoder->alloc, mainEncoder->allocBig));
|
|
||||||
|
|
||||||
while (p->srcPos < srcSize)
|
|
||||||
{
|
|
||||||
size_t packSize = destLim - *destSize;
|
|
||||||
res = Lzma2EncInt_EncodeSubblock(p, dest + *destSize, &packSize, NULL);
|
|
||||||
if (res != SZ_OK)
|
|
||||||
break;
|
|
||||||
*destSize += packSize;
|
|
||||||
|
|
||||||
if (packSize == 0)
|
|
||||||
{
|
|
||||||
res = SZ_ERROR_FAIL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MtProgress_Set(&mainEncoder->mtCoder.mtProgress, index, p->srcPos, *destSize) != SZ_OK)
|
|
||||||
{
|
|
||||||
res = SZ_ERROR_PROGRESS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LzmaEnc_Finish(p->enc);
|
|
||||||
if (res != SZ_OK)
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (finished)
|
|
||||||
{
|
|
||||||
if (*destSize == destLim)
|
|
||||||
return SZ_ERROR_OUTPUT_EOF;
|
|
||||||
dest[(*destSize)++] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------- Lzma2Enc ---------- */
|
|
||||||
|
|
||||||
CLzma2EncHandle Lzma2Enc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig)
|
CLzma2EncHandle Lzma2Enc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig)
|
||||||
{
|
{
|
||||||
@@ -410,44 +390,78 @@ CLzma2EncHandle Lzma2Enc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig)
|
|||||||
return NULL;
|
return NULL;
|
||||||
Lzma2EncProps_Init(&p->props);
|
Lzma2EncProps_Init(&p->props);
|
||||||
Lzma2EncProps_Normalize(&p->props);
|
Lzma2EncProps_Normalize(&p->props);
|
||||||
p->outBuf = 0;
|
p->expectedDataSize = (UInt64)(Int64)-1;
|
||||||
|
p->tempBufLzma = NULL;
|
||||||
p->alloc = alloc;
|
p->alloc = alloc;
|
||||||
p->allocBig = allocBig;
|
p->allocBig = allocBig;
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
|
for (i = 0; i < MTCODER__THREADS_MAX; i++)
|
||||||
p->coders[i].enc = 0;
|
p->coders[i].enc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _7ZIP_ST
|
#ifndef _7ZIP_ST
|
||||||
MtCoder_Construct(&p->mtCoder);
|
p->mtCoder_WasConstructed = False;
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
for (i = 0; i < MTCODER__BLOCKS_MAX; i++)
|
||||||
|
p->outBufs[i] = NULL;
|
||||||
|
p->outBufSize = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
|
||||||
|
static void Lzma2Enc_FreeOutBufs(CLzma2Enc *p)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
for (i = 0; i < MTCODER__BLOCKS_MAX; i++)
|
||||||
|
if (p->outBufs[i])
|
||||||
|
{
|
||||||
|
ISzAlloc_Free(p->alloc, p->outBufs[i]);
|
||||||
|
p->outBufs[i] = NULL;
|
||||||
|
}
|
||||||
|
p->outBufSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void Lzma2Enc_Destroy(CLzma2EncHandle pp)
|
void Lzma2Enc_Destroy(CLzma2EncHandle pp)
|
||||||
{
|
{
|
||||||
CLzma2Enc *p = (CLzma2Enc *)pp;
|
CLzma2Enc *p = (CLzma2Enc *)pp;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
|
for (i = 0; i < MTCODER__THREADS_MAX; i++)
|
||||||
{
|
{
|
||||||
CLzma2EncInt *t = &p->coders[i];
|
CLzma2EncInt *t = &p->coders[i];
|
||||||
if (t->enc)
|
if (t->enc)
|
||||||
{
|
{
|
||||||
LzmaEnc_Destroy(t->enc, p->alloc, p->allocBig);
|
LzmaEnc_Destroy(t->enc, p->alloc, p->allocBig);
|
||||||
t->enc = 0;
|
t->enc = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef _7ZIP_ST
|
#ifndef _7ZIP_ST
|
||||||
MtCoder_Destruct(&p->mtCoder);
|
if (p->mtCoder_WasConstructed)
|
||||||
|
{
|
||||||
|
MtCoder_Destruct(&p->mtCoder);
|
||||||
|
p->mtCoder_WasConstructed = False;
|
||||||
|
}
|
||||||
|
Lzma2Enc_FreeOutBufs(p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ISzAlloc_Free(p->alloc, p->outBuf);
|
ISzAlloc_Free(p->alloc, p->tempBufLzma);
|
||||||
|
p->tempBufLzma = NULL;
|
||||||
|
|
||||||
ISzAlloc_Free(p->alloc, pp);
|
ISzAlloc_Free(p->alloc, pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SRes Lzma2Enc_SetProps(CLzma2EncHandle pp, const CLzma2EncProps *props)
|
SRes Lzma2Enc_SetProps(CLzma2EncHandle pp, const CLzma2EncProps *props)
|
||||||
{
|
{
|
||||||
CLzma2Enc *p = (CLzma2Enc *)pp;
|
CLzma2Enc *p = (CLzma2Enc *)pp;
|
||||||
@@ -460,6 +474,14 @@ SRes Lzma2Enc_SetProps(CLzma2EncHandle pp, const CLzma2EncProps *props)
|
|||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Lzma2Enc_SetDataSize(CLzmaEncHandle pp, UInt64 expectedDataSiize)
|
||||||
|
{
|
||||||
|
CLzma2Enc *p = (CLzma2Enc *)pp;
|
||||||
|
p->expectedDataSize = expectedDataSiize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Byte Lzma2Enc_WriteProperties(CLzma2EncHandle pp)
|
Byte Lzma2Enc_WriteProperties(CLzma2EncHandle pp)
|
||||||
{
|
{
|
||||||
CLzma2Enc *p = (CLzma2Enc *)pp;
|
CLzma2Enc *p = (CLzma2Enc *)pp;
|
||||||
@@ -471,50 +493,311 @@ Byte Lzma2Enc_WriteProperties(CLzma2EncHandle pp)
|
|||||||
return (Byte)i;
|
return (Byte)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRes Lzma2Enc_Encode(CLzma2EncHandle pp,
|
|
||||||
ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress)
|
|
||||||
{
|
|
||||||
CLzma2Enc *p = (CLzma2Enc *)pp;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < p->props.numBlockThreads; i++)
|
static SRes Lzma2Enc_EncodeMt1(
|
||||||
|
CLzma2Enc *me,
|
||||||
|
CLzma2EncInt *p,
|
||||||
|
ISeqOutStream *outStream,
|
||||||
|
Byte *outBuf, size_t *outBufSize,
|
||||||
|
ISeqInStream *inStream,
|
||||||
|
const Byte *inData, size_t inDataSize,
|
||||||
|
int finished,
|
||||||
|
ICompressProgress *progress)
|
||||||
|
{
|
||||||
|
UInt64 unpackTotal = 0;
|
||||||
|
UInt64 packTotal = 0;
|
||||||
|
size_t outLim = 0;
|
||||||
|
CLimitedSeqInStream limitedInStream;
|
||||||
|
|
||||||
|
if (outBuf)
|
||||||
{
|
{
|
||||||
CLzma2EncInt *t = &p->coders[(unsigned)i];
|
outLim = *outBufSize;
|
||||||
if (!t->enc)
|
*outBufSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!p->enc)
|
||||||
|
{
|
||||||
|
p->propsAreSet = False;
|
||||||
|
p->enc = LzmaEnc_Create(me->alloc);
|
||||||
|
if (!p->enc)
|
||||||
|
return SZ_ERROR_MEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
limitedInStream.realStream = inStream;
|
||||||
|
if (inStream)
|
||||||
|
{
|
||||||
|
limitedInStream.vt.Read = LimitedSeqInStream_Read;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!outBuf)
|
||||||
|
{
|
||||||
|
// outStream version works only in one thread. So we use CLzma2Enc::tempBufLzma
|
||||||
|
if (!me->tempBufLzma)
|
||||||
{
|
{
|
||||||
t->enc = LzmaEnc_Create(p->alloc);
|
me->tempBufLzma = (Byte *)ISzAlloc_Alloc(me->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
|
||||||
if (!t->enc)
|
if (!me->tempBufLzma)
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _7ZIP_ST
|
RINOK(Lzma2EncInt_InitStream(p, &me->props));
|
||||||
if (p->props.numBlockThreads > 1)
|
|
||||||
|
for (;;)
|
||||||
{
|
{
|
||||||
CMtCallbackImp mtCallback;
|
SRes res = SZ_OK;
|
||||||
|
size_t inSizeCur = 0;
|
||||||
|
|
||||||
mtCallback.funcTable.Code = MtCallbackImp_Code;
|
Lzma2EncInt_InitBlock(p);
|
||||||
mtCallback.lzma2Enc = p;
|
|
||||||
|
|
||||||
|
LimitedSeqInStream_Init(&limitedInStream);
|
||||||
|
limitedInStream.limit = me->props.blockSize;
|
||||||
|
|
||||||
|
if (inStream)
|
||||||
|
{
|
||||||
|
UInt64 expected = (UInt64)(Int64)-1;
|
||||||
|
// inStream version works only in one thread. So we use CLzma2Enc::expectedDataSize
|
||||||
|
if (me->expectedDataSize != (UInt64)(Int64)-1
|
||||||
|
&& me->expectedDataSize >= unpackTotal)
|
||||||
|
expected = me->expectedDataSize - unpackTotal;
|
||||||
|
if (me->props.blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID
|
||||||
|
&& expected > me->props.blockSize)
|
||||||
|
expected = (size_t)me->props.blockSize;
|
||||||
|
|
||||||
|
LzmaEnc_SetDataSize(p->enc, expected);
|
||||||
|
|
||||||
|
RINOK(LzmaEnc_PrepareForLzma2(p->enc,
|
||||||
|
&limitedInStream.vt,
|
||||||
|
LZMA2_KEEP_WINDOW_SIZE,
|
||||||
|
me->alloc,
|
||||||
|
me->allocBig));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inSizeCur = inDataSize - (size_t)unpackTotal;
|
||||||
|
if (me->props.blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID
|
||||||
|
&& inSizeCur > me->props.blockSize)
|
||||||
|
inSizeCur = (size_t)me->props.blockSize;
|
||||||
|
|
||||||
|
// LzmaEnc_SetDataSize(p->enc, inSizeCur);
|
||||||
|
|
||||||
|
RINOK(LzmaEnc_MemPrepare(p->enc,
|
||||||
|
inData + (size_t)unpackTotal, inSizeCur,
|
||||||
|
LZMA2_KEEP_WINDOW_SIZE,
|
||||||
|
me->alloc,
|
||||||
|
me->allocBig));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
size_t packSize = LZMA2_CHUNK_SIZE_COMPRESSED_MAX;
|
||||||
|
if (outBuf)
|
||||||
|
packSize = outLim - (size_t)packTotal;
|
||||||
|
|
||||||
|
res = Lzma2EncInt_EncodeSubblock(p,
|
||||||
|
outBuf ? outBuf + (size_t)packTotal : me->tempBufLzma, &packSize,
|
||||||
|
outBuf ? NULL : outStream);
|
||||||
|
|
||||||
|
if (res != SZ_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
packTotal += packSize;
|
||||||
|
if (outBuf)
|
||||||
|
*outBufSize = (size_t)packTotal;
|
||||||
|
|
||||||
|
res = Progress(progress, unpackTotal + p->srcPos, packTotal);
|
||||||
|
if (res != SZ_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (LzmaEnc_GetNumAvailableBytes(p->enc) == 0)
|
||||||
|
break;
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (packSize == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LzmaEnc_Finish(p->enc);
|
||||||
|
|
||||||
|
unpackTotal += p->srcPos;
|
||||||
|
|
||||||
|
RINOK(res);
|
||||||
|
|
||||||
|
if (p->srcPos != (inStream ? limitedInStream.processed : inSizeCur))
|
||||||
|
return SZ_ERROR_FAIL;
|
||||||
|
|
||||||
|
if (inStream ? limitedInStream.finished : (unpackTotal == inDataSize))
|
||||||
|
{
|
||||||
|
if (finished)
|
||||||
|
{
|
||||||
|
if (outBuf)
|
||||||
|
{
|
||||||
|
size_t destPos = *outBufSize;
|
||||||
|
if (destPos >= outLim)
|
||||||
|
return SZ_ERROR_OUTPUT_EOF;
|
||||||
|
outBuf[destPos] = 0;
|
||||||
|
*outBufSize = destPos + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Byte b = 0;
|
||||||
|
if (ISeqOutStream_Write(outStream, &b, 1) != 1)
|
||||||
|
return SZ_ERROR_WRITE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
|
||||||
|
static SRes Lzma2Enc_MtCallback_Code(void *pp, unsigned coderIndex, unsigned outBufIndex,
|
||||||
|
const Byte *src, size_t srcSize, int finished)
|
||||||
|
{
|
||||||
|
CLzma2Enc *me = (CLzma2Enc *)pp;
|
||||||
|
size_t destSize = me->outBufSize;
|
||||||
|
SRes res;
|
||||||
|
CMtProgressThunk progressThunk;
|
||||||
|
|
||||||
|
Byte *dest = me->outBufs[outBufIndex];
|
||||||
|
|
||||||
|
me->outBufsDataSizes[outBufIndex] = 0;
|
||||||
|
|
||||||
|
if (!dest)
|
||||||
|
{
|
||||||
|
dest = (Byte *)ISzAlloc_Alloc(me->alloc, me->outBufSize);
|
||||||
|
if (!dest)
|
||||||
|
return SZ_ERROR_MEM;
|
||||||
|
me->outBufs[outBufIndex] = dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
MtProgressThunk_CreateVTable(&progressThunk);
|
||||||
|
progressThunk.mtProgress = &me->mtCoder.mtProgress;
|
||||||
|
progressThunk.inSize = 0;
|
||||||
|
progressThunk.outSize = 0;
|
||||||
|
|
||||||
|
res = Lzma2Enc_EncodeMt1(me,
|
||||||
|
&me->coders[coderIndex],
|
||||||
|
NULL, dest, &destSize,
|
||||||
|
NULL, src, srcSize,
|
||||||
|
finished,
|
||||||
|
&progressThunk.vt);
|
||||||
|
|
||||||
|
me->outBufsDataSizes[outBufIndex] = destSize;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static SRes Lzma2Enc_MtCallback_Write(void *pp, unsigned outBufIndex)
|
||||||
|
{
|
||||||
|
CLzma2Enc *me = (CLzma2Enc *)pp;
|
||||||
|
size_t size = me->outBufsDataSizes[outBufIndex];
|
||||||
|
const Byte *data = me->outBufs[outBufIndex];
|
||||||
|
|
||||||
|
if (me->outStream)
|
||||||
|
return ISeqOutStream_Write(me->outStream, data, size) == size ? SZ_OK : SZ_ERROR_WRITE;
|
||||||
|
|
||||||
|
if (size > me->outBuf_Rem)
|
||||||
|
return SZ_ERROR_OUTPUT_EOF;
|
||||||
|
memcpy(me->outBuf, data, size);
|
||||||
|
me->outBuf_Rem -= size;
|
||||||
|
me->outBuf += size;
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SRes Lzma2Enc_Encode2(CLzma2EncHandle pp,
|
||||||
|
ISeqOutStream *outStream,
|
||||||
|
Byte *outBuf, size_t *outBufSize,
|
||||||
|
ISeqInStream *inStream,
|
||||||
|
const Byte *inData, size_t inDataSize,
|
||||||
|
ICompressProgress *progress)
|
||||||
|
{
|
||||||
|
CLzma2Enc *p = (CLzma2Enc *)pp;
|
||||||
|
|
||||||
|
if (inStream && inData)
|
||||||
|
return SZ_ERROR_PARAM;
|
||||||
|
|
||||||
|
if (outStream && outBuf)
|
||||||
|
return SZ_ERROR_PARAM;
|
||||||
|
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
for (i = 0; i < MTCODER__THREADS_MAX; i++)
|
||||||
|
p->coders[i].propsAreSet = False;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
|
||||||
|
if (p->props.numBlockThreads_Reduced > 1)
|
||||||
|
{
|
||||||
|
IMtCoderCallback2 vt;
|
||||||
|
|
||||||
|
if (!p->mtCoder_WasConstructed)
|
||||||
|
{
|
||||||
|
p->mtCoder_WasConstructed = True;
|
||||||
|
MtCoder_Construct(&p->mtCoder);
|
||||||
|
}
|
||||||
|
|
||||||
|
vt.Code = Lzma2Enc_MtCallback_Code;
|
||||||
|
vt.Write = Lzma2Enc_MtCallback_Write;
|
||||||
|
|
||||||
|
p->outStream = outStream;
|
||||||
|
p->outBuf = NULL;
|
||||||
|
p->outBuf_Rem = 0;
|
||||||
|
if (!outStream)
|
||||||
|
{
|
||||||
|
p->outBuf = outBuf;
|
||||||
|
p->outBuf_Rem = *outBufSize;
|
||||||
|
*outBufSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->mtCoder.allocBig = p->allocBig;
|
||||||
p->mtCoder.progress = progress;
|
p->mtCoder.progress = progress;
|
||||||
p->mtCoder.inStream = inStream;
|
p->mtCoder.inStream = inStream;
|
||||||
p->mtCoder.outStream = outStream;
|
p->mtCoder.inData = inData;
|
||||||
p->mtCoder.alloc = p->alloc;
|
p->mtCoder.inDataSize = inDataSize;
|
||||||
p->mtCoder.mtCallback = &mtCallback.funcTable;
|
p->mtCoder.mtCallback = &vt;
|
||||||
|
p->mtCoder.mtCallbackObject = p;
|
||||||
|
|
||||||
|
p->mtCoder.blockSize = (size_t)p->props.blockSize;
|
||||||
|
if (p->mtCoder.blockSize != p->props.blockSize)
|
||||||
|
return SZ_ERROR_PARAM; /* SZ_ERROR_MEM */
|
||||||
|
|
||||||
p->mtCoder.blockSize = p->props.blockSize;
|
|
||||||
p->mtCoder.destBlockSize = p->props.blockSize + (p->props.blockSize >> 10) + 16;
|
|
||||||
if (p->mtCoder.destBlockSize < p->props.blockSize)
|
|
||||||
{
|
{
|
||||||
p->mtCoder.destBlockSize = (size_t)0 - 1;
|
size_t destBlockSize = p->mtCoder.blockSize + (p->mtCoder.blockSize >> 10) + 16;
|
||||||
if (p->mtCoder.destBlockSize < p->props.blockSize)
|
if (destBlockSize < p->mtCoder.blockSize)
|
||||||
return SZ_ERROR_FAIL;
|
return SZ_ERROR_PARAM;
|
||||||
|
if (p->outBufSize != destBlockSize)
|
||||||
|
Lzma2Enc_FreeOutBufs(p);
|
||||||
|
p->outBufSize = destBlockSize;
|
||||||
}
|
}
|
||||||
p->mtCoder.numThreads = p->props.numBlockThreads;
|
|
||||||
|
|
||||||
return MtCoder_Code(&p->mtCoder);
|
p->mtCoder.numThreadsMax = p->props.numBlockThreads_Max;
|
||||||
|
p->mtCoder.expectedDataSize = p->expectedDataSize;
|
||||||
|
|
||||||
|
{
|
||||||
|
SRes res = MtCoder_Code(&p->mtCoder);
|
||||||
|
if (!outStream)
|
||||||
|
*outBufSize = p->outBuf - outBuf;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return Lzma2Enc_EncodeMt1(&p->coders[0], p, outStream, inStream, progress);
|
|
||||||
|
return Lzma2Enc_EncodeMt1(p,
|
||||||
|
&p->coders[0],
|
||||||
|
outStream, outBuf, outBufSize,
|
||||||
|
inStream, inData, inDataSize,
|
||||||
|
True, /* finished */
|
||||||
|
progress);
|
||||||
}
|
}
|
||||||
|
|||||||
43
C/Lzma2Enc.h
43
C/Lzma2Enc.h
@@ -1,5 +1,5 @@
|
|||||||
/* Lzma2Enc.h -- LZMA2 Encoder
|
/* Lzma2Enc.h -- LZMA2 Encoder
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2017-07-27 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA2_ENC_H
|
#ifndef __LZMA2_ENC_H
|
||||||
#define __LZMA2_ENC_H
|
#define __LZMA2_ENC_H
|
||||||
@@ -8,11 +8,15 @@
|
|||||||
|
|
||||||
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
#define LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO 0
|
||||||
|
#define LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID ((UInt64)(Int64)-1)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CLzmaEncProps lzmaProps;
|
CLzmaEncProps lzmaProps;
|
||||||
size_t blockSize;
|
UInt64 blockSize;
|
||||||
int numBlockThreads;
|
int numBlockThreads_Reduced;
|
||||||
|
int numBlockThreads_Max;
|
||||||
int numTotalThreads;
|
int numTotalThreads;
|
||||||
} CLzma2EncProps;
|
} CLzma2EncProps;
|
||||||
|
|
||||||
@@ -22,13 +26,14 @@ void Lzma2EncProps_Normalize(CLzma2EncProps *p);
|
|||||||
/* ---------- CLzmaEnc2Handle Interface ---------- */
|
/* ---------- CLzmaEnc2Handle Interface ---------- */
|
||||||
|
|
||||||
/* Lzma2Enc_* functions can return the following exit codes:
|
/* Lzma2Enc_* functions can return the following exit codes:
|
||||||
Returns:
|
SRes:
|
||||||
SZ_OK - OK
|
SZ_OK - OK
|
||||||
SZ_ERROR_MEM - Memory allocation error
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
SZ_ERROR_PARAM - Incorrect paramater in props
|
SZ_ERROR_PARAM - Incorrect paramater in props
|
||||||
SZ_ERROR_WRITE - Write callback error
|
SZ_ERROR_WRITE - ISeqOutStream write callback error
|
||||||
|
SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output
|
||||||
SZ_ERROR_PROGRESS - some break from progress callback
|
SZ_ERROR_PROGRESS - some break from progress callback
|
||||||
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
|
SZ_ERROR_THREAD - error in multithreading functions (only for Mt version)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef void * CLzma2EncHandle;
|
typedef void * CLzma2EncHandle;
|
||||||
@@ -36,26 +41,14 @@ typedef void * CLzma2EncHandle;
|
|||||||
CLzma2EncHandle Lzma2Enc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
CLzma2EncHandle Lzma2Enc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
||||||
void Lzma2Enc_Destroy(CLzma2EncHandle p);
|
void Lzma2Enc_Destroy(CLzma2EncHandle p);
|
||||||
SRes Lzma2Enc_SetProps(CLzma2EncHandle p, const CLzma2EncProps *props);
|
SRes Lzma2Enc_SetProps(CLzma2EncHandle p, const CLzma2EncProps *props);
|
||||||
|
void Lzma2Enc_SetDataSize(CLzma2EncHandle p, UInt64 expectedDataSiize);
|
||||||
Byte Lzma2Enc_WriteProperties(CLzma2EncHandle p);
|
Byte Lzma2Enc_WriteProperties(CLzma2EncHandle p);
|
||||||
SRes Lzma2Enc_Encode(CLzma2EncHandle p,
|
SRes Lzma2Enc_Encode2(CLzma2EncHandle p,
|
||||||
ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress);
|
ISeqOutStream *outStream,
|
||||||
|
Byte *outBuf, size_t *outBufSize,
|
||||||
/* ---------- One Call Interface ---------- */
|
ISeqInStream *inStream,
|
||||||
|
const Byte *inData, size_t inDataSize,
|
||||||
/* Lzma2Encode
|
ICompressProgress *progress);
|
||||||
Return code:
|
|
||||||
SZ_OK - OK
|
|
||||||
SZ_ERROR_MEM - Memory allocation error
|
|
||||||
SZ_ERROR_PARAM - Incorrect paramater
|
|
||||||
SZ_ERROR_OUTPUT_EOF - output buffer overflow
|
|
||||||
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
SRes Lzma2Encode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
|
||||||
const CLzmaEncProps *props, Byte *propsEncoded, int writeEndMark,
|
|
||||||
ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
|
||||||
*/
|
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
|
/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
|
||||||
2016-05-16 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
|
|||||||
{
|
{
|
||||||
size_t outSize2 = *destLen;
|
size_t outSize2 = *destLen;
|
||||||
Byte *filteredStream;
|
Byte *filteredStream;
|
||||||
Bool useFilter;
|
BoolInt useFilter;
|
||||||
int mainResult = SZ_ERROR_OUTPUT_EOF;
|
int mainResult = SZ_ERROR_OUTPUT_EOF;
|
||||||
CLzmaEncProps props;
|
CLzmaEncProps props;
|
||||||
LzmaEncProps_Init(&props);
|
LzmaEncProps_Init(&props);
|
||||||
@@ -56,7 +56,7 @@ int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
|
|||||||
|
|
||||||
{
|
{
|
||||||
size_t minSize = 0;
|
size_t minSize = 0;
|
||||||
Bool bestIsFiltered = False;
|
BoolInt bestIsFiltered = False;
|
||||||
|
|
||||||
/* passes for SZ_FILTER_AUTO:
|
/* passes for SZ_FILTER_AUTO:
|
||||||
0 - BCJ + LZMA
|
0 - BCJ + LZMA
|
||||||
@@ -71,7 +71,7 @@ int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
|
|||||||
size_t outSizeProcessed = outSize2 - LZMA86_HEADER_SIZE;
|
size_t outSizeProcessed = outSize2 - LZMA86_HEADER_SIZE;
|
||||||
size_t outPropsSize = 5;
|
size_t outPropsSize = 5;
|
||||||
SRes curRes;
|
SRes curRes;
|
||||||
Bool curModeIsFiltered = (numPasses > 1 && i == numPasses - 1);
|
BoolInt curModeIsFiltered = (numPasses > 1 && i == numPasses - 1);
|
||||||
if (curModeIsFiltered && !bestIsFiltered)
|
if (curModeIsFiltered && !bestIsFiltered)
|
||||||
break;
|
break;
|
||||||
if (useFilter && i == 0)
|
if (useFilter && i == 0)
|
||||||
|
|||||||
407
C/LzmaDec.c
407
C/LzmaDec.c
@@ -1,12 +1,13 @@
|
|||||||
/* LzmaDec.c -- LZMA Decoder
|
/* LzmaDec.c -- LZMA Decoder
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "LzmaDec.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* #include "CpuArch.h" */
|
||||||
|
#include "LzmaDec.h"
|
||||||
|
|
||||||
#define kNumTopBits 24
|
#define kNumTopBits 24
|
||||||
#define kTopValue ((UInt32)1 << kNumTopBits)
|
#define kTopValue ((UInt32)1 << kNumTopBits)
|
||||||
|
|
||||||
@@ -18,15 +19,22 @@
|
|||||||
|
|
||||||
#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
|
#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
|
||||||
|
|
||||||
#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
|
#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)
|
||||||
#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
|
#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
|
||||||
#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
|
#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
|
||||||
#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
|
#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
|
||||||
{ UPDATE_0(p); i = (i + i); A0; } else \
|
{ UPDATE_0(p); i = (i + i); A0; } else \
|
||||||
{ UPDATE_1(p); i = (i + i) + 1; A1; }
|
{ UPDATE_1(p); i = (i + i) + 1; A1; }
|
||||||
#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;)
|
|
||||||
|
|
||||||
#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); }
|
#define TREE_GET_BIT(probs, i) { GET_BIT2(probs + i, i, ;, ;); }
|
||||||
|
|
||||||
|
#define REV_BIT(p, i, A0, A1) IF_BIT_0(p + i) \
|
||||||
|
{ UPDATE_0(p + i); A0; } else \
|
||||||
|
{ UPDATE_1(p + i); A1; }
|
||||||
|
#define REV_BIT_VAR( p, i, m) REV_BIT(p, i, i += m; m += m, m += m; i += m; )
|
||||||
|
#define REV_BIT_CONST(p, i, m) REV_BIT(p, i, i += m; , i += m * 2; )
|
||||||
|
#define REV_BIT_LAST( p, i, m) REV_BIT(p, i, i -= m , ; )
|
||||||
|
|
||||||
#define TREE_DECODE(probs, limit, i) \
|
#define TREE_DECODE(probs, limit, i) \
|
||||||
{ i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }
|
{ i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }
|
||||||
|
|
||||||
@@ -46,16 +54,19 @@
|
|||||||
i -= 0x40; }
|
i -= 0x40; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NORMAL_LITER_DEC GET_BIT(prob + symbol, symbol)
|
#define NORMAL_LITER_DEC TREE_GET_BIT(prob, symbol)
|
||||||
#define MATCHED_LITER_DEC \
|
#define MATCHED_LITER_DEC \
|
||||||
matchByte <<= 1; \
|
matchByte += matchByte; \
|
||||||
bit = (matchByte & offs); \
|
bit = offs; \
|
||||||
probLit = prob + offs + bit + symbol; \
|
offs &= matchByte; \
|
||||||
GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
|
probLit = prob + (offs + bit + symbol); \
|
||||||
|
GET_BIT2(probLit, symbol, 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) * (UInt32)ttt; if (code < bound)
|
||||||
#define UPDATE_0_CHECK range = bound;
|
#define UPDATE_0_CHECK range = bound;
|
||||||
#define UPDATE_1_CHECK range -= bound; code -= bound;
|
#define UPDATE_1_CHECK range -= bound; code -= bound;
|
||||||
#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
|
#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
|
||||||
@@ -66,25 +77,28 @@
|
|||||||
{ i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
|
{ i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
|
||||||
|
|
||||||
|
|
||||||
|
#define REV_BIT_CHECK(p, i, m) IF_BIT_0_CHECK(p + i) \
|
||||||
|
{ UPDATE_0_CHECK; i += m; m += m; } else \
|
||||||
|
{ UPDATE_1_CHECK; m += m; i += m; }
|
||||||
|
|
||||||
|
|
||||||
#define kNumPosBitsMax 4
|
#define kNumPosBitsMax 4
|
||||||
#define kNumPosStatesMax (1 << kNumPosBitsMax)
|
#define kNumPosStatesMax (1 << kNumPosBitsMax)
|
||||||
|
|
||||||
#define kLenNumLowBits 3
|
#define kLenNumLowBits 3
|
||||||
#define kLenNumLowSymbols (1 << kLenNumLowBits)
|
#define kLenNumLowSymbols (1 << kLenNumLowBits)
|
||||||
#define kLenNumMidBits 3
|
|
||||||
#define kLenNumMidSymbols (1 << kLenNumMidBits)
|
|
||||||
#define kLenNumHighBits 8
|
#define kLenNumHighBits 8
|
||||||
#define kLenNumHighSymbols (1 << kLenNumHighBits)
|
#define kLenNumHighSymbols (1 << kLenNumHighBits)
|
||||||
|
|
||||||
#define LenChoice 0
|
#define LenLow 0
|
||||||
#define LenChoice2 (LenChoice + 1)
|
#define LenHigh (LenLow + 2 * (kNumPosStatesMax << kLenNumLowBits))
|
||||||
#define LenLow (LenChoice2 + 1)
|
|
||||||
#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
|
|
||||||
#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
|
|
||||||
#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
|
#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
|
||||||
|
|
||||||
|
#define LenChoice LenLow
|
||||||
|
#define LenChoice2 (LenLow + (1 << kLenNumLowBits))
|
||||||
|
|
||||||
#define kNumStates 12
|
#define kNumStates 12
|
||||||
|
#define kNumStates2 16
|
||||||
#define kNumLitStates 7
|
#define kNumLitStates 7
|
||||||
|
|
||||||
#define kStartPosModelIndex 4
|
#define kStartPosModelIndex 4
|
||||||
@@ -98,54 +112,117 @@
|
|||||||
#define kAlignTableSize (1 << kNumAlignBits)
|
#define kAlignTableSize (1 << kNumAlignBits)
|
||||||
|
|
||||||
#define kMatchMinLen 2
|
#define kMatchMinLen 2
|
||||||
#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
|
#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols * 2 + kLenNumHighSymbols)
|
||||||
|
|
||||||
#define IsMatch 0
|
/* External ASM code needs same CLzmaProb array layout. So don't change it. */
|
||||||
#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
|
|
||||||
|
/* (probs_1664) is faster and better for code size at some platforms */
|
||||||
|
/*
|
||||||
|
#ifdef MY_CPU_X86_OR_AMD64
|
||||||
|
*/
|
||||||
|
#define kStartOffset 1664
|
||||||
|
#define GET_PROBS p->probs_1664
|
||||||
|
/*
|
||||||
|
#define GET_PROBS p->probs + kStartOffset
|
||||||
|
#else
|
||||||
|
#define kStartOffset 0
|
||||||
|
#define GET_PROBS p->probs
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SpecPos (-kStartOffset)
|
||||||
|
#define IsRep0Long (SpecPos + kNumFullDistances)
|
||||||
|
#define RepLenCoder (IsRep0Long + (kNumStates2 << kNumPosBitsMax))
|
||||||
|
#define LenCoder (RepLenCoder + kNumLenProbs)
|
||||||
|
#define IsMatch (LenCoder + kNumLenProbs)
|
||||||
|
#define Align (IsMatch + (kNumStates2 << kNumPosBitsMax))
|
||||||
|
#define IsRep (Align + kAlignTableSize)
|
||||||
#define IsRepG0 (IsRep + kNumStates)
|
#define IsRepG0 (IsRep + kNumStates)
|
||||||
#define IsRepG1 (IsRepG0 + kNumStates)
|
#define IsRepG1 (IsRepG0 + kNumStates)
|
||||||
#define IsRepG2 (IsRepG1 + kNumStates)
|
#define IsRepG2 (IsRepG1 + kNumStates)
|
||||||
#define IsRep0Long (IsRepG2 + kNumStates)
|
#define PosSlot (IsRepG2 + kNumStates)
|
||||||
#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
|
#define Literal (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
|
||||||
#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
|
#define NUM_BASE_PROBS (Literal + kStartOffset)
|
||||||
#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
|
|
||||||
#define LenCoder (Align + kAlignTableSize)
|
|
||||||
#define RepLenCoder (LenCoder + kNumLenProbs)
|
|
||||||
#define Literal (RepLenCoder + kNumLenProbs)
|
|
||||||
|
|
||||||
#define LZMA_BASE_SIZE 1846
|
#if Align != 0 && kStartOffset != 0
|
||||||
#define LZMA_LIT_SIZE 0x300
|
#error Stop_Compiling_Bad_LZMA_kAlign
|
||||||
|
|
||||||
#if Literal != LZMA_BASE_SIZE
|
|
||||||
StopCompilingDueBUG
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LzmaProps_GetNumProbs(p) (Literal + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
|
#if NUM_BASE_PROBS != 1984
|
||||||
|
#error Stop_Compiling_Bad_LZMA_PROBS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define LZMA_LIT_SIZE 0x300
|
||||||
|
|
||||||
|
#define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
|
||||||
|
|
||||||
|
|
||||||
|
#define CALC_POS_STATE(processedPos, pbMask) (((processedPos) & (pbMask)) << 4)
|
||||||
|
#define COMBINED_PS_STATE (posState + state)
|
||||||
|
#define GET_LEN_STATE (posState)
|
||||||
|
|
||||||
#define LZMA_DIC_MIN (1 << 12)
|
#define LZMA_DIC_MIN (1 << 12)
|
||||||
|
|
||||||
/* First LZMA-symbol is always decoded.
|
/*
|
||||||
And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization
|
p->remainLen : shows status of LZMA decoder:
|
||||||
|
< kMatchSpecLenStart : normal remain
|
||||||
|
= kMatchSpecLenStart : finished
|
||||||
|
= kMatchSpecLenStart + 1 : need init range coder
|
||||||
|
= kMatchSpecLenStart + 2 : need init range coder and state
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ---------- LZMA_DECODE_REAL ---------- */
|
||||||
|
/*
|
||||||
|
LzmaDec_DecodeReal_3() can be implemented in external ASM file.
|
||||||
|
3 - is the code compatibility version of that function for check at link time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LZMA_DECODE_REAL LzmaDec_DecodeReal_3
|
||||||
|
|
||||||
|
/*
|
||||||
|
LZMA_DECODE_REAL()
|
||||||
|
In:
|
||||||
|
RangeCoder is normalized
|
||||||
|
if (p->dicPos == limit)
|
||||||
|
{
|
||||||
|
LzmaDec_TryDummy() was called before to exclude LITERAL and MATCH-REP cases.
|
||||||
|
So first symbol can be only MATCH-NON-REP. And if that MATCH-NON-REP symbol
|
||||||
|
is not END_OF_PAYALOAD_MARKER, then function returns error code.
|
||||||
|
}
|
||||||
|
|
||||||
|
Processing:
|
||||||
|
first LZMA symbol will be decoded in any case
|
||||||
|
All checks for limits are at the end of main loop,
|
||||||
|
It will decode new LZMA-symbols while (p->buf < bufLimit && dicPos < limit),
|
||||||
|
RangeCoder is still without last normalization when (p->buf < bufLimit) is being checked.
|
||||||
|
|
||||||
Out:
|
Out:
|
||||||
|
RangeCoder is normalized
|
||||||
Result:
|
Result:
|
||||||
SZ_OK - OK
|
SZ_OK - OK
|
||||||
SZ_ERROR_DATA - Error
|
SZ_ERROR_DATA - Error
|
||||||
p->remainLen:
|
p->remainLen:
|
||||||
< kMatchSpecLenStart : normal remain
|
< kMatchSpecLenStart : normal remain
|
||||||
= kMatchSpecLenStart : finished
|
= kMatchSpecLenStart : finished
|
||||||
= kMatchSpecLenStart + 1 : Flush marker (unused now)
|
|
||||||
= kMatchSpecLenStart + 2 : State Init Marker (unused now)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
|
|
||||||
{
|
|
||||||
CLzmaProb *probs = p->probs;
|
|
||||||
|
|
||||||
unsigned state = p->state;
|
#ifdef _LZMA_DEC_OPT
|
||||||
|
|
||||||
|
int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static
|
||||||
|
int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
|
||||||
|
{
|
||||||
|
CLzmaProb *probs = GET_PROBS;
|
||||||
|
unsigned state = (unsigned)p->state;
|
||||||
UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
|
UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
|
||||||
unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
|
unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
|
||||||
unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1;
|
|
||||||
unsigned lc = p->prop.lc;
|
unsigned lc = p->prop.lc;
|
||||||
|
unsigned lpMask = ((unsigned)0x100 << p->prop.lp) - ((unsigned)0x100 >> lc);
|
||||||
|
|
||||||
Byte *dic = p->dic;
|
Byte *dic = p->dic;
|
||||||
SizeT dicBufSize = p->dicBufSize;
|
SizeT dicBufSize = p->dicBufSize;
|
||||||
@@ -164,17 +241,16 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
CLzmaProb *prob;
|
CLzmaProb *prob;
|
||||||
UInt32 bound;
|
UInt32 bound;
|
||||||
unsigned ttt;
|
unsigned ttt;
|
||||||
unsigned posState = processedPos & pbMask;
|
unsigned posState = CALC_POS_STATE(processedPos, pbMask);
|
||||||
|
|
||||||
prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
|
prob = probs + IsMatch + COMBINED_PS_STATE;
|
||||||
IF_BIT_0(prob)
|
IF_BIT_0(prob)
|
||||||
{
|
{
|
||||||
unsigned symbol;
|
unsigned symbol;
|
||||||
UPDATE_0(prob);
|
UPDATE_0(prob);
|
||||||
prob = probs + Literal;
|
prob = probs + Literal;
|
||||||
if (processedPos != 0 || checkDicSize != 0)
|
if (processedPos != 0 || checkDicSize != 0)
|
||||||
prob += ((UInt32)LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) +
|
prob += (UInt32)3 * ((((processedPos << 8) + dic[(dicPos == 0 ? dicBufSize : dicPos) - 1]) & lpMask) << lc);
|
||||||
(dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc))));
|
|
||||||
processedPos++;
|
processedPos++;
|
||||||
|
|
||||||
if (state < kNumLitStates)
|
if (state < kNumLitStates)
|
||||||
@@ -240,13 +316,16 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
UPDATE_1(prob);
|
UPDATE_1(prob);
|
||||||
|
/*
|
||||||
|
// that case was checked before with kBadRepCode
|
||||||
if (checkDicSize == 0 && processedPos == 0)
|
if (checkDicSize == 0 && processedPos == 0)
|
||||||
return SZ_ERROR_DATA;
|
return SZ_ERROR_DATA;
|
||||||
|
*/
|
||||||
prob = probs + IsRepG0 + state;
|
prob = probs + IsRepG0 + state;
|
||||||
IF_BIT_0(prob)
|
IF_BIT_0(prob)
|
||||||
{
|
{
|
||||||
UPDATE_0(prob);
|
UPDATE_0(prob);
|
||||||
prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
|
prob = probs + IsRep0Long + COMBINED_PS_STATE;
|
||||||
IF_BIT_0(prob)
|
IF_BIT_0(prob)
|
||||||
{
|
{
|
||||||
UPDATE_0(prob);
|
UPDATE_0(prob);
|
||||||
@@ -299,7 +378,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
IF_BIT_0(probLen)
|
IF_BIT_0(probLen)
|
||||||
{
|
{
|
||||||
UPDATE_0(probLen);
|
UPDATE_0(probLen);
|
||||||
probLen = prob + LenLow + (posState << kLenNumLowBits);
|
probLen = prob + LenLow + GET_LEN_STATE;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
lim = (1 << kLenNumLowBits);
|
lim = (1 << kLenNumLowBits);
|
||||||
}
|
}
|
||||||
@@ -310,15 +389,15 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
IF_BIT_0(probLen)
|
IF_BIT_0(probLen)
|
||||||
{
|
{
|
||||||
UPDATE_0(probLen);
|
UPDATE_0(probLen);
|
||||||
probLen = prob + LenMid + (posState << kLenNumMidBits);
|
probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits);
|
||||||
offset = kLenNumLowSymbols;
|
offset = kLenNumLowSymbols;
|
||||||
lim = (1 << kLenNumMidBits);
|
lim = (1 << kLenNumLowBits);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UPDATE_1(probLen);
|
UPDATE_1(probLen);
|
||||||
probLen = prob + LenHigh;
|
probLen = prob + LenHigh;
|
||||||
offset = kLenNumLowSymbols + kLenNumMidSymbols;
|
offset = kLenNumLowSymbols * 2;
|
||||||
lim = (1 << kLenNumHighBits);
|
lim = (1 << kLenNumHighBits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -331,7 +410,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
IF_BIT_0(probLen)
|
IF_BIT_0(probLen)
|
||||||
{
|
{
|
||||||
UPDATE_0(probLen);
|
UPDATE_0(probLen);
|
||||||
probLen = prob + LenLow + (posState << kLenNumLowBits);
|
probLen = prob + LenLow + GET_LEN_STATE;
|
||||||
len = 1;
|
len = 1;
|
||||||
TREE_GET_BIT(probLen, len);
|
TREE_GET_BIT(probLen, len);
|
||||||
TREE_GET_BIT(probLen, len);
|
TREE_GET_BIT(probLen, len);
|
||||||
@@ -345,7 +424,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
IF_BIT_0(probLen)
|
IF_BIT_0(probLen)
|
||||||
{
|
{
|
||||||
UPDATE_0(probLen);
|
UPDATE_0(probLen);
|
||||||
probLen = prob + LenMid + (posState << kLenNumMidBits);
|
probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits);
|
||||||
len = 1;
|
len = 1;
|
||||||
TREE_GET_BIT(probLen, len);
|
TREE_GET_BIT(probLen, len);
|
||||||
TREE_GET_BIT(probLen, len);
|
TREE_GET_BIT(probLen, len);
|
||||||
@@ -356,7 +435,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
UPDATE_1(probLen);
|
UPDATE_1(probLen);
|
||||||
probLen = prob + LenHigh;
|
probLen = prob + LenHigh;
|
||||||
TREE_DECODE(probLen, (1 << kLenNumHighBits), len);
|
TREE_DECODE(probLen, (1 << kLenNumHighBits), len);
|
||||||
len += kLenNumLowSymbols + kLenNumMidSymbols;
|
len += kLenNumLowSymbols * 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,16 +455,16 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
if (posSlot < kEndPosModelIndex)
|
if (posSlot < kEndPosModelIndex)
|
||||||
{
|
{
|
||||||
distance <<= numDirectBits;
|
distance <<= numDirectBits;
|
||||||
prob = probs + SpecPos + distance - posSlot - 1;
|
prob = probs + SpecPos;
|
||||||
{
|
{
|
||||||
UInt32 mask = 1;
|
UInt32 m = 1;
|
||||||
unsigned i = 1;
|
distance++;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
GET_BIT2(prob + i, i, ; , distance |= mask);
|
REV_BIT_VAR(prob, distance, m);
|
||||||
mask <<= 1;
|
|
||||||
}
|
}
|
||||||
while (--numDirectBits != 0);
|
while (--numDirectBits);
|
||||||
|
distance -= m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -412,19 +491,20 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
while (--numDirectBits != 0);
|
while (--numDirectBits);
|
||||||
prob = probs + Align;
|
prob = probs + Align;
|
||||||
distance <<= kNumAlignBits;
|
distance <<= kNumAlignBits;
|
||||||
{
|
{
|
||||||
unsigned i = 1;
|
unsigned i = 1;
|
||||||
GET_BIT2(prob + i, i, ; , distance |= 1);
|
REV_BIT_CONST(prob, i, 1);
|
||||||
GET_BIT2(prob + i, i, ; , distance |= 2);
|
REV_BIT_CONST(prob, i, 2);
|
||||||
GET_BIT2(prob + i, i, ; , distance |= 4);
|
REV_BIT_CONST(prob, i, 4);
|
||||||
GET_BIT2(prob + i, i, ; , distance |= 8);
|
REV_BIT_LAST (prob, i, 8);
|
||||||
|
distance |= i;
|
||||||
}
|
}
|
||||||
if (distance == (UInt32)0xFFFFFFFF)
|
if (distance == (UInt32)0xFFFFFFFF)
|
||||||
{
|
{
|
||||||
len += kMatchSpecLenStart;
|
len = kMatchSpecLenStart;
|
||||||
state -= kNumStates;
|
state -= kNumStates;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -435,20 +515,12 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
rep2 = rep1;
|
rep2 = rep1;
|
||||||
rep1 = rep0;
|
rep1 = rep0;
|
||||||
rep0 = distance + 1;
|
rep0 = distance + 1;
|
||||||
if (checkDicSize == 0)
|
state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;
|
||||||
{
|
if (distance >= (checkDicSize == 0 ? processedPos: checkDicSize))
|
||||||
if (distance >= processedPos)
|
|
||||||
{
|
|
||||||
p->dicPos = dicPos;
|
|
||||||
return SZ_ERROR_DATA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (distance >= checkDicSize)
|
|
||||||
{
|
{
|
||||||
p->dicPos = dicPos;
|
p->dicPos = dicPos;
|
||||||
return SZ_ERROR_DATA;
|
return SZ_ERROR_DATA;
|
||||||
}
|
}
|
||||||
state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
len += kMatchMinLen;
|
len += kMatchMinLen;
|
||||||
@@ -467,7 +539,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
curLen = ((rem < len) ? (unsigned)rem : len);
|
curLen = ((rem < len) ? (unsigned)rem : len);
|
||||||
pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0);
|
pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0);
|
||||||
|
|
||||||
processedPos += curLen;
|
processedPos += (UInt32)curLen;
|
||||||
|
|
||||||
len -= curLen;
|
len -= curLen;
|
||||||
if (curLen <= dicBufSize - pos)
|
if (curLen <= dicBufSize - pos)
|
||||||
@@ -475,7 +547,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
Byte *dest = dic + dicPos;
|
Byte *dest = dic + dicPos;
|
||||||
ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
|
ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
|
||||||
const Byte *lim = dest + curLen;
|
const Byte *lim = dest + curLen;
|
||||||
dicPos += curLen;
|
dicPos += (SizeT)curLen;
|
||||||
do
|
do
|
||||||
*(dest) = (Byte)*(dest + src);
|
*(dest) = (Byte)*(dest + src);
|
||||||
while (++dest != lim);
|
while (++dest != lim);
|
||||||
@@ -500,17 +572,18 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
p->buf = buf;
|
p->buf = buf;
|
||||||
p->range = range;
|
p->range = range;
|
||||||
p->code = code;
|
p->code = code;
|
||||||
p->remainLen = len;
|
p->remainLen = (UInt32)len;
|
||||||
p->dicPos = dicPos;
|
p->dicPos = dicPos;
|
||||||
p->processedPos = processedPos;
|
p->processedPos = processedPos;
|
||||||
p->reps[0] = rep0;
|
p->reps[0] = rep0;
|
||||||
p->reps[1] = rep1;
|
p->reps[1] = rep1;
|
||||||
p->reps[2] = rep2;
|
p->reps[2] = rep2;
|
||||||
p->reps[3] = rep3;
|
p->reps[3] = rep3;
|
||||||
p->state = state;
|
p->state = (UInt32)state;
|
||||||
|
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
|
static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
|
||||||
{
|
{
|
||||||
@@ -519,7 +592,7 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
|
|||||||
Byte *dic = p->dic;
|
Byte *dic = p->dic;
|
||||||
SizeT dicPos = p->dicPos;
|
SizeT dicPos = p->dicPos;
|
||||||
SizeT dicBufSize = p->dicBufSize;
|
SizeT dicBufSize = p->dicBufSize;
|
||||||
unsigned len = p->remainLen;
|
unsigned len = (unsigned)p->remainLen;
|
||||||
SizeT rep0 = p->reps[0]; /* we use SizeT to avoid the BUG of VC14 for AMD64 */
|
SizeT rep0 = p->reps[0]; /* we use SizeT to avoid the BUG of VC14 for AMD64 */
|
||||||
SizeT rem = limit - dicPos;
|
SizeT rem = limit - dicPos;
|
||||||
if (rem < len)
|
if (rem < len)
|
||||||
@@ -528,8 +601,8 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
|
|||||||
if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
|
if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
|
||||||
p->checkDicSize = p->prop.dicSize;
|
p->checkDicSize = p->prop.dicSize;
|
||||||
|
|
||||||
p->processedPos += len;
|
p->processedPos += (UInt32)len;
|
||||||
p->remainLen -= len;
|
p->remainLen -= (UInt32)len;
|
||||||
while (len != 0)
|
while (len != 0)
|
||||||
{
|
{
|
||||||
len--;
|
len--;
|
||||||
@@ -540,6 +613,14 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define kRange0 0xFFFFFFFF
|
||||||
|
#define kBound0 ((kRange0 >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1))
|
||||||
|
#define kBadRepCode (kBound0 + (((kRange0 - kBound0) >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1)))
|
||||||
|
#if kBadRepCode != (0xC0000000 - 0x400)
|
||||||
|
#error Stop_Compiling_Bad_LZMA_Check
|
||||||
|
#endif
|
||||||
|
|
||||||
static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
|
static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
@@ -550,9 +631,13 @@ static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
UInt32 rem = p->prop.dicSize - p->processedPos;
|
UInt32 rem = p->prop.dicSize - p->processedPos;
|
||||||
if (limit - p->dicPos > rem)
|
if (limit - p->dicPos > rem)
|
||||||
limit2 = p->dicPos + rem;
|
limit2 = p->dicPos + rem;
|
||||||
|
|
||||||
|
if (p->processedPos == 0)
|
||||||
|
if (p->code >= kBadRepCode)
|
||||||
|
return SZ_ERROR_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit));
|
RINOK(LZMA_DECODE_REAL(p, limit2, bufLimit));
|
||||||
|
|
||||||
if (p->checkDicSize == 0 && p->processedPos >= p->prop.dicSize)
|
if (p->checkDicSize == 0 && p->processedPos >= p->prop.dicSize)
|
||||||
p->checkDicSize = p->prop.dicSize;
|
p->checkDicSize = p->prop.dicSize;
|
||||||
@@ -561,9 +646,6 @@ static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte
|
|||||||
}
|
}
|
||||||
while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
|
while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
|
||||||
|
|
||||||
if (p->remainLen > kMatchSpecLenStart)
|
|
||||||
p->remainLen = kMatchSpecLenStart;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,17 +662,17 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
|
|||||||
UInt32 range = p->range;
|
UInt32 range = p->range;
|
||||||
UInt32 code = p->code;
|
UInt32 code = p->code;
|
||||||
const Byte *bufLimit = buf + inSize;
|
const Byte *bufLimit = buf + inSize;
|
||||||
const CLzmaProb *probs = p->probs;
|
const CLzmaProb *probs = GET_PROBS;
|
||||||
unsigned state = p->state;
|
unsigned state = (unsigned)p->state;
|
||||||
ELzmaDummy res;
|
ELzmaDummy res;
|
||||||
|
|
||||||
{
|
{
|
||||||
const CLzmaProb *prob;
|
const CLzmaProb *prob;
|
||||||
UInt32 bound;
|
UInt32 bound;
|
||||||
unsigned ttt;
|
unsigned ttt;
|
||||||
unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1);
|
unsigned posState = CALC_POS_STATE(p->processedPos, (1 << p->prop.pb) - 1);
|
||||||
|
|
||||||
prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
|
prob = probs + IsMatch + COMBINED_PS_STATE;
|
||||||
IF_BIT_0_CHECK(prob)
|
IF_BIT_0_CHECK(prob)
|
||||||
{
|
{
|
||||||
UPDATE_0_CHECK
|
UPDATE_0_CHECK
|
||||||
@@ -618,10 +700,11 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
|
|||||||
{
|
{
|
||||||
unsigned bit;
|
unsigned bit;
|
||||||
const CLzmaProb *probLit;
|
const CLzmaProb *probLit;
|
||||||
matchByte <<= 1;
|
matchByte += matchByte;
|
||||||
bit = (matchByte & offs);
|
bit = offs;
|
||||||
probLit = prob + offs + bit + symbol;
|
offs &= matchByte;
|
||||||
GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit)
|
probLit = prob + (offs + bit + symbol);
|
||||||
|
GET_BIT2_CHECK(probLit, symbol, offs ^= bit; , ; )
|
||||||
}
|
}
|
||||||
while (symbol < 0x100);
|
while (symbol < 0x100);
|
||||||
}
|
}
|
||||||
@@ -648,7 +731,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
|
|||||||
IF_BIT_0_CHECK(prob)
|
IF_BIT_0_CHECK(prob)
|
||||||
{
|
{
|
||||||
UPDATE_0_CHECK;
|
UPDATE_0_CHECK;
|
||||||
prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
|
prob = probs + IsRep0Long + COMBINED_PS_STATE;
|
||||||
IF_BIT_0_CHECK(prob)
|
IF_BIT_0_CHECK(prob)
|
||||||
{
|
{
|
||||||
UPDATE_0_CHECK;
|
UPDATE_0_CHECK;
|
||||||
@@ -691,7 +774,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
|
|||||||
IF_BIT_0_CHECK(probLen)
|
IF_BIT_0_CHECK(probLen)
|
||||||
{
|
{
|
||||||
UPDATE_0_CHECK;
|
UPDATE_0_CHECK;
|
||||||
probLen = prob + LenLow + (posState << kLenNumLowBits);
|
probLen = prob + LenLow + GET_LEN_STATE;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
limit = 1 << kLenNumLowBits;
|
limit = 1 << kLenNumLowBits;
|
||||||
}
|
}
|
||||||
@@ -702,15 +785,15 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
|
|||||||
IF_BIT_0_CHECK(probLen)
|
IF_BIT_0_CHECK(probLen)
|
||||||
{
|
{
|
||||||
UPDATE_0_CHECK;
|
UPDATE_0_CHECK;
|
||||||
probLen = prob + LenMid + (posState << kLenNumMidBits);
|
probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits);
|
||||||
offset = kLenNumLowSymbols;
|
offset = kLenNumLowSymbols;
|
||||||
limit = 1 << kLenNumMidBits;
|
limit = 1 << kLenNumLowBits;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UPDATE_1_CHECK;
|
UPDATE_1_CHECK;
|
||||||
probLen = prob + LenHigh;
|
probLen = prob + LenHigh;
|
||||||
offset = kLenNumLowSymbols + kLenNumMidSymbols;
|
offset = kLenNumLowSymbols * 2;
|
||||||
limit = 1 << kLenNumHighBits;
|
limit = 1 << kLenNumHighBits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -722,7 +805,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
|
|||||||
{
|
{
|
||||||
unsigned posSlot;
|
unsigned posSlot;
|
||||||
prob = probs + PosSlot +
|
prob = probs + PosSlot +
|
||||||
((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
|
((len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) <<
|
||||||
kNumPosSlotBits);
|
kNumPosSlotBits);
|
||||||
TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);
|
TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);
|
||||||
if (posSlot >= kStartPosModelIndex)
|
if (posSlot >= kStartPosModelIndex)
|
||||||
@@ -733,7 +816,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
|
|||||||
|
|
||||||
if (posSlot < kEndPosModelIndex)
|
if (posSlot < kEndPosModelIndex)
|
||||||
{
|
{
|
||||||
prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1;
|
prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -745,17 +828,18 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
|
|||||||
code -= range & (((code - range) >> 31) - 1);
|
code -= range & (((code - range) >> 31) - 1);
|
||||||
/* if (code >= range) code -= range; */
|
/* if (code >= range) code -= range; */
|
||||||
}
|
}
|
||||||
while (--numDirectBits != 0);
|
while (--numDirectBits);
|
||||||
prob = probs + Align;
|
prob = probs + Align;
|
||||||
numDirectBits = kNumAlignBits;
|
numDirectBits = kNumAlignBits;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
unsigned i = 1;
|
unsigned i = 1;
|
||||||
|
unsigned m = 1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
GET_BIT_CHECK(prob + i, i);
|
REV_BIT_CHECK(prob, i, m);
|
||||||
}
|
}
|
||||||
while (--numDirectBits != 0);
|
while (--numDirectBits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -766,20 +850,19 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
|
void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState)
|
||||||
{
|
{
|
||||||
p->needFlush = 1;
|
p->remainLen = kMatchSpecLenStart + 1;
|
||||||
p->remainLen = 0;
|
|
||||||
p->tempBufSize = 0;
|
p->tempBufSize = 0;
|
||||||
|
|
||||||
if (initDic)
|
if (initDic)
|
||||||
{
|
{
|
||||||
p->processedPos = 0;
|
p->processedPos = 0;
|
||||||
p->checkDicSize = 0;
|
p->checkDicSize = 0;
|
||||||
p->needInitState = 1;
|
p->remainLen = kMatchSpecLenStart + 2;
|
||||||
}
|
}
|
||||||
if (initState)
|
if (initState)
|
||||||
p->needInitState = 1;
|
p->remainLen = kMatchSpecLenStart + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LzmaDec_Init(CLzmaDec *p)
|
void LzmaDec_Init(CLzmaDec *p)
|
||||||
@@ -788,53 +871,54 @@ void LzmaDec_Init(CLzmaDec *p)
|
|||||||
LzmaDec_InitDicAndState(p, True, True);
|
LzmaDec_InitDicAndState(p, True, True);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LzmaDec_InitStateReal(CLzmaDec *p)
|
|
||||||
{
|
|
||||||
SizeT numProbs = LzmaProps_GetNumProbs(&p->prop);
|
|
||||||
SizeT i;
|
|
||||||
CLzmaProb *probs = p->probs;
|
|
||||||
for (i = 0; i < numProbs; i++)
|
|
||||||
probs[i] = kBitModelTotal >> 1;
|
|
||||||
p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;
|
|
||||||
p->state = 0;
|
|
||||||
p->needInitState = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
|
SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
|
||||||
ELzmaFinishMode finishMode, ELzmaStatus *status)
|
ELzmaFinishMode finishMode, ELzmaStatus *status)
|
||||||
{
|
{
|
||||||
SizeT inSize = *srcLen;
|
SizeT inSize = *srcLen;
|
||||||
(*srcLen) = 0;
|
(*srcLen) = 0;
|
||||||
LzmaDec_WriteRem(p, dicLimit);
|
|
||||||
|
|
||||||
*status = LZMA_STATUS_NOT_SPECIFIED;
|
*status = LZMA_STATUS_NOT_SPECIFIED;
|
||||||
|
|
||||||
|
if (p->remainLen > kMatchSpecLenStart)
|
||||||
|
{
|
||||||
|
for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)
|
||||||
|
p->tempBuf[p->tempBufSize++] = *src++;
|
||||||
|
if (p->tempBufSize != 0 && p->tempBuf[0] != 0)
|
||||||
|
return SZ_ERROR_DATA;
|
||||||
|
if (p->tempBufSize < RC_INIT_SIZE)
|
||||||
|
{
|
||||||
|
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
|
return SZ_OK;
|
||||||
|
}
|
||||||
|
p->code =
|
||||||
|
((UInt32)p->tempBuf[1] << 24)
|
||||||
|
| ((UInt32)p->tempBuf[2] << 16)
|
||||||
|
| ((UInt32)p->tempBuf[3] << 8)
|
||||||
|
| ((UInt32)p->tempBuf[4]);
|
||||||
|
p->range = 0xFFFFFFFF;
|
||||||
|
p->tempBufSize = 0;
|
||||||
|
|
||||||
|
if (p->remainLen > kMatchSpecLenStart + 1)
|
||||||
|
{
|
||||||
|
SizeT numProbs = LzmaProps_GetNumProbs(&p->prop);
|
||||||
|
SizeT i;
|
||||||
|
CLzmaProb *probs = p->probs;
|
||||||
|
for (i = 0; i < numProbs; i++)
|
||||||
|
probs[i] = kBitModelTotal >> 1;
|
||||||
|
p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;
|
||||||
|
p->state = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->remainLen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LzmaDec_WriteRem(p, dicLimit);
|
||||||
|
|
||||||
while (p->remainLen != kMatchSpecLenStart)
|
while (p->remainLen != kMatchSpecLenStart)
|
||||||
{
|
{
|
||||||
int checkEndMarkNow;
|
int checkEndMarkNow = 0;
|
||||||
|
|
||||||
if (p->needFlush)
|
|
||||||
{
|
|
||||||
for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)
|
|
||||||
p->tempBuf[p->tempBufSize++] = *src++;
|
|
||||||
if (p->tempBufSize < RC_INIT_SIZE)
|
|
||||||
{
|
|
||||||
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
|
|
||||||
return SZ_OK;
|
|
||||||
}
|
|
||||||
if (p->tempBuf[0] != 0)
|
|
||||||
return SZ_ERROR_DATA;
|
|
||||||
p->code =
|
|
||||||
((UInt32)p->tempBuf[1] << 24)
|
|
||||||
| ((UInt32)p->tempBuf[2] << 16)
|
|
||||||
| ((UInt32)p->tempBuf[3] << 8)
|
|
||||||
| ((UInt32)p->tempBuf[4]);
|
|
||||||
p->range = 0xFFFFFFFF;
|
|
||||||
p->needFlush = 0;
|
|
||||||
p->tempBufSize = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkEndMarkNow = 0;
|
|
||||||
if (p->dicPos >= dicLimit)
|
if (p->dicPos >= dicLimit)
|
||||||
{
|
{
|
||||||
if (p->remainLen == 0 && p->code == 0)
|
if (p->remainLen == 0 && p->code == 0)
|
||||||
@@ -855,9 +939,6 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
|
|||||||
checkEndMarkNow = 1;
|
checkEndMarkNow = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->needInitState)
|
|
||||||
LzmaDec_InitStateReal(p);
|
|
||||||
|
|
||||||
if (p->tempBufSize == 0)
|
if (p->tempBufSize == 0)
|
||||||
{
|
{
|
||||||
SizeT processed;
|
SizeT processed;
|
||||||
@@ -898,10 +979,10 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
|
|||||||
p->tempBufSize = rem;
|
p->tempBufSize = rem;
|
||||||
if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
|
if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
|
||||||
{
|
{
|
||||||
int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);
|
int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, (SizeT)rem);
|
||||||
if (dummyRes == DUMMY_ERROR)
|
if (dummyRes == DUMMY_ERROR)
|
||||||
{
|
{
|
||||||
(*srcLen) += lookAhead;
|
(*srcLen) += (SizeT)lookAhead;
|
||||||
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
|
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
@@ -924,17 +1005,20 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
|
|||||||
return SZ_ERROR_FAIL; /* some internal error */
|
return SZ_ERROR_FAIL; /* some internal error */
|
||||||
lookAhead -= rem;
|
lookAhead -= rem;
|
||||||
}
|
}
|
||||||
(*srcLen) += lookAhead;
|
(*srcLen) += (SizeT)lookAhead;
|
||||||
src += lookAhead;
|
src += lookAhead;
|
||||||
inSize -= lookAhead;
|
inSize -= (SizeT)lookAhead;
|
||||||
p->tempBufSize = 0;
|
p->tempBufSize = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p->code == 0)
|
|
||||||
*status = LZMA_STATUS_FINISHED_WITH_MARK;
|
if (p->code != 0)
|
||||||
return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
|
return SZ_ERROR_DATA;
|
||||||
|
*status = LZMA_STATUS_FINISHED_WITH_MARK;
|
||||||
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
|
SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
|
||||||
{
|
{
|
||||||
SizeT outSize = *destLen;
|
SizeT outSize = *destLen;
|
||||||
@@ -1011,10 +1095,10 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
|
|||||||
if (d >= (9 * 5 * 5))
|
if (d >= (9 * 5 * 5))
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
|
|
||||||
p->lc = d % 9;
|
p->lc = (Byte)(d % 9);
|
||||||
d /= 9;
|
d /= 9;
|
||||||
p->pb = d / 5;
|
p->pb = (Byte)(d / 5);
|
||||||
p->lp = d % 5;
|
p->lp = (Byte)(d % 5);
|
||||||
|
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
@@ -1026,9 +1110,10 @@ static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAl
|
|||||||
{
|
{
|
||||||
LzmaDec_FreeProbs(p, alloc);
|
LzmaDec_FreeProbs(p, alloc);
|
||||||
p->probs = (CLzmaProb *)ISzAlloc_Alloc(alloc, numProbs * sizeof(CLzmaProb));
|
p->probs = (CLzmaProb *)ISzAlloc_Alloc(alloc, numProbs * sizeof(CLzmaProb));
|
||||||
p->numProbs = numProbs;
|
|
||||||
if (!p->probs)
|
if (!p->probs)
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
|
p->probs_1664 = p->probs + 1664;
|
||||||
|
p->numProbs = numProbs;
|
||||||
}
|
}
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
41
C/LzmaDec.h
41
C/LzmaDec.h
@@ -1,5 +1,5 @@
|
|||||||
/* LzmaDec.h -- LZMA Decoder
|
/* LzmaDec.h -- LZMA Decoder
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-04-21 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA_DEC_H
|
#ifndef __LZMA_DEC_H
|
||||||
#define __LZMA_DEC_H
|
#define __LZMA_DEC_H
|
||||||
@@ -12,11 +12,13 @@ EXTERN_C_BEGIN
|
|||||||
/* _LZMA_PROB32 can increase the speed on some CPUs,
|
/* _LZMA_PROB32 can increase the speed on some CPUs,
|
||||||
but memory usage for CLzmaDec::probs will be doubled in that case */
|
but memory usage for CLzmaDec::probs will be doubled in that case */
|
||||||
|
|
||||||
|
typedef
|
||||||
#ifdef _LZMA_PROB32
|
#ifdef _LZMA_PROB32
|
||||||
#define CLzmaProb UInt32
|
UInt32
|
||||||
#else
|
#else
|
||||||
#define CLzmaProb UInt16
|
UInt16
|
||||||
#endif
|
#endif
|
||||||
|
CLzmaProb;
|
||||||
|
|
||||||
|
|
||||||
/* ---------- LZMA Properties ---------- */
|
/* ---------- LZMA Properties ---------- */
|
||||||
@@ -25,7 +27,10 @@ EXTERN_C_BEGIN
|
|||||||
|
|
||||||
typedef struct _CLzmaProps
|
typedef struct _CLzmaProps
|
||||||
{
|
{
|
||||||
unsigned lc, lp, pb;
|
Byte lc;
|
||||||
|
Byte lp;
|
||||||
|
Byte pb;
|
||||||
|
Byte _pad_;
|
||||||
UInt32 dicSize;
|
UInt32 dicSize;
|
||||||
} CLzmaProps;
|
} CLzmaProps;
|
||||||
|
|
||||||
@@ -47,32 +52,34 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
/* Don't change this structure. ASM code can use it. */
|
||||||
CLzmaProps prop;
|
CLzmaProps prop;
|
||||||
CLzmaProb *probs;
|
CLzmaProb *probs;
|
||||||
|
CLzmaProb *probs_1664;
|
||||||
Byte *dic;
|
Byte *dic;
|
||||||
const Byte *buf;
|
|
||||||
UInt32 range, code;
|
|
||||||
SizeT dicPos;
|
|
||||||
SizeT dicBufSize;
|
SizeT dicBufSize;
|
||||||
|
SizeT dicPos;
|
||||||
|
const Byte *buf;
|
||||||
|
UInt32 range;
|
||||||
|
UInt32 code;
|
||||||
UInt32 processedPos;
|
UInt32 processedPos;
|
||||||
UInt32 checkDicSize;
|
UInt32 checkDicSize;
|
||||||
unsigned state;
|
|
||||||
UInt32 reps[4];
|
UInt32 reps[4];
|
||||||
unsigned remainLen;
|
UInt32 state;
|
||||||
int needFlush;
|
UInt32 remainLen;
|
||||||
int needInitState;
|
|
||||||
UInt32 numProbs;
|
UInt32 numProbs;
|
||||||
unsigned tempBufSize;
|
unsigned tempBufSize;
|
||||||
Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
|
Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
|
||||||
} CLzmaDec;
|
} CLzmaDec;
|
||||||
|
|
||||||
#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
|
#define LzmaDec_Construct(p) { (p)->dic = NULL; (p)->probs = NULL; }
|
||||||
|
|
||||||
void LzmaDec_Init(CLzmaDec *p);
|
void LzmaDec_Init(CLzmaDec *p);
|
||||||
|
|
||||||
/* There are two types of LZMA streams:
|
/* There are two types of LZMA streams:
|
||||||
0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
|
- Stream with end mark. That end mark adds about 6 bytes to compressed size.
|
||||||
1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
|
- Stream without end mark. You must know exact uncompressed size to decompress such stream. */
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@@ -132,8 +139,8 @@ LzmaDec_Allocate* can return:
|
|||||||
SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc);
|
SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc);
|
||||||
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc);
|
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc);
|
||||||
|
|
||||||
SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAllocPtr alloc);
|
SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc);
|
||||||
void LzmaDec_Free(CLzmaDec *state, ISzAllocPtr alloc);
|
void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc);
|
||||||
|
|
||||||
/* ---------- Dictionary Interface ---------- */
|
/* ---------- Dictionary Interface ---------- */
|
||||||
|
|
||||||
@@ -142,7 +149,7 @@ void LzmaDec_Free(CLzmaDec *state, ISzAllocPtr alloc);
|
|||||||
You must work with CLzmaDec variables directly in this interface.
|
You must work with CLzmaDec variables directly in this interface.
|
||||||
|
|
||||||
STEPS:
|
STEPS:
|
||||||
LzmaDec_Constr()
|
LzmaDec_Construct()
|
||||||
LzmaDec_Allocate()
|
LzmaDec_Allocate()
|
||||||
for (each new stream)
|
for (each new stream)
|
||||||
{
|
{
|
||||||
|
|||||||
2603
C/LzmaEnc.c
2603
C/LzmaEnc.c
File diff suppressed because it is too large
Load Diff
37
C/LzmaEnc.h
37
C/LzmaEnc.h
@@ -1,5 +1,5 @@
|
|||||||
/* LzmaEnc.h -- LZMA Encoder
|
/* LzmaEnc.h -- LZMA Encoder
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2017-07-27 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA_ENC_H
|
#ifndef __LZMA_ENC_H
|
||||||
#define __LZMA_ENC_H
|
#define __LZMA_ENC_H
|
||||||
@@ -12,12 +12,10 @@ EXTERN_C_BEGIN
|
|||||||
|
|
||||||
typedef struct _CLzmaEncProps
|
typedef struct _CLzmaEncProps
|
||||||
{
|
{
|
||||||
int level; /* 0 <= level <= 9 */
|
int level; /* 0 <= level <= 9 */
|
||||||
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 <= (3 << 29) 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 */
|
||||||
@@ -25,9 +23,12 @@ typedef struct _CLzmaEncProps
|
|||||||
int fb; /* 5 <= fb <= 273, default = 32 */
|
int fb; /* 5 <= fb <= 273, default = 32 */
|
||||||
int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
|
int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
|
||||||
int numHashBytes; /* 2, 3 or 4, default = 4 */
|
int numHashBytes; /* 2, 3 or 4, default = 4 */
|
||||||
UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
|
UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
|
||||||
unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
|
unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
|
||||||
int numThreads; /* 1 or 2, default = 2 */
|
int numThreads; /* 1 or 2, default = 2 */
|
||||||
|
|
||||||
|
UInt64 reduceSize; /* estimated size of data that will be compressed. default = (UInt64)(Int64)-1.
|
||||||
|
Encoder uses this value to reduce dictionary size */
|
||||||
} CLzmaEncProps;
|
} CLzmaEncProps;
|
||||||
|
|
||||||
void LzmaEncProps_Init(CLzmaEncProps *p);
|
void LzmaEncProps_Init(CLzmaEncProps *p);
|
||||||
@@ -37,38 +38,34 @@ UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
|
|||||||
|
|
||||||
/* ---------- CLzmaEncHandle Interface ---------- */
|
/* ---------- CLzmaEncHandle Interface ---------- */
|
||||||
|
|
||||||
/* LzmaEnc_* functions can return the following exit codes:
|
/* LzmaEnc* functions can return the following exit codes:
|
||||||
Returns:
|
SRes:
|
||||||
SZ_OK - OK
|
SZ_OK - OK
|
||||||
SZ_ERROR_MEM - Memory allocation error
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
SZ_ERROR_PARAM - Incorrect paramater in props
|
SZ_ERROR_PARAM - Incorrect paramater in props
|
||||||
SZ_ERROR_WRITE - Write callback error.
|
SZ_ERROR_WRITE - ISeqOutStream write callback error
|
||||||
|
SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output
|
||||||
SZ_ERROR_PROGRESS - some break from progress callback
|
SZ_ERROR_PROGRESS - some break from progress callback
|
||||||
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
|
SZ_ERROR_THREAD - error in multithreading functions (only for Mt version)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef void * CLzmaEncHandle;
|
typedef void * CLzmaEncHandle;
|
||||||
|
|
||||||
CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc);
|
CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc);
|
||||||
void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
||||||
|
|
||||||
SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
|
SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
|
||||||
|
void LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize);
|
||||||
SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
|
SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
|
||||||
unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p);
|
unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p);
|
||||||
|
|
||||||
SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
|
SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
|
||||||
ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
||||||
SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
||||||
int writeEndMark, ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
int writeEndMark, ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
||||||
|
|
||||||
/* ---------- One Call Interface ---------- */
|
|
||||||
|
|
||||||
/* LzmaEncode
|
/* ---------- One Call Interface ---------- */
|
||||||
Return code:
|
|
||||||
SZ_OK - OK
|
|
||||||
SZ_ERROR_MEM - Memory allocation error
|
|
||||||
SZ_ERROR_PARAM - Incorrect paramater
|
|
||||||
SZ_ERROR_OUTPUT_EOF - output buffer overflow
|
|
||||||
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
|
|
||||||
*/
|
|
||||||
|
|
||||||
SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
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,
|
||||||
|
|||||||
744
C/MtCoder.c
744
C/MtCoder.c
@@ -1,168 +1,89 @@
|
|||||||
/* MtCoder.c -- Multi-thread Coder
|
/* MtCoder.c -- Multi-thread Coder
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
#include "MtCoder.h"
|
#include "MtCoder.h"
|
||||||
|
|
||||||
void LoopThread_Construct(CLoopThread *p)
|
#ifndef _7ZIP_ST
|
||||||
{
|
|
||||||
Thread_Construct(&p->thread);
|
|
||||||
Event_Construct(&p->startEvent);
|
|
||||||
Event_Construct(&p->finishedEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoopThread_Close(CLoopThread *p)
|
SRes MtProgressThunk_Progress(const ICompressProgress *pp, UInt64 inSize, UInt64 outSize)
|
||||||
{
|
{
|
||||||
Thread_Close(&p->thread);
|
CMtProgressThunk *thunk = CONTAINER_FROM_VTBL(pp, CMtProgressThunk, vt);
|
||||||
Event_Close(&p->startEvent);
|
UInt64 inSize2 = 0;
|
||||||
Event_Close(&p->finishedEvent);
|
UInt64 outSize2 = 0;
|
||||||
}
|
if (inSize != (UInt64)(Int64)-1)
|
||||||
|
|
||||||
static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE LoopThreadFunc(void *pp)
|
|
||||||
{
|
|
||||||
CLoopThread *p = (CLoopThread *)pp;
|
|
||||||
for (;;)
|
|
||||||
{
|
{
|
||||||
if (Event_Wait(&p->startEvent) != 0)
|
inSize2 = inSize - thunk->inSize;
|
||||||
return SZ_ERROR_THREAD;
|
thunk->inSize = inSize;
|
||||||
if (p->stop)
|
|
||||||
return 0;
|
|
||||||
p->res = p->func(p->param);
|
|
||||||
if (Event_Set(&p->finishedEvent) != 0)
|
|
||||||
return SZ_ERROR_THREAD;
|
|
||||||
}
|
}
|
||||||
|
if (outSize != (UInt64)(Int64)-1)
|
||||||
|
{
|
||||||
|
outSize2 = outSize - thunk->outSize;
|
||||||
|
thunk->outSize = outSize;
|
||||||
|
}
|
||||||
|
return MtProgress_ProgressAdd(thunk->mtProgress, inSize2, outSize2);
|
||||||
}
|
}
|
||||||
|
|
||||||
WRes LoopThread_Create(CLoopThread *p)
|
|
||||||
|
void MtProgressThunk_CreateVTable(CMtProgressThunk *p)
|
||||||
{
|
{
|
||||||
p->stop = 0;
|
p->vt.Progress = MtProgressThunk_Progress;
|
||||||
RINOK(AutoResetEvent_CreateNotSignaled(&p->startEvent));
|
|
||||||
RINOK(AutoResetEvent_CreateNotSignaled(&p->finishedEvent));
|
|
||||||
return Thread_Create(&p->thread, LoopThreadFunc, p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WRes LoopThread_StopAndWait(CLoopThread *p)
|
|
||||||
{
|
|
||||||
p->stop = 1;
|
|
||||||
if (Event_Set(&p->startEvent) != 0)
|
|
||||||
return SZ_ERROR_THREAD;
|
|
||||||
return Thread_Wait(&p->thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
WRes LoopThread_StartSubThread(CLoopThread *p) { return Event_Set(&p->startEvent); }
|
|
||||||
WRes LoopThread_WaitSubThread(CLoopThread *p) { return Event_Wait(&p->finishedEvent); }
|
|
||||||
|
|
||||||
static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize)
|
|
||||||
{
|
|
||||||
return (p && ICompressProgress_Progress(p, inSize, outSize) != SZ_OK) ? SZ_ERROR_PROGRESS : SZ_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MtProgress_Init(CMtProgress *p, ICompressProgress *progress)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
|
|
||||||
p->inSizes[i] = p->outSizes[i] = 0;
|
|
||||||
p->totalInSize = p->totalOutSize = 0;
|
|
||||||
p->progress = progress;
|
|
||||||
p->res = SZ_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MtProgress_Reinit(CMtProgress *p, unsigned index)
|
|
||||||
{
|
|
||||||
p->inSizes[index] = 0;
|
|
||||||
p->outSizes[index] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define UPDATE_PROGRESS(size, prev, total) \
|
|
||||||
if (size != (UInt64)(Int64)-1) { total += size - prev; prev = size; }
|
|
||||||
|
|
||||||
SRes MtProgress_Set(CMtProgress *p, unsigned index, UInt64 inSize, UInt64 outSize)
|
|
||||||
{
|
|
||||||
SRes res;
|
|
||||||
CriticalSection_Enter(&p->cs);
|
|
||||||
UPDATE_PROGRESS(inSize, p->inSizes[index], p->totalInSize)
|
|
||||||
UPDATE_PROGRESS(outSize, p->outSizes[index], p->totalOutSize)
|
|
||||||
if (p->res == SZ_OK)
|
|
||||||
p->res = Progress(p->progress, p->totalInSize, p->totalOutSize);
|
|
||||||
res = p->res;
|
|
||||||
CriticalSection_Leave(&p->cs);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MtProgress_SetError(CMtProgress *p, SRes res)
|
|
||||||
{
|
|
||||||
CriticalSection_Enter(&p->cs);
|
|
||||||
if (p->res == SZ_OK)
|
|
||||||
p->res = res;
|
|
||||||
CriticalSection_Leave(&p->cs);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void MtCoder_SetError(CMtCoder* p, SRes res)
|
|
||||||
{
|
|
||||||
CriticalSection_Enter(&p->cs);
|
|
||||||
if (p->res == SZ_OK)
|
|
||||||
p->res = res;
|
|
||||||
CriticalSection_Leave(&p->cs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------- MtThread ---------- */
|
|
||||||
|
|
||||||
void CMtThread_Construct(CMtThread *p, CMtCoder *mtCoder)
|
|
||||||
{
|
|
||||||
p->mtCoder = mtCoder;
|
|
||||||
p->outBuf = 0;
|
|
||||||
p->inBuf = 0;
|
|
||||||
Event_Construct(&p->canRead);
|
|
||||||
Event_Construct(&p->canWrite);
|
|
||||||
LoopThread_Construct(&p->thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; }
|
#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; }
|
||||||
|
|
||||||
static void CMtThread_CloseEvents(CMtThread *p)
|
|
||||||
|
static WRes ArEvent_OptCreate_And_Reset(CEvent *p)
|
||||||
{
|
{
|
||||||
Event_Close(&p->canRead);
|
if (Event_IsCreated(p))
|
||||||
Event_Close(&p->canWrite);
|
return Event_Reset(p);
|
||||||
|
return AutoResetEvent_CreateNotSignaled(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CMtThread_Destruct(CMtThread *p)
|
|
||||||
{
|
|
||||||
CMtThread_CloseEvents(p);
|
|
||||||
|
|
||||||
if (Thread_WasCreated(&p->thread.thread))
|
static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp);
|
||||||
|
|
||||||
|
|
||||||
|
static SRes MtCoderThread_CreateAndStart(CMtCoderThread *t)
|
||||||
|
{
|
||||||
|
WRes wres = ArEvent_OptCreate_And_Reset(&t->startEvent);
|
||||||
|
if (wres == 0)
|
||||||
{
|
{
|
||||||
LoopThread_StopAndWait(&p->thread);
|
t->stop = False;
|
||||||
LoopThread_Close(&p->thread);
|
if (!Thread_WasCreated(&t->thread))
|
||||||
|
wres = Thread_Create(&t->thread, ThreadFunc, t);
|
||||||
|
if (wres == 0)
|
||||||
|
wres = Event_Set(&t->startEvent);
|
||||||
|
}
|
||||||
|
if (wres == 0)
|
||||||
|
return SZ_OK;
|
||||||
|
return MY_SRes_HRESULT_FROM_WRes(wres);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void MtCoderThread_Destruct(CMtCoderThread *t)
|
||||||
|
{
|
||||||
|
if (Thread_WasCreated(&t->thread))
|
||||||
|
{
|
||||||
|
t->stop = 1;
|
||||||
|
Event_Set(&t->startEvent);
|
||||||
|
Thread_Wait(&t->thread);
|
||||||
|
Thread_Close(&t->thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->mtCoder->alloc)
|
Event_Close(&t->startEvent);
|
||||||
ISzAlloc_Free(p->mtCoder->alloc, p->outBuf);
|
|
||||||
p->outBuf = 0;
|
|
||||||
|
|
||||||
if (p->mtCoder->alloc)
|
if (t->inBuf)
|
||||||
ISzAlloc_Free(p->mtCoder->alloc, p->inBuf);
|
{
|
||||||
p->inBuf = 0;
|
ISzAlloc_Free(t->mtCoder->allocBig, t->inBuf);
|
||||||
|
t->inBuf = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MY_BUF_ALLOC(buf, size, newSize) \
|
|
||||||
if (buf == 0 || size != newSize) \
|
|
||||||
{ ISzAlloc_Free(p->mtCoder->alloc, buf); \
|
|
||||||
size = newSize; buf = (Byte *)ISzAlloc_Alloc(p->mtCoder->alloc, size); \
|
|
||||||
if (buf == 0) return SZ_ERROR_MEM; }
|
|
||||||
|
|
||||||
static SRes CMtThread_Prepare(CMtThread *p)
|
|
||||||
{
|
|
||||||
MY_BUF_ALLOC(p->inBuf, p->inBufSize, p->mtCoder->blockSize)
|
|
||||||
MY_BUF_ALLOC(p->outBuf, p->outBufSize, p->mtCoder->destBlockSize)
|
|
||||||
|
|
||||||
p->stopReading = False;
|
|
||||||
p->stopWriting = False;
|
|
||||||
RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canRead));
|
|
||||||
RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canWrite));
|
|
||||||
|
|
||||||
return SZ_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SRes FullRead(ISeqInStream *stream, Byte *data, size_t *processedSize)
|
static SRes FullRead(ISeqInStream *stream, Byte *data, size_t *processedSize)
|
||||||
{
|
{
|
||||||
@@ -170,158 +91,511 @@ static SRes FullRead(ISeqInStream *stream, Byte *data, size_t *processedSize)
|
|||||||
*processedSize = 0;
|
*processedSize = 0;
|
||||||
while (size != 0)
|
while (size != 0)
|
||||||
{
|
{
|
||||||
size_t curSize = size;
|
size_t cur = size;
|
||||||
SRes res = ISeqInStream_Read(stream, data, &curSize);
|
SRes res = ISeqInStream_Read(stream, data, &cur);
|
||||||
*processedSize += curSize;
|
*processedSize += cur;
|
||||||
data += curSize;
|
data += cur;
|
||||||
size -= curSize;
|
size -= cur;
|
||||||
RINOK(res);
|
RINOK(res);
|
||||||
if (curSize == 0)
|
if (cur == 0)
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
return SZ_OK;
|
return SZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GET_NEXT_THREAD(p) &p->mtCoder->threads[p->index == p->mtCoder->numThreads - 1 ? 0 : p->index + 1]
|
|
||||||
|
|
||||||
static SRes MtThread_Process(CMtThread *p, Bool *stop)
|
/*
|
||||||
|
ThreadFunc2() returns:
|
||||||
|
SZ_OK - in all normal cases (even for stream error or memory allocation error)
|
||||||
|
SZ_ERROR_THREAD - in case of failure in system synch function
|
||||||
|
*/
|
||||||
|
|
||||||
|
static SRes ThreadFunc2(CMtCoderThread *t)
|
||||||
{
|
{
|
||||||
CMtThread *next;
|
CMtCoder *mtc = t->mtCoder;
|
||||||
*stop = True;
|
|
||||||
if (Event_Wait(&p->canRead) != 0)
|
|
||||||
return SZ_ERROR_THREAD;
|
|
||||||
|
|
||||||
next = GET_NEXT_THREAD(p);
|
|
||||||
|
|
||||||
if (p->stopReading)
|
|
||||||
{
|
|
||||||
next->stopReading = True;
|
|
||||||
return Event_Set(&next->canRead) == 0 ? SZ_OK : SZ_ERROR_THREAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
size_t size = p->mtCoder->blockSize;
|
|
||||||
size_t destSize = p->outBufSize;
|
|
||||||
|
|
||||||
RINOK(FullRead(p->mtCoder->inStream, p->inBuf, &size));
|
|
||||||
next->stopReading = *stop = (size != p->mtCoder->blockSize);
|
|
||||||
if (Event_Set(&next->canRead) != 0)
|
|
||||||
return SZ_ERROR_THREAD;
|
|
||||||
|
|
||||||
RINOK(IMtCoderCallback_Code(p->mtCoder->mtCallback, p->index,
|
|
||||||
p->outBuf, &destSize, p->inBuf, size, *stop));
|
|
||||||
|
|
||||||
MtProgress_Reinit(&p->mtCoder->mtProgress, p->index);
|
|
||||||
|
|
||||||
if (Event_Wait(&p->canWrite) != 0)
|
|
||||||
return SZ_ERROR_THREAD;
|
|
||||||
if (p->stopWriting)
|
|
||||||
return SZ_ERROR_FAIL;
|
|
||||||
if (ISeqOutStream_Write(p->mtCoder->outStream, p->outBuf, destSize) != destSize)
|
|
||||||
return SZ_ERROR_WRITE;
|
|
||||||
return Event_Set(&next->canWrite) == 0 ? SZ_OK : SZ_ERROR_THREAD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp)
|
|
||||||
{
|
|
||||||
CMtThread *p = (CMtThread *)pp;
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
Bool stop;
|
unsigned bi;
|
||||||
CMtThread *next = GET_NEXT_THREAD(p);
|
SRes res;
|
||||||
SRes res = MtThread_Process(p, &stop);
|
SRes res2;
|
||||||
if (res != SZ_OK)
|
BoolInt finished;
|
||||||
|
unsigned bufIndex;
|
||||||
|
size_t size;
|
||||||
|
const Byte *inData;
|
||||||
|
UInt64 readProcessed = 0;
|
||||||
|
|
||||||
|
RINOK_THREAD(Event_Wait(&mtc->readEvent))
|
||||||
|
|
||||||
|
/* after Event_Wait(&mtc->readEvent) we must call Event_Set(&mtc->readEvent) in any case to unlock another threads */
|
||||||
|
|
||||||
|
if (mtc->stopReading)
|
||||||
{
|
{
|
||||||
MtCoder_SetError(p->mtCoder, res);
|
return Event_Set(&mtc->readEvent) == 0 ? SZ_OK : SZ_ERROR_THREAD;
|
||||||
MtProgress_SetError(&p->mtCoder->mtProgress, res);
|
|
||||||
next->stopReading = True;
|
|
||||||
next->stopWriting = True;
|
|
||||||
Event_Set(&next->canRead);
|
|
||||||
Event_Set(&next->canWrite);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
if (stop)
|
|
||||||
|
res = MtProgress_GetError(&mtc->mtProgress);
|
||||||
|
|
||||||
|
size = 0;
|
||||||
|
inData = NULL;
|
||||||
|
finished = True;
|
||||||
|
|
||||||
|
if (res == SZ_OK)
|
||||||
|
{
|
||||||
|
size = mtc->blockSize;
|
||||||
|
if (mtc->inStream)
|
||||||
|
{
|
||||||
|
if (!t->inBuf)
|
||||||
|
{
|
||||||
|
t->inBuf = (Byte *)ISzAlloc_Alloc(mtc->allocBig, mtc->blockSize);
|
||||||
|
if (!t->inBuf)
|
||||||
|
res = SZ_ERROR_MEM;
|
||||||
|
}
|
||||||
|
if (res == SZ_OK)
|
||||||
|
{
|
||||||
|
res = FullRead(mtc->inStream, t->inBuf, &size);
|
||||||
|
readProcessed = mtc->readProcessed + size;
|
||||||
|
mtc->readProcessed = readProcessed;
|
||||||
|
}
|
||||||
|
if (res != SZ_OK)
|
||||||
|
{
|
||||||
|
mtc->readRes = res;
|
||||||
|
/* after reading error - we can stop encoding of previous blocks */
|
||||||
|
MtProgress_SetError(&mtc->mtProgress, res);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
finished = (size != mtc->blockSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t rem;
|
||||||
|
readProcessed = mtc->readProcessed;
|
||||||
|
rem = mtc->inDataSize - (size_t)readProcessed;
|
||||||
|
if (size > rem)
|
||||||
|
size = rem;
|
||||||
|
inData = mtc->inData + (size_t)readProcessed;
|
||||||
|
readProcessed += size;
|
||||||
|
mtc->readProcessed = readProcessed;
|
||||||
|
finished = (mtc->inDataSize == (size_t)readProcessed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we must get some block from blocksSemaphore before Event_Set(&mtc->readEvent) */
|
||||||
|
|
||||||
|
res2 = SZ_OK;
|
||||||
|
|
||||||
|
if (Semaphore_Wait(&mtc->blocksSemaphore) != 0)
|
||||||
|
{
|
||||||
|
res2 = SZ_ERROR_THREAD;
|
||||||
|
if (res == SZ_OK)
|
||||||
|
{
|
||||||
|
res = res2;
|
||||||
|
// MtProgress_SetError(&mtc->mtProgress, res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bi = mtc->blockIndex;
|
||||||
|
|
||||||
|
if (++mtc->blockIndex >= mtc->numBlocksMax)
|
||||||
|
mtc->blockIndex = 0;
|
||||||
|
|
||||||
|
bufIndex = (unsigned)(int)-1;
|
||||||
|
|
||||||
|
if (res == SZ_OK)
|
||||||
|
res = MtProgress_GetError(&mtc->mtProgress);
|
||||||
|
|
||||||
|
if (res != SZ_OK)
|
||||||
|
finished = True;
|
||||||
|
|
||||||
|
if (!finished)
|
||||||
|
{
|
||||||
|
if (mtc->numStartedThreads < mtc->numStartedThreadsLimit
|
||||||
|
&& mtc->expectedDataSize != readProcessed)
|
||||||
|
{
|
||||||
|
res = MtCoderThread_CreateAndStart(&mtc->threads[mtc->numStartedThreads]);
|
||||||
|
if (res == SZ_OK)
|
||||||
|
mtc->numStartedThreads++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MtProgress_SetError(&mtc->mtProgress, res);
|
||||||
|
finished = True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finished)
|
||||||
|
mtc->stopReading = True;
|
||||||
|
|
||||||
|
RINOK_THREAD(Event_Set(&mtc->readEvent))
|
||||||
|
|
||||||
|
if (res2 != SZ_OK)
|
||||||
|
return res2;
|
||||||
|
|
||||||
|
if (res == SZ_OK)
|
||||||
|
{
|
||||||
|
CriticalSection_Enter(&mtc->cs);
|
||||||
|
bufIndex = mtc->freeBlockHead;
|
||||||
|
mtc->freeBlockHead = mtc->freeBlockList[bufIndex];
|
||||||
|
CriticalSection_Leave(&mtc->cs);
|
||||||
|
|
||||||
|
res = mtc->mtCallback->Code(mtc->mtCallbackObject, t->index, bufIndex,
|
||||||
|
mtc->inStream ? t->inBuf : inData, size, finished);
|
||||||
|
|
||||||
|
// MtProgress_Reinit(&mtc->mtProgress, t->index);
|
||||||
|
|
||||||
|
if (res != SZ_OK)
|
||||||
|
MtProgress_SetError(&mtc->mtProgress, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
CMtCoderBlock *block = &mtc->blocks[bi];
|
||||||
|
block->res = res;
|
||||||
|
block->bufIndex = bufIndex;
|
||||||
|
block->finished = finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MTCODER__USE_WRITE_THREAD
|
||||||
|
RINOK_THREAD(Event_Set(&mtc->writeEvents[bi]))
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
unsigned wi;
|
||||||
|
{
|
||||||
|
CriticalSection_Enter(&mtc->cs);
|
||||||
|
wi = mtc->writeIndex;
|
||||||
|
if (wi == bi)
|
||||||
|
mtc->writeIndex = (unsigned)(int)-1;
|
||||||
|
else
|
||||||
|
mtc->ReadyBlocks[bi] = True;
|
||||||
|
CriticalSection_Leave(&mtc->cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wi != bi)
|
||||||
|
{
|
||||||
|
if (res != SZ_OK || finished)
|
||||||
|
return 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mtc->writeRes != SZ_OK)
|
||||||
|
res = mtc->writeRes;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (res == SZ_OK && bufIndex != (unsigned)(int)-1)
|
||||||
|
{
|
||||||
|
res = mtc->mtCallback->Write(mtc->mtCallbackObject, bufIndex);
|
||||||
|
if (res != SZ_OK)
|
||||||
|
{
|
||||||
|
mtc->writeRes = res;
|
||||||
|
MtProgress_SetError(&mtc->mtProgress, res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (++wi >= mtc->numBlocksMax)
|
||||||
|
wi = 0;
|
||||||
|
{
|
||||||
|
BoolInt isReady;
|
||||||
|
|
||||||
|
CriticalSection_Enter(&mtc->cs);
|
||||||
|
|
||||||
|
if (bufIndex != (unsigned)(int)-1)
|
||||||
|
{
|
||||||
|
mtc->freeBlockList[bufIndex] = mtc->freeBlockHead;
|
||||||
|
mtc->freeBlockHead = bufIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
isReady = mtc->ReadyBlocks[wi];
|
||||||
|
|
||||||
|
if (isReady)
|
||||||
|
mtc->ReadyBlocks[wi] = False;
|
||||||
|
else
|
||||||
|
mtc->writeIndex = wi;
|
||||||
|
|
||||||
|
CriticalSection_Leave(&mtc->cs);
|
||||||
|
|
||||||
|
RINOK_THREAD(Semaphore_Release1(&mtc->blocksSemaphore))
|
||||||
|
|
||||||
|
if (!isReady)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
CMtCoderBlock *block = &mtc->blocks[wi];
|
||||||
|
if (res == SZ_OK && block->res != SZ_OK)
|
||||||
|
res = block->res;
|
||||||
|
bufIndex = block->bufIndex;
|
||||||
|
finished = block->finished;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (finished || res != SZ_OK)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MtCoder_Construct(CMtCoder* p)
|
|
||||||
|
static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp)
|
||||||
|
{
|
||||||
|
CMtCoderThread *t = (CMtCoderThread *)pp;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (Event_Wait(&t->startEvent) != 0)
|
||||||
|
return SZ_ERROR_THREAD;
|
||||||
|
if (t->stop)
|
||||||
|
return 0;
|
||||||
|
{
|
||||||
|
SRes res = ThreadFunc2(t);
|
||||||
|
CMtCoder *mtc = t->mtCoder;
|
||||||
|
if (res != SZ_OK)
|
||||||
|
{
|
||||||
|
MtProgress_SetError(&mtc->mtProgress, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef MTCODER__USE_WRITE_THREAD
|
||||||
|
{
|
||||||
|
unsigned numFinished = (unsigned)InterlockedIncrement(&mtc->numFinishedThreads);
|
||||||
|
if (numFinished == mtc->numStartedThreads)
|
||||||
|
if (Event_Set(&mtc->finishedEvent) != 0)
|
||||||
|
return SZ_ERROR_THREAD;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MtCoder_Construct(CMtCoder *p)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
p->alloc = 0;
|
|
||||||
for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
|
p->blockSize = 0;
|
||||||
|
p->numThreadsMax = 0;
|
||||||
|
p->expectedDataSize = (UInt64)(Int64)-1;
|
||||||
|
|
||||||
|
p->inStream = NULL;
|
||||||
|
p->inData = NULL;
|
||||||
|
p->inDataSize = 0;
|
||||||
|
|
||||||
|
p->progress = NULL;
|
||||||
|
p->allocBig = NULL;
|
||||||
|
|
||||||
|
p->mtCallback = NULL;
|
||||||
|
p->mtCallbackObject = NULL;
|
||||||
|
|
||||||
|
p->allocatedBufsSize = 0;
|
||||||
|
|
||||||
|
Event_Construct(&p->readEvent);
|
||||||
|
Semaphore_Construct(&p->blocksSemaphore);
|
||||||
|
|
||||||
|
for (i = 0; i < MTCODER__THREADS_MAX; i++)
|
||||||
{
|
{
|
||||||
CMtThread *t = &p->threads[i];
|
CMtCoderThread *t = &p->threads[i];
|
||||||
|
t->mtCoder = p;
|
||||||
t->index = i;
|
t->index = i;
|
||||||
CMtThread_Construct(t, p);
|
t->inBuf = NULL;
|
||||||
|
t->stop = False;
|
||||||
|
Event_Construct(&t->startEvent);
|
||||||
|
Thread_Construct(&t->thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MTCODER__USE_WRITE_THREAD
|
||||||
|
for (i = 0; i < MTCODER__BLOCKS_MAX; i++)
|
||||||
|
Event_Construct(&p->writeEvents[i]);
|
||||||
|
#else
|
||||||
|
Event_Construct(&p->finishedEvent);
|
||||||
|
#endif
|
||||||
|
|
||||||
CriticalSection_Init(&p->cs);
|
CriticalSection_Init(&p->cs);
|
||||||
CriticalSection_Init(&p->mtProgress.cs);
|
CriticalSection_Init(&p->mtProgress.cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MtCoder_Destruct(CMtCoder* p)
|
|
||||||
|
|
||||||
|
|
||||||
|
static void MtCoder_Free(CMtCoder *p)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)
|
|
||||||
CMtThread_Destruct(&p->threads[i]);
|
/*
|
||||||
|
p->stopReading = True;
|
||||||
|
if (Event_IsCreated(&p->readEvent))
|
||||||
|
Event_Set(&p->readEvent);
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (i = 0; i < MTCODER__THREADS_MAX; i++)
|
||||||
|
MtCoderThread_Destruct(&p->threads[i]);
|
||||||
|
|
||||||
|
Event_Close(&p->readEvent);
|
||||||
|
Semaphore_Close(&p->blocksSemaphore);
|
||||||
|
|
||||||
|
#ifdef MTCODER__USE_WRITE_THREAD
|
||||||
|
for (i = 0; i < MTCODER__BLOCKS_MAX; i++)
|
||||||
|
Event_Close(&p->writeEvents[i]);
|
||||||
|
#else
|
||||||
|
Event_Close(&p->finishedEvent);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MtCoder_Destruct(CMtCoder *p)
|
||||||
|
{
|
||||||
|
MtCoder_Free(p);
|
||||||
|
|
||||||
CriticalSection_Delete(&p->cs);
|
CriticalSection_Delete(&p->cs);
|
||||||
CriticalSection_Delete(&p->mtProgress.cs);
|
CriticalSection_Delete(&p->mtProgress.cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SRes MtCoder_Code(CMtCoder *p)
|
SRes MtCoder_Code(CMtCoder *p)
|
||||||
{
|
{
|
||||||
unsigned i, numThreads = p->numThreads;
|
unsigned numThreads = p->numThreadsMax;
|
||||||
|
unsigned numBlocksMax;
|
||||||
|
unsigned i;
|
||||||
SRes res = SZ_OK;
|
SRes res = SZ_OK;
|
||||||
p->res = SZ_OK;
|
|
||||||
|
if (numThreads > MTCODER__THREADS_MAX)
|
||||||
|
numThreads = MTCODER__THREADS_MAX;
|
||||||
|
numBlocksMax = MTCODER__GET_NUM_BLOCKS_FROM_THREADS(numThreads);
|
||||||
|
|
||||||
|
if (p->blockSize < ((UInt32)1 << 26)) numBlocksMax++;
|
||||||
|
if (p->blockSize < ((UInt32)1 << 24)) numBlocksMax++;
|
||||||
|
if (p->blockSize < ((UInt32)1 << 22)) numBlocksMax++;
|
||||||
|
|
||||||
|
if (numBlocksMax > MTCODER__BLOCKS_MAX)
|
||||||
|
numBlocksMax = MTCODER__BLOCKS_MAX;
|
||||||
|
|
||||||
|
if (p->blockSize != p->allocatedBufsSize)
|
||||||
|
{
|
||||||
|
for (i = 0; i < MTCODER__THREADS_MAX; i++)
|
||||||
|
{
|
||||||
|
CMtCoderThread *t = &p->threads[i];
|
||||||
|
if (t->inBuf)
|
||||||
|
{
|
||||||
|
ISzAlloc_Free(p->allocBig, t->inBuf);
|
||||||
|
t->inBuf = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p->allocatedBufsSize = p->blockSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->readRes = SZ_OK;
|
||||||
|
|
||||||
MtProgress_Init(&p->mtProgress, p->progress);
|
MtProgress_Init(&p->mtProgress, p->progress);
|
||||||
|
|
||||||
for (i = 0; i < numThreads; i++)
|
#ifdef MTCODER__USE_WRITE_THREAD
|
||||||
|
for (i = 0; i < numBlocksMax; i++)
|
||||||
|
{
|
||||||
|
RINOK_THREAD(ArEvent_OptCreate_And_Reset(&p->writeEvents[i]));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
RINOK_THREAD(ArEvent_OptCreate_And_Reset(&p->finishedEvent));
|
||||||
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
RINOK(CMtThread_Prepare(&p->threads[i]));
|
RINOK_THREAD(ArEvent_OptCreate_And_Reset(&p->readEvent));
|
||||||
|
|
||||||
|
if (Semaphore_IsCreated(&p->blocksSemaphore))
|
||||||
|
{
|
||||||
|
RINOK_THREAD(Semaphore_Close(&p->blocksSemaphore));
|
||||||
|
}
|
||||||
|
RINOK_THREAD(Semaphore_Create(&p->blocksSemaphore, numBlocksMax, numBlocksMax));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < numThreads; i++)
|
for (i = 0; i < MTCODER__BLOCKS_MAX - 1; i++)
|
||||||
|
p->freeBlockList[i] = i + 1;
|
||||||
|
p->freeBlockList[MTCODER__BLOCKS_MAX - 1] = (unsigned)(int)-1;
|
||||||
|
p->freeBlockHead = 0;
|
||||||
|
|
||||||
|
p->readProcessed = 0;
|
||||||
|
p->blockIndex = 0;
|
||||||
|
p->numBlocksMax = numBlocksMax;
|
||||||
|
p->stopReading = False;
|
||||||
|
|
||||||
|
#ifndef MTCODER__USE_WRITE_THREAD
|
||||||
|
p->writeIndex = 0;
|
||||||
|
p->writeRes = SZ_OK;
|
||||||
|
for (i = 0; i < MTCODER__BLOCKS_MAX; i++)
|
||||||
|
p->ReadyBlocks[i] = False;
|
||||||
|
p->numFinishedThreads = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
p->numStartedThreadsLimit = numThreads;
|
||||||
|
p->numStartedThreads = 0;
|
||||||
|
|
||||||
|
// for (i = 0; i < numThreads; i++)
|
||||||
{
|
{
|
||||||
CMtThread *t = &p->threads[i];
|
CMtCoderThread *nextThread = &p->threads[p->numStartedThreads++];
|
||||||
CLoopThread *lt = &t->thread;
|
RINOK(MtCoderThread_CreateAndStart(nextThread));
|
||||||
|
}
|
||||||
|
|
||||||
if (!Thread_WasCreated(<->thread))
|
RINOK_THREAD(Event_Set(&p->readEvent))
|
||||||
|
|
||||||
|
#ifdef MTCODER__USE_WRITE_THREAD
|
||||||
|
{
|
||||||
|
unsigned bi = 0;
|
||||||
|
|
||||||
|
for (;; bi++)
|
||||||
{
|
{
|
||||||
lt->func = ThreadFunc;
|
if (bi >= numBlocksMax)
|
||||||
lt->param = t;
|
bi = 0;
|
||||||
|
|
||||||
|
RINOK_THREAD(Event_Wait(&p->writeEvents[bi]))
|
||||||
|
|
||||||
if (LoopThread_Create(lt) != SZ_OK)
|
|
||||||
{
|
{
|
||||||
res = SZ_ERROR_THREAD;
|
const CMtCoderBlock *block = &p->blocks[bi];
|
||||||
break;
|
unsigned bufIndex = block->bufIndex;
|
||||||
|
BoolInt finished = block->finished;
|
||||||
|
if (res == SZ_OK && block->res != SZ_OK)
|
||||||
|
res = block->res;
|
||||||
|
|
||||||
|
if (bufIndex != (unsigned)(int)-1)
|
||||||
|
{
|
||||||
|
if (res == SZ_OK)
|
||||||
|
{
|
||||||
|
res = p->mtCallback->Write(p->mtCallbackObject, bufIndex);
|
||||||
|
if (res != SZ_OK)
|
||||||
|
MtProgress_SetError(&p->mtProgress, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
CriticalSection_Enter(&p->cs);
|
||||||
|
{
|
||||||
|
p->freeBlockList[bufIndex] = p->freeBlockHead;
|
||||||
|
p->freeBlockHead = bufIndex;
|
||||||
|
}
|
||||||
|
CriticalSection_Leave(&p->cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
RINOK_THREAD(Semaphore_Release1(&p->blocksSemaphore))
|
||||||
|
|
||||||
|
if (finished)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
WRes wres = Event_Wait(&p->finishedEvent);
|
||||||
|
res = MY_SRes_HRESULT_FROM_WRes(wres);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (res == SZ_OK)
|
if (res == SZ_OK)
|
||||||
{
|
res = p->readRes;
|
||||||
unsigned j;
|
|
||||||
for (i = 0; i < numThreads; i++)
|
|
||||||
{
|
|
||||||
CMtThread *t = &p->threads[i];
|
|
||||||
if (LoopThread_StartSubThread(&t->thread) != SZ_OK)
|
|
||||||
{
|
|
||||||
res = SZ_ERROR_THREAD;
|
|
||||||
p->threads[0].stopReading = True;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Event_Set(&p->threads[0].canWrite);
|
if (res == SZ_OK)
|
||||||
Event_Set(&p->threads[0].canRead);
|
res = p->mtProgress.res;
|
||||||
|
|
||||||
for (j = 0; j < i; j++)
|
#ifndef MTCODER__USE_WRITE_THREAD
|
||||||
LoopThread_WaitSubThread(&p->threads[j].thread);
|
if (res == SZ_OK)
|
||||||
}
|
res = p->writeRes;
|
||||||
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < numThreads; i++)
|
if (res != SZ_OK)
|
||||||
CMtThread_CloseEvents(&p->threads[i]);
|
MtCoder_Free(p);
|
||||||
return (res == SZ_OK) ? p->res : res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
153
C/MtCoder.h
153
C/MtCoder.h
@@ -1,102 +1,141 @@
|
|||||||
/* MtCoder.h -- Multi-thread Coder
|
/* MtCoder.h -- Multi-thread Coder
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __MT_CODER_H
|
#ifndef __MT_CODER_H
|
||||||
#define __MT_CODER_H
|
#define __MT_CODER_H
|
||||||
|
|
||||||
#include "Threads.h"
|
#include "MtDec.h"
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
typedef struct
|
/*
|
||||||
{
|
if ( defined MTCODER__USE_WRITE_THREAD) : main thread writes all data blocks to output stream
|
||||||
CThread thread;
|
if (not defined MTCODER__USE_WRITE_THREAD) : any coder thread can write data blocks to output stream
|
||||||
CAutoResetEvent startEvent;
|
*/
|
||||||
CAutoResetEvent finishedEvent;
|
/* #define MTCODER__USE_WRITE_THREAD */
|
||||||
int stop;
|
|
||||||
|
|
||||||
THREAD_FUNC_TYPE func;
|
|
||||||
LPVOID param;
|
|
||||||
THREAD_FUNC_RET_TYPE res;
|
|
||||||
} CLoopThread;
|
|
||||||
|
|
||||||
void LoopThread_Construct(CLoopThread *p);
|
|
||||||
void LoopThread_Close(CLoopThread *p);
|
|
||||||
WRes LoopThread_Create(CLoopThread *p);
|
|
||||||
WRes LoopThread_StopAndWait(CLoopThread *p);
|
|
||||||
WRes LoopThread_StartSubThread(CLoopThread *p);
|
|
||||||
WRes LoopThread_WaitSubThread(CLoopThread *p);
|
|
||||||
|
|
||||||
#ifndef _7ZIP_ST
|
#ifndef _7ZIP_ST
|
||||||
#define NUM_MT_CODER_THREADS_MAX 32
|
#define MTCODER__GET_NUM_BLOCKS_FROM_THREADS(numThreads) ((numThreads) + (numThreads) / 8 + 1)
|
||||||
|
#define MTCODER__THREADS_MAX 64
|
||||||
|
#define MTCODER__BLOCKS_MAX (MTCODER__GET_NUM_BLOCKS_FROM_THREADS(MTCODER__THREADS_MAX) + 3)
|
||||||
#else
|
#else
|
||||||
#define NUM_MT_CODER_THREADS_MAX 1
|
#define MTCODER__THREADS_MAX 1
|
||||||
|
#define MTCODER__BLOCKS_MAX 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UInt64 totalInSize;
|
ICompressProgress vt;
|
||||||
UInt64 totalOutSize;
|
CMtProgress *mtProgress;
|
||||||
ICompressProgress *progress;
|
UInt64 inSize;
|
||||||
SRes res;
|
UInt64 outSize;
|
||||||
CCriticalSection cs;
|
} CMtProgressThunk;
|
||||||
UInt64 inSizes[NUM_MT_CODER_THREADS_MAX];
|
|
||||||
UInt64 outSizes[NUM_MT_CODER_THREADS_MAX];
|
void MtProgressThunk_CreateVTable(CMtProgressThunk *p);
|
||||||
} CMtProgress;
|
|
||||||
|
#define MtProgressThunk_Init(p) { (p)->inSize = 0; (p)->outSize = 0; }
|
||||||
|
|
||||||
SRes MtProgress_Set(CMtProgress *p, unsigned index, UInt64 inSize, UInt64 outSize);
|
|
||||||
|
|
||||||
struct _CMtCoder;
|
struct _CMtCoder;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
struct _CMtCoder *mtCoder;
|
struct _CMtCoder *mtCoder;
|
||||||
Byte *outBuf;
|
|
||||||
size_t outBufSize;
|
|
||||||
Byte *inBuf;
|
|
||||||
size_t inBufSize;
|
|
||||||
unsigned index;
|
unsigned index;
|
||||||
CLoopThread thread;
|
int stop;
|
||||||
|
Byte *inBuf;
|
||||||
|
|
||||||
Bool stopReading;
|
CAutoResetEvent startEvent;
|
||||||
Bool stopWriting;
|
CThread thread;
|
||||||
CAutoResetEvent canRead;
|
} CMtCoderThread;
|
||||||
CAutoResetEvent canWrite;
|
|
||||||
} CMtThread;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct IMtCoderCallback IMtCoderCallback;
|
typedef struct
|
||||||
struct IMtCoderCallback
|
|
||||||
{
|
{
|
||||||
SRes (*Code)(const IMtCoderCallback *p, unsigned index, Byte *dest, size_t *destSize,
|
SRes (*Code)(void *p, unsigned coderIndex, unsigned outBufIndex,
|
||||||
const Byte *src, size_t srcSize, int finished);
|
const Byte *src, size_t srcSize, int finished);
|
||||||
};
|
SRes (*Write)(void *p, unsigned outBufIndex);
|
||||||
#define IMtCoderCallback_Code(p, index, dest, destSize, src, srcSize, finished) (p)->Code(p, index, dest, destSize, src, srcSize, finished)
|
} IMtCoderCallback2;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SRes res;
|
||||||
|
unsigned bufIndex;
|
||||||
|
BoolInt finished;
|
||||||
|
} CMtCoderBlock;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _CMtCoder
|
typedef struct _CMtCoder
|
||||||
{
|
{
|
||||||
size_t blockSize;
|
/* input variables */
|
||||||
size_t destBlockSize;
|
|
||||||
unsigned numThreads;
|
size_t blockSize; /* size of input block */
|
||||||
|
unsigned numThreadsMax;
|
||||||
|
UInt64 expectedDataSize;
|
||||||
|
|
||||||
ISeqInStream *inStream;
|
ISeqInStream *inStream;
|
||||||
ISeqOutStream *outStream;
|
const Byte *inData;
|
||||||
ICompressProgress *progress;
|
size_t inDataSize;
|
||||||
ISzAllocPtr alloc;
|
|
||||||
|
ICompressProgress *progress;
|
||||||
|
ISzAllocPtr allocBig;
|
||||||
|
|
||||||
|
IMtCoderCallback2 *mtCallback;
|
||||||
|
void *mtCallbackObject;
|
||||||
|
|
||||||
|
|
||||||
|
/* internal variables */
|
||||||
|
|
||||||
|
size_t allocatedBufsSize;
|
||||||
|
|
||||||
|
CAutoResetEvent readEvent;
|
||||||
|
CSemaphore blocksSemaphore;
|
||||||
|
|
||||||
|
BoolInt stopReading;
|
||||||
|
SRes readRes;
|
||||||
|
|
||||||
|
#ifdef MTCODER__USE_WRITE_THREAD
|
||||||
|
CAutoResetEvent writeEvents[MTCODER__BLOCKS_MAX];
|
||||||
|
#else
|
||||||
|
CAutoResetEvent finishedEvent;
|
||||||
|
SRes writeRes;
|
||||||
|
unsigned writeIndex;
|
||||||
|
Byte ReadyBlocks[MTCODER__BLOCKS_MAX];
|
||||||
|
LONG numFinishedThreads;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
unsigned numStartedThreadsLimit;
|
||||||
|
unsigned numStartedThreads;
|
||||||
|
|
||||||
|
unsigned numBlocksMax;
|
||||||
|
unsigned blockIndex;
|
||||||
|
UInt64 readProcessed;
|
||||||
|
|
||||||
IMtCoderCallback *mtCallback;
|
|
||||||
CCriticalSection cs;
|
CCriticalSection cs;
|
||||||
SRes res;
|
|
||||||
|
unsigned freeBlockHead;
|
||||||
|
unsigned freeBlockList[MTCODER__BLOCKS_MAX];
|
||||||
|
|
||||||
CMtProgress mtProgress;
|
CMtProgress mtProgress;
|
||||||
CMtThread threads[NUM_MT_CODER_THREADS_MAX];
|
CMtCoderBlock blocks[MTCODER__BLOCKS_MAX];
|
||||||
|
CMtCoderThread threads[MTCODER__THREADS_MAX];
|
||||||
} CMtCoder;
|
} CMtCoder;
|
||||||
|
|
||||||
void MtCoder_Construct(CMtCoder* p);
|
|
||||||
void MtCoder_Destruct(CMtCoder* p);
|
void MtCoder_Construct(CMtCoder *p);
|
||||||
|
void MtCoder_Destruct(CMtCoder *p);
|
||||||
SRes MtCoder_Code(CMtCoder *p);
|
SRes MtCoder_Code(CMtCoder *p);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
201
C/MtDec.h
Normal file
201
C/MtDec.h
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
/* MtDec.h -- Multi-thread Decoder
|
||||||
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __MT_DEC_H
|
||||||
|
#define __MT_DEC_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
#include "Threads.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
#define MTDEC__THREADS_MAX 32
|
||||||
|
#else
|
||||||
|
#define MTDEC__THREADS_MAX 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ICompressProgress *progress;
|
||||||
|
SRes res;
|
||||||
|
UInt64 totalInSize;
|
||||||
|
UInt64 totalOutSize;
|
||||||
|
CCriticalSection cs;
|
||||||
|
} CMtProgress;
|
||||||
|
|
||||||
|
void MtProgress_Init(CMtProgress *p, ICompressProgress *progress);
|
||||||
|
SRes MtProgress_Progress_ST(CMtProgress *p);
|
||||||
|
SRes MtProgress_ProgressAdd(CMtProgress *p, UInt64 inSize, UInt64 outSize);
|
||||||
|
SRes MtProgress_GetError(CMtProgress *p);
|
||||||
|
void MtProgress_SetError(CMtProgress *p, SRes res);
|
||||||
|
|
||||||
|
struct _CMtDec;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
struct _CMtDec *mtDec;
|
||||||
|
unsigned index;
|
||||||
|
void *inBuf;
|
||||||
|
|
||||||
|
size_t inDataSize_Start; // size of input data in start block
|
||||||
|
UInt64 inDataSize; // total size of input data in all blocks
|
||||||
|
|
||||||
|
CThread thread;
|
||||||
|
CAutoResetEvent canRead;
|
||||||
|
CAutoResetEvent canWrite;
|
||||||
|
void *allocaPtr;
|
||||||
|
} CMtDecThread;
|
||||||
|
|
||||||
|
void MtDecThread_FreeInBufs(CMtDecThread *t);
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
MTDEC_PARSE_CONTINUE, // continue this block with more input data
|
||||||
|
MTDEC_PARSE_OVERFLOW, // MT buffers overflow, need switch to single-thread
|
||||||
|
MTDEC_PARSE_NEW, // new block
|
||||||
|
MTDEC_PARSE_END // end of block threading. But we still can return to threading after Write(&needContinue)
|
||||||
|
} EMtDecParseState;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
// in
|
||||||
|
int startCall;
|
||||||
|
const Byte *src;
|
||||||
|
size_t srcSize;
|
||||||
|
// in : (srcSize == 0) is allowed
|
||||||
|
// out : it's allowed to return less that actually was used ?
|
||||||
|
int srcFinished;
|
||||||
|
|
||||||
|
// out
|
||||||
|
EMtDecParseState state;
|
||||||
|
BoolInt canCreateNewThread;
|
||||||
|
UInt64 outPos; // check it (size_t)
|
||||||
|
} CMtDecCallbackInfo;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void (*Parse)(void *p, unsigned coderIndex, CMtDecCallbackInfo *ci);
|
||||||
|
|
||||||
|
// PreCode() and Code():
|
||||||
|
// (SRes_return_result != SZ_OK) means stop decoding, no need another blocks
|
||||||
|
SRes (*PreCode)(void *p, unsigned coderIndex);
|
||||||
|
SRes (*Code)(void *p, unsigned coderIndex,
|
||||||
|
const Byte *src, size_t srcSize, int srcFinished,
|
||||||
|
UInt64 *inCodePos, UInt64 *outCodePos, int *stop);
|
||||||
|
// stop - means stop another Code calls
|
||||||
|
|
||||||
|
|
||||||
|
/* Write() must be called, if Parse() was called
|
||||||
|
set (needWrite) if
|
||||||
|
{
|
||||||
|
&& (was not interrupted by progress)
|
||||||
|
&& (was not interrupted in previous block)
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (*needContinue), decoder still need to continue decoding with new iteration,
|
||||||
|
even after MTDEC_PARSE_END
|
||||||
|
if (*canRecode), we didn't flush current block data, so we still can decode current block later.
|
||||||
|
*/
|
||||||
|
SRes (*Write)(void *p, unsigned coderIndex,
|
||||||
|
BoolInt needWriteToStream,
|
||||||
|
const Byte *src, size_t srcSize,
|
||||||
|
// int srcFinished,
|
||||||
|
BoolInt *needContinue,
|
||||||
|
BoolInt *canRecode);
|
||||||
|
} IMtDecCallback;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _CMtDec
|
||||||
|
{
|
||||||
|
/* input variables */
|
||||||
|
|
||||||
|
size_t inBufSize; /* size of input block */
|
||||||
|
unsigned numThreadsMax;
|
||||||
|
// size_t inBlockMax;
|
||||||
|
unsigned numThreadsMax_2;
|
||||||
|
|
||||||
|
ISeqInStream *inStream;
|
||||||
|
// const Byte *inData;
|
||||||
|
// size_t inDataSize;
|
||||||
|
|
||||||
|
ICompressProgress *progress;
|
||||||
|
ISzAllocPtr alloc;
|
||||||
|
|
||||||
|
IMtDecCallback *mtCallback;
|
||||||
|
void *mtCallbackObject;
|
||||||
|
|
||||||
|
|
||||||
|
/* internal variables */
|
||||||
|
|
||||||
|
size_t allocatedBufsSize;
|
||||||
|
|
||||||
|
BoolInt exitThread;
|
||||||
|
WRes exitThreadWRes;
|
||||||
|
|
||||||
|
UInt64 blockIndex;
|
||||||
|
BoolInt isAllocError;
|
||||||
|
BoolInt overflow;
|
||||||
|
SRes threadingErrorSRes;
|
||||||
|
|
||||||
|
BoolInt needContinue;
|
||||||
|
|
||||||
|
// CAutoResetEvent finishedEvent;
|
||||||
|
|
||||||
|
SRes readRes;
|
||||||
|
SRes codeRes;
|
||||||
|
|
||||||
|
BoolInt wasInterrupted;
|
||||||
|
|
||||||
|
unsigned numStartedThreads_Limit;
|
||||||
|
unsigned numStartedThreads;
|
||||||
|
|
||||||
|
Byte *crossBlock;
|
||||||
|
size_t crossStart;
|
||||||
|
size_t crossEnd;
|
||||||
|
UInt64 readProcessed;
|
||||||
|
BoolInt readWasFinished;
|
||||||
|
UInt64 inProcessed;
|
||||||
|
|
||||||
|
unsigned filledThreadStart;
|
||||||
|
unsigned numFilledThreads;
|
||||||
|
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
BoolInt needInterrupt;
|
||||||
|
UInt64 interruptIndex;
|
||||||
|
CMtProgress mtProgress;
|
||||||
|
CMtDecThread threads[MTDEC__THREADS_MAX];
|
||||||
|
#endif
|
||||||
|
} CMtDec;
|
||||||
|
|
||||||
|
|
||||||
|
void MtDec_Construct(CMtDec *p);
|
||||||
|
void MtDec_Destruct(CMtDec *p);
|
||||||
|
|
||||||
|
/*
|
||||||
|
MtDec_Code() returns:
|
||||||
|
SZ_OK - in most cases
|
||||||
|
MY_SRes_HRESULT_FROM_WRes(WRes_error) - in case of unexpected error in threading function
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes MtDec_Code(CMtDec *p);
|
||||||
|
Byte *MtDec_GetCrossBuff(CMtDec *p);
|
||||||
|
|
||||||
|
int MtDec_PrepareRead(CMtDec *p);
|
||||||
|
const Byte *MtDec_Read(CMtDec *p, size_t *inLim);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Ppmd7.c -- PPMdH codec
|
/* Ppmd7.c -- PPMdH codec
|
||||||
2017-04-03 : Igor Pavlov : Public domain
|
2018-07-04 : 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 "Precomp.h"
|
||||||
@@ -95,7 +95,7 @@ void Ppmd7_Free(CPpmd7 *p, ISzAllocPtr alloc)
|
|||||||
p->Base = 0;
|
p->Base = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAllocPtr alloc)
|
BoolInt Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAllocPtr alloc)
|
||||||
{
|
{
|
||||||
if (!p->Base || p->Size != size)
|
if (!p->Base || p->Size != size)
|
||||||
{
|
{
|
||||||
@@ -342,7 +342,7 @@ void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder)
|
|||||||
p->DummySee.Count = 64; /* unused */
|
p->DummySee.Count = 64; /* unused */
|
||||||
}
|
}
|
||||||
|
|
||||||
static CTX_PTR CreateSuccessors(CPpmd7 *p, Bool skip)
|
static CTX_PTR CreateSuccessors(CPpmd7 *p, BoolInt skip)
|
||||||
{
|
{
|
||||||
CPpmd_State upState;
|
CPpmd_State upState;
|
||||||
CTX_PTR c = p->MinContext;
|
CTX_PTR c = p->MinContext;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Ppmd7.h -- PPMdH compression codec
|
/* Ppmd7.h -- PPMdH compression codec
|
||||||
2017-04-03 : Igor Pavlov : Public domain
|
2018-07-04 : 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 */
|
||||||
|
|
||||||
/* This code supports virtual RangeDecoder and includes the implementation
|
/* This code supports virtual RangeDecoder and includes the implementation
|
||||||
@@ -60,7 +60,7 @@ typedef struct
|
|||||||
} CPpmd7;
|
} CPpmd7;
|
||||||
|
|
||||||
void Ppmd7_Construct(CPpmd7 *p);
|
void Ppmd7_Construct(CPpmd7 *p);
|
||||||
Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAllocPtr alloc);
|
BoolInt Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAllocPtr alloc);
|
||||||
void Ppmd7_Free(CPpmd7 *p, ISzAllocPtr alloc);
|
void Ppmd7_Free(CPpmd7 *p, ISzAllocPtr alloc);
|
||||||
void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder);
|
void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder);
|
||||||
#define Ppmd7_WasAllocated(p) ((p)->Base != NULL)
|
#define Ppmd7_WasAllocated(p) ((p)->Base != NULL)
|
||||||
@@ -115,7 +115,7 @@ typedef struct
|
|||||||
} CPpmd7z_RangeDec;
|
} CPpmd7z_RangeDec;
|
||||||
|
|
||||||
void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p);
|
void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p);
|
||||||
Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p);
|
BoolInt Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p);
|
||||||
#define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0)
|
#define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0)
|
||||||
|
|
||||||
int Ppmd7_DecodeSymbol(CPpmd7 *p, const IPpmd7_RangeDec *rc);
|
int Ppmd7_DecodeSymbol(CPpmd7 *p, const IPpmd7_RangeDec *rc);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Ppmd7Dec.c -- PPMdH Decoder
|
/* Ppmd7Dec.c -- PPMdH Decoder
|
||||||
2017-04-03 : Igor Pavlov : Public domain
|
2018-07-04 : 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 "Precomp.h"
|
||||||
@@ -8,7 +8,7 @@ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
|||||||
|
|
||||||
#define kTopValue (1 << 24)
|
#define kTopValue (1 << 24)
|
||||||
|
|
||||||
Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p)
|
BoolInt Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
p->Code = 0;
|
p->Code = 0;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Ppmd8.c -- PPMdI codec
|
/* Ppmd8.c -- PPMdI codec
|
||||||
2017-04-03 : Igor Pavlov : Public domain
|
2018-07-04 : 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 "Precomp.h"
|
||||||
@@ -93,7 +93,7 @@ void Ppmd8_Free(CPpmd8 *p, ISzAllocPtr alloc)
|
|||||||
p->Base = 0;
|
p->Base = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size, ISzAllocPtr alloc)
|
BoolInt Ppmd8_Alloc(CPpmd8 *p, UInt32 size, ISzAllocPtr alloc)
|
||||||
{
|
{
|
||||||
if (!p->Base || p->Size != size)
|
if (!p->Base || p->Size != size)
|
||||||
{
|
{
|
||||||
@@ -605,7 +605,7 @@ static void RestoreModel(CPpmd8 *p, CTX_PTR c1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CTX_PTR CreateSuccessors(CPpmd8 *p, Bool skip, CPpmd_State *s1, CTX_PTR c)
|
static CTX_PTR CreateSuccessors(CPpmd8 *p, BoolInt skip, CPpmd_State *s1, CTX_PTR c)
|
||||||
{
|
{
|
||||||
CPpmd_State upState;
|
CPpmd_State upState;
|
||||||
Byte flags;
|
Byte flags;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Ppmd8.h -- PPMdI codec
|
/* Ppmd8.h -- PPMdI codec
|
||||||
2017-04-03 : Igor Pavlov : Public domain
|
2018-07-04 : 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 */
|
||||||
@@ -86,7 +86,7 @@ typedef struct
|
|||||||
} CPpmd8;
|
} CPpmd8;
|
||||||
|
|
||||||
void Ppmd8_Construct(CPpmd8 *p);
|
void Ppmd8_Construct(CPpmd8 *p);
|
||||||
Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size, ISzAllocPtr alloc);
|
BoolInt Ppmd8_Alloc(CPpmd8 *p, UInt32 size, ISzAllocPtr alloc);
|
||||||
void Ppmd8_Free(CPpmd8 *p, ISzAllocPtr alloc);
|
void Ppmd8_Free(CPpmd8 *p, ISzAllocPtr alloc);
|
||||||
void Ppmd8_Init(CPpmd8 *p, unsigned maxOrder, unsigned restoreMethod);
|
void Ppmd8_Init(CPpmd8 *p, unsigned maxOrder, unsigned restoreMethod);
|
||||||
#define Ppmd8_WasAllocated(p) ((p)->Base != NULL)
|
#define Ppmd8_WasAllocated(p) ((p)->Base != NULL)
|
||||||
@@ -121,7 +121,7 @@ CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked, UInt32 *scale);
|
|||||||
|
|
||||||
/* ---------- Decode ---------- */
|
/* ---------- Decode ---------- */
|
||||||
|
|
||||||
Bool Ppmd8_RangeDec_Init(CPpmd8 *p);
|
BoolInt Ppmd8_RangeDec_Init(CPpmd8 *p);
|
||||||
#define Ppmd8_RangeDec_IsFinishedOK(p) ((p)->Code == 0)
|
#define Ppmd8_RangeDec_IsFinishedOK(p) ((p)->Code == 0)
|
||||||
int Ppmd8_DecodeSymbol(CPpmd8 *p); /* returns: -1 as EndMarker, -2 as DataError */
|
int Ppmd8_DecodeSymbol(CPpmd8 *p); /* returns: -1 as EndMarker, -2 as DataError */
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Ppmd8Dec.c -- PPMdI Decoder
|
/* Ppmd8Dec.c -- PPMdI Decoder
|
||||||
2017-04-03 : Igor Pavlov : Public domain
|
2018-07-04 : 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 */
|
||||||
@@ -11,7 +11,7 @@ This code is based on:
|
|||||||
#define kTop (1 << 24)
|
#define kTop (1 << 24)
|
||||||
#define kBot (1 << 15)
|
#define kBot (1 << 15)
|
||||||
|
|
||||||
Bool Ppmd8_RangeDec_Init(CPpmd8 *p)
|
BoolInt Ppmd8_RangeDec_Init(CPpmd8 *p)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
p->Low = 0;
|
p->Low = 0;
|
||||||
|
|||||||
14
C/Threads.c
14
C/Threads.c
@@ -1,5 +1,5 @@
|
|||||||
/* Threads.c -- multithreading library
|
/* Threads.c -- multithreading library
|
||||||
2014-09-21 : Igor Pavlov : Public domain */
|
2017-06-26 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -12,18 +12,20 @@
|
|||||||
static WRes GetError()
|
static WRes GetError()
|
||||||
{
|
{
|
||||||
DWORD res = GetLastError();
|
DWORD res = GetLastError();
|
||||||
return (res) ? (WRes)(res) : 1;
|
return res ? (WRes)res : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
WRes HandleToWRes(HANDLE h) { return (h != 0) ? 0 : GetError(); }
|
static WRes HandleToWRes(HANDLE h) { return (h != NULL) ? 0 : GetError(); }
|
||||||
WRes BOOLToWRes(BOOL v) { return v ? 0 : GetError(); }
|
static WRes BOOLToWRes(BOOL v) { return v ? 0 : GetError(); }
|
||||||
|
|
||||||
WRes HandlePtr_Close(HANDLE *p)
|
WRes HandlePtr_Close(HANDLE *p)
|
||||||
{
|
{
|
||||||
if (*p != NULL)
|
if (*p != NULL)
|
||||||
|
{
|
||||||
if (!CloseHandle(*p))
|
if (!CloseHandle(*p))
|
||||||
return GetError();
|
return GetError();
|
||||||
*p = NULL;
|
*p = NULL;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param)
|
|||||||
return HandleToWRes(*p);
|
return HandleToWRes(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
WRes Event_Create(CEvent *p, BOOL manualReset, int signaled)
|
static WRes Event_Create(CEvent *p, BOOL manualReset, int signaled)
|
||||||
{
|
{
|
||||||
*p = CreateEvent(NULL, manualReset, (signaled ? TRUE : FALSE), NULL);
|
*p = CreateEvent(NULL, manualReset, (signaled ? TRUE : FALSE), NULL);
|
||||||
return HandleToWRes(*p);
|
return HandleToWRes(*p);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Threads.h -- multithreading library
|
/* Threads.h -- multithreading library
|
||||||
2013-11-12 : Igor Pavlov : Public domain */
|
2017-06-18 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __7Z_THREADS_H
|
#ifndef __7Z_THREADS_H
|
||||||
#define __7Z_THREADS_H
|
#define __7Z_THREADS_H
|
||||||
@@ -49,7 +49,8 @@ WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled);
|
|||||||
WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p);
|
WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p);
|
||||||
|
|
||||||
typedef HANDLE CSemaphore;
|
typedef HANDLE CSemaphore;
|
||||||
#define Semaphore_Construct(p) (*p) = NULL
|
#define Semaphore_Construct(p) *(p) = NULL
|
||||||
|
#define Semaphore_IsCreated(p) (*(p) != NULL)
|
||||||
#define Semaphore_Close(p) HandlePtr_Close(p)
|
#define Semaphore_Close(p) HandlePtr_Close(p)
|
||||||
#define Semaphore_Wait(p) Handle_WaitObject(*(p))
|
#define Semaphore_Wait(p) Handle_WaitObject(*(p))
|
||||||
WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount);
|
WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount);
|
||||||
|
|||||||
241
C/Util/7z/7z.dsp
241
C/Util/7z/7z.dsp
@@ -1,241 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="7z" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
|
||||||
|
|
||||||
CFG=7z - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "7z.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "7z.mak" CFG="7z - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "7z - Win32 Release" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE "7z - Win32 Debug" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "7z - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FAcs /Yu"Precomp.h" /FD /c
|
|
||||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 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
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "7z - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# 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 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 RSC /l 0x419 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 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
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "7z - Win32 Release"
|
|
||||||
# Name "7z - Win32 Debug"
|
|
||||||
# Begin Group "Common"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7z.h
|
|
||||||
# End 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
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zBuf.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zCrc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zCrc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zCrcOpt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zDec.c
|
|
||||||
# ADD CPP /D "_7ZIP_PPMD_SUPPPORT"
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zFile.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zFile.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zStream.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zTypes.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bcj2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bcj2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bra.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bra.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bra86.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\BraIA64.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\CpuArch.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\CpuArch.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Delta.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Delta.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Lzma2Dec.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Lzma2Dec.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaDec.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaDec.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Ppmd.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Ppmd7.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Ppmd7.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Ppmd7Dec.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Spec"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Compiler.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\Precomp.c
|
|
||||||
# ADD CPP /Yc"Precomp.h"
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\Precomp.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zMain.c
|
|
||||||
# End Source File
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
|
||||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "7z"=.\7z.dsp - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Global:
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<3>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* 7zMain.c - Test application for 7z Decoder
|
/* 7zMain.c - Test application for 7z Decoder
|
||||||
2017-04-05 : Igor Pavlov : Public domain */
|
2019-02-02 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s
|
|||||||
char defaultChar = '_';
|
char defaultChar = '_';
|
||||||
BOOL defUsed;
|
BOOL defUsed;
|
||||||
unsigned numChars = 0;
|
unsigned numChars = 0;
|
||||||
numChars = WideCharToMultiByte(codePage, 0, s, len, (char *)buf->data, size, &defaultChar, &defUsed);
|
numChars = WideCharToMultiByte(codePage, 0, (LPCWSTR)s, len, (char *)buf->data, size, &defaultChar, &defUsed);
|
||||||
if (numChars == 0 || numChars >= size)
|
if (numChars == 0 || numChars >= size)
|
||||||
return SZ_ERROR_FAIL;
|
return SZ_ERROR_FAIL;
|
||||||
buf->data[numChars] = 0;
|
buf->data[numChars] = 0;
|
||||||
@@ -202,7 +202,7 @@ static WRes MyCreateDir(const UInt16 *name)
|
|||||||
{
|
{
|
||||||
#ifdef USE_WINDOWS_FILE
|
#ifdef USE_WINDOWS_FILE
|
||||||
|
|
||||||
return CreateDirectoryW(name, NULL) ? 0 : GetLastError();
|
return CreateDirectoryW((LPCWSTR)name, NULL) ? 0 : GetLastError();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ static WRes MyCreateDir(const UInt16 *name)
|
|||||||
static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name)
|
static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name)
|
||||||
{
|
{
|
||||||
#ifdef USE_WINDOWS_FILE
|
#ifdef USE_WINDOWS_FILE
|
||||||
return OutFile_OpenW(p, name);
|
return OutFile_OpenW(p, (LPCWSTR)name);
|
||||||
#else
|
#else
|
||||||
CBuf buf;
|
CBuf buf;
|
||||||
WRes res;
|
WRes res;
|
||||||
@@ -354,7 +354,7 @@ static void PrintError(char *s)
|
|||||||
PrintLF();
|
PrintLF();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetAttribString(UInt32 wa, Bool isDir, char *s)
|
static void GetAttribString(UInt32 wa, BoolInt isDir, char *s)
|
||||||
{
|
{
|
||||||
#ifdef USE_WINDOWS_FILE
|
#ifdef USE_WINDOWS_FILE
|
||||||
s[0] = (char)(((wa & FILE_ATTRIBUTE_DIRECTORY) != 0 || isDir) ? 'D' : '.');
|
s[0] = (char)(((wa & FILE_ATTRIBUTE_DIRECTORY) != 0 || isDir) ? 'D' : '.');
|
||||||
@@ -430,7 +430,7 @@ int MY_CDECL main(int numargs, char *args[])
|
|||||||
res = SZ_OK;
|
res = SZ_OK;
|
||||||
|
|
||||||
{
|
{
|
||||||
lookStream.buf = ISzAlloc_Alloc(&allocImp, kInputBufSize);
|
lookStream.buf = (Byte *)ISzAlloc_Alloc(&allocImp, kInputBufSize);
|
||||||
if (!lookStream.buf)
|
if (!lookStream.buf)
|
||||||
res = SZ_ERROR_MEM;
|
res = SZ_ERROR_MEM;
|
||||||
else
|
else
|
||||||
@@ -607,6 +607,31 @@ int MY_CDECL main(int numargs, char *args[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_WINDOWS_FILE
|
||||||
|
{
|
||||||
|
FILETIME mtime, ctime;
|
||||||
|
FILETIME *mtimePtr = NULL;
|
||||||
|
FILETIME *ctimePtr = NULL;
|
||||||
|
|
||||||
|
if (SzBitWithVals_Check(&db.MTime, i))
|
||||||
|
{
|
||||||
|
const CNtfsFileTime *t = &db.MTime.Vals[i];
|
||||||
|
mtime.dwLowDateTime = (DWORD)(t->Low);
|
||||||
|
mtime.dwHighDateTime = (DWORD)(t->High);
|
||||||
|
mtimePtr = &mtime;
|
||||||
|
}
|
||||||
|
if (SzBitWithVals_Check(&db.CTime, i))
|
||||||
|
{
|
||||||
|
const CNtfsFileTime *t = &db.CTime.Vals[i];
|
||||||
|
ctime.dwLowDateTime = (DWORD)(t->Low);
|
||||||
|
ctime.dwHighDateTime = (DWORD)(t->High);
|
||||||
|
ctimePtr = &ctime;
|
||||||
|
}
|
||||||
|
if (mtimePtr || ctimePtr)
|
||||||
|
SetFileTime(outFile.handle, ctimePtr, NULL, mtimePtr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (File_Close(&outFile))
|
if (File_Close(&outFile))
|
||||||
{
|
{
|
||||||
PrintError("can not close output file");
|
PrintError("can not close output file");
|
||||||
@@ -616,7 +641,14 @@ int MY_CDECL main(int numargs, char *args[])
|
|||||||
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
#ifdef USE_WINDOWS_FILE
|
||||||
if (SzBitWithVals_Check(&db.Attribs, i))
|
if (SzBitWithVals_Check(&db.Attribs, i))
|
||||||
SetFileAttributesW(destPath, db.Attribs.Vals[i]);
|
{
|
||||||
|
UInt32 attrib = db.Attribs.Vals[i];
|
||||||
|
/* p7zip stores posix attributes in high 16 bits and adds 0x8000 as marker.
|
||||||
|
We remove posix bits, if we detect posix mode field */
|
||||||
|
if ((attrib & 0xF0000000) != 0)
|
||||||
|
attrib &= 0x7FFF;
|
||||||
|
SetFileAttributesW((LPCWSTR)destPath, attrib);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
PrintLF();
|
PrintLF();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* 7zipInstall.c - 7-Zip Installer
|
/* 7zipInstall.c - 7-Zip Installer
|
||||||
2017-04-04 : Igor Pavlov : Public domain */
|
2019-02-19 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -89,9 +89,9 @@ static LPCWSTR const k_Reg_CLSID_7zip_Inproc = L"CLSID\\" k_7zip_CLSID L"\\Inpro
|
|||||||
|
|
||||||
#define g_AllUsers True
|
#define g_AllUsers True
|
||||||
|
|
||||||
static Bool g_Install_was_Pressed;
|
static BoolInt g_Install_was_Pressed;
|
||||||
static Bool g_Finished;
|
static BoolInt g_Finished;
|
||||||
static Bool g_SilentMode;
|
static BoolInt g_SilentMode;
|
||||||
|
|
||||||
static HWND g_HWND;
|
static HWND g_HWND;
|
||||||
static HWND g_Path_HWND;
|
static HWND g_Path_HWND;
|
||||||
@@ -121,13 +121,51 @@ static void PrintErrorMessage(const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef DWORD (WINAPI * Func_GetFileVersionInfoSizeW)(LPCWSTR lptstrFilename, LPDWORD lpdwHandle);
|
||||||
|
typedef BOOL (WINAPI * Func_GetFileVersionInfoW)(LPCWSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData);
|
||||||
|
typedef BOOL (WINAPI * Func_VerQueryValueW)(const LPVOID pBlock, LPWSTR lpSubBlock, LPVOID * lplpBuffer, PUINT puLen);
|
||||||
|
|
||||||
|
static HMODULE g_version_dll_hModule;
|
||||||
|
|
||||||
static DWORD GetFileVersion(LPCWSTR s)
|
static DWORD GetFileVersion(LPCWSTR s)
|
||||||
{
|
{
|
||||||
DWORD size = 0;
|
DWORD size = 0;
|
||||||
BYTE *vi = NULL;
|
void *vi = NULL;
|
||||||
DWORD version = 0;
|
DWORD version = 0;
|
||||||
|
|
||||||
size = GetFileVersionInfoSizeW(s, NULL);
|
Func_GetFileVersionInfoSizeW my_GetFileVersionInfoSizeW;
|
||||||
|
Func_GetFileVersionInfoW my_GetFileVersionInfoW;
|
||||||
|
Func_VerQueryValueW my_VerQueryValueW;
|
||||||
|
|
||||||
|
if (!g_version_dll_hModule)
|
||||||
|
{
|
||||||
|
wchar_t buf[MAX_PATH + 100];
|
||||||
|
{
|
||||||
|
unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2);
|
||||||
|
if (len == 0 || len > MAX_PATH)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
unsigned pos = (unsigned)lstrlenW(buf);
|
||||||
|
if (buf[pos - 1] != '\\')
|
||||||
|
buf[pos++] = '\\';
|
||||||
|
lstrcpyW(buf + pos, L"version.dll");
|
||||||
|
}
|
||||||
|
g_version_dll_hModule = LoadLibraryW(buf);
|
||||||
|
if (!g_version_dll_hModule)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
my_GetFileVersionInfoSizeW = (Func_GetFileVersionInfoSizeW)GetProcAddress(g_version_dll_hModule, "GetFileVersionInfoSizeW");
|
||||||
|
my_GetFileVersionInfoW = (Func_GetFileVersionInfoW)GetProcAddress(g_version_dll_hModule, "GetFileVersionInfoW");
|
||||||
|
my_VerQueryValueW = (Func_VerQueryValueW)GetProcAddress(g_version_dll_hModule, "VerQueryValueW");
|
||||||
|
|
||||||
|
if (!my_GetFileVersionInfoSizeW
|
||||||
|
|| !my_GetFileVersionInfoW
|
||||||
|
|| !my_VerQueryValueW)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
size = my_GetFileVersionInfoSizeW(s, NULL);
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -135,11 +173,11 @@ static DWORD GetFileVersion(LPCWSTR s)
|
|||||||
if (!vi)
|
if (!vi)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (GetFileVersionInfoW(s, 0, size, vi))
|
if (my_GetFileVersionInfoW(s, 0, size, vi))
|
||||||
{
|
{
|
||||||
VS_FIXEDFILEINFO *fi = NULL;
|
VS_FIXEDFILEINFO *fi = NULL;
|
||||||
UINT fiLen = 0;
|
UINT fiLen = 0;
|
||||||
if (VerQueryValueW(vi, L"\\", (LPVOID *)&fi, &fiLen))
|
if (my_VerQueryValueW(vi, L"\\", (LPVOID *)&fi, &fiLen))
|
||||||
version = fi->dwFileVersionMS;
|
version = fi->dwFileVersionMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +192,7 @@ static WRes MyCreateDir(LPCWSTR name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define IS_SEPAR(c) (c == WCHAR_PATH_SEPARATOR)
|
#define IS_SEPAR(c) (c == WCHAR_PATH_SEPARATOR)
|
||||||
#define IS_LETTER_CHAR(c) ((c) >= 'a' && (c) <= 'z' || (c) >= 'A' && (c) <= 'Z')
|
#define IS_LETTER_CHAR(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z'))
|
||||||
#define IS_DRIVE_PATH(s) (IS_LETTER_CHAR(s[0]) && s[1] == ':' && IS_SEPAR(s[2]))
|
#define IS_DRIVE_PATH(s) (IS_LETTER_CHAR(s[0]) && s[1] == ':' && IS_SEPAR(s[2]))
|
||||||
|
|
||||||
static int ReverseFind_PathSepar(const wchar_t *s)
|
static int ReverseFind_PathSepar(const wchar_t *s)
|
||||||
@@ -270,7 +308,7 @@ static int MyRegistry_QueryString2(HKEY hKey, LPCWSTR keyName, LPCWSTR valName,
|
|||||||
if (res != ERROR_SUCCESS)
|
if (res != ERROR_SUCCESS)
|
||||||
return False;
|
return False;
|
||||||
{
|
{
|
||||||
Bool res2 = MyRegistry_QueryString(key, valName, dest);
|
BoolInt res2 = MyRegistry_QueryString(key, valName, dest);
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
return res2;
|
return res2;
|
||||||
}
|
}
|
||||||
@@ -343,7 +381,7 @@ static LONG MyRegistry_CreateKeyAndVal_32(HKEY parentKey, LPCWSTR keyName, LPCWS
|
|||||||
|
|
||||||
#define kSignatureSearchLimit (1 << 22)
|
#define kSignatureSearchLimit (1 << 22)
|
||||||
|
|
||||||
static Bool FindSignature(CSzFile *stream, UInt64 *resPos)
|
static BoolInt FindSignature(CSzFile *stream, UInt64 *resPos)
|
||||||
{
|
{
|
||||||
Byte buf[kBufSize];
|
Byte buf[kBufSize];
|
||||||
size_t numPrevBytes = 0;
|
size_t numPrevBytes = 0;
|
||||||
@@ -431,7 +469,7 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool MyBrowseForFolder(HWND owner, LPCWSTR title, UINT ulFlags,
|
static BoolInt MyBrowseForFolder(HWND owner, LPCWSTR title, UINT ulFlags,
|
||||||
LPCWSTR initialFolder, LPWSTR resultPath)
|
LPCWSTR initialFolder, LPWSTR resultPath)
|
||||||
{
|
{
|
||||||
WCHAR displayName[MAX_PATH];
|
WCHAR displayName[MAX_PATH];
|
||||||
@@ -694,7 +732,7 @@ static void SetShellProgramsGroup(HWND hwndOwner)
|
|||||||
|
|
||||||
for (; i < 3; i++)
|
for (; i < 3; i++)
|
||||||
{
|
{
|
||||||
Bool isOK = True;
|
BoolInt isOK = True;
|
||||||
WCHAR link[MAX_PATH + 40];
|
WCHAR link[MAX_PATH + 40];
|
||||||
WCHAR destPath[MAX_PATH + 40];
|
WCHAR destPath[MAX_PATH + 40];
|
||||||
|
|
||||||
@@ -874,7 +912,7 @@ static void WriteShellEx()
|
|||||||
|
|
||||||
static const wchar_t *GetCmdParam(const wchar_t *s)
|
static const wchar_t *GetCmdParam(const wchar_t *s)
|
||||||
{
|
{
|
||||||
Bool quoteMode = False;
|
BoolInt quoteMode = False;
|
||||||
for (;; s++)
|
for (;; s++)
|
||||||
{
|
{
|
||||||
wchar_t c = *s;
|
wchar_t c = *s;
|
||||||
@@ -988,7 +1026,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
if (path[0] == 0)
|
if (path[0] == 0)
|
||||||
{
|
{
|
||||||
HKEY key = 0;
|
HKEY key = 0;
|
||||||
Bool ok = False;
|
BoolInt ok = False;
|
||||||
LONG res = RegOpenKeyExW(HKEY_CURRENT_USER, k_Reg_Software_7zip, 0, KEY_READ | k_Reg_WOW_Flag, &key);
|
LONG res = RegOpenKeyExW(HKEY_CURRENT_USER, k_Reg_Software_7zip, 0, KEY_READ | k_Reg_WOW_Flag, &key);
|
||||||
if (res == ERROR_SUCCESS)
|
if (res == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
@@ -1101,9 +1139,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Bool GetErrorMessage(DWORD errorCode, WCHAR *message)
|
static BoolInt GetErrorMessage(DWORD errorCode, WCHAR *message)
|
||||||
{
|
{
|
||||||
LPVOID msgBuf;
|
LPWSTR msgBuf;
|
||||||
if (FormatMessageW(
|
if (FormatMessageW(
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||||
| FORMAT_MESSAGE_FROM_SYSTEM
|
| FORMAT_MESSAGE_FROM_SYSTEM
|
||||||
@@ -1201,7 +1239,7 @@ if (res == SZ_OK)
|
|||||||
|
|
||||||
if (res == SZ_OK)
|
if (res == SZ_OK)
|
||||||
{
|
{
|
||||||
lookStream.buf = ISzAlloc_Alloc(&allocImp, kInputBufSize);
|
lookStream.buf = (Byte *)ISzAlloc_Alloc(&allocImp, kInputBufSize);
|
||||||
if (!lookStream.buf)
|
if (!lookStream.buf)
|
||||||
res = SZ_ERROR_MEM;
|
res = SZ_ERROR_MEM;
|
||||||
else
|
else
|
||||||
@@ -1272,7 +1310,7 @@ if (res == SZ_OK)
|
|||||||
|
|
||||||
temp = path + pathLen;
|
temp = path + pathLen;
|
||||||
|
|
||||||
SzArEx_GetFileNameUtf16(&db, i, temp);
|
SzArEx_GetFileNameUtf16(&db, i, (UInt16 *)temp);
|
||||||
|
|
||||||
if (!g_SilentMode)
|
if (!g_SilentMode)
|
||||||
SetWindowTextW(g_InfoLine_HWND, temp);
|
SetWindowTextW(g_InfoLine_HWND, temp);
|
||||||
@@ -1313,7 +1351,7 @@ if (res == SZ_OK)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Bool skipFile = False;
|
// BoolInt skipFile = False;
|
||||||
|
|
||||||
wcscpy(origPath, path);
|
wcscpy(origPath, path);
|
||||||
|
|
||||||
|
|||||||
@@ -1,240 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="7zipInstall" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
|
||||||
|
|
||||||
CFG=7zipInstall - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "7zipInstall.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "7zipInstall.mak" CFG="7zipInstall - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "7zipInstall - Win32 Release" (based on "Win32 (x86) Application")
|
|
||||||
!MESSAGE "7zipInstall - Win32 Debug" (based on "Win32 (x86) Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
MTL=midl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "7zipInstall - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE2" /D "UNICODE2" /Yu"Precomp.h" /FD /c
|
|
||||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
|
||||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 /nologo /subsystem:windows /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 version.lib /nologo /subsystem:windows /machine:I386
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "7zipInstall - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE2" /D "UNICODE2" /Yu"Precomp.h" /FD /GZ /c
|
|
||||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
|
||||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 /nologo /subsystem:windows /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 version.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "7zipInstall - Win32 Release"
|
|
||||||
# Name "7zipInstall - Win32 Debug"
|
|
||||||
# Begin Group "Common"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7z.h
|
|
||||||
# End 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
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zBuf.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zCrc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zCrc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zCrcOpt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zDec.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zFile.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zFile.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zStream.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zTypes.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zVersion.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bcj2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bcj2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bra.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bra.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bra86.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\BraIA64.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\CpuArch.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\CpuArch.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Delta.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Delta.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\DllSecur.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\DllSecur.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Lzma2Dec.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Lzma2Dec.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaDec.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaDec.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Spec"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\Precomp.c
|
|
||||||
# ADD CPP /Yc"Precomp.h"
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\Precomp.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zipInstall.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\resource.rc
|
|
||||||
# End Source File
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
|
||||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "7zipInstall"=.\7zipInstall.dsp - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Global:
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<3>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
PROG = 7zipInstall.exe
|
PROG = 7zipInstall.exe
|
||||||
|
MY_FIXED = 1
|
||||||
LIBS = $(LIBS) version.lib
|
|
||||||
|
|
||||||
!IFDEF _64BIT_INSTALLER
|
!IFDEF _64BIT_INSTALLER
|
||||||
CFLAGS = $(CFLAGS) -D_64BIT_INSTALLER
|
CFLAGS = $(CFLAGS) -D_64BIT_INSTALLER
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* 7zipUninstall.c - 7-Zip Uninstaller
|
/* 7zipUninstall.c - 7-Zip Uninstaller
|
||||||
2017-04-04 : Igor Pavlov : Public domain */
|
2019-02-02 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -70,9 +70,9 @@ static const WCHAR * const k_Reg_CLSID_7zip_Inproc = L"CLSID\\" k_7zip_CLSID L"\
|
|||||||
|
|
||||||
#define g_AllUsers True
|
#define g_AllUsers True
|
||||||
|
|
||||||
static Bool g_Install_was_Pressed;
|
static BoolInt g_Install_was_Pressed;
|
||||||
static Bool g_Finished;
|
static BoolInt g_Finished;
|
||||||
static Bool g_SilentMode;
|
static BoolInt g_SilentMode;
|
||||||
|
|
||||||
static HWND g_HWND;
|
static HWND g_HWND;
|
||||||
static HWND g_Path_HWND;
|
static HWND g_Path_HWND;
|
||||||
@@ -94,7 +94,7 @@ static const WCHAR * const kUninstallExe = L"Uninstall.exe";
|
|||||||
|
|
||||||
#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c)))
|
#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c)))
|
||||||
|
|
||||||
static Bool AreStringsEqual_NoCase(const wchar_t *s1, const wchar_t *s2)
|
static BoolInt AreStringsEqual_NoCase(const wchar_t *s1, const wchar_t *s2)
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@@ -107,7 +107,7 @@ static Bool AreStringsEqual_NoCase(const wchar_t *s1, const wchar_t *s2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_t *s2)
|
static BoolInt IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_t *s2)
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@@ -149,7 +149,7 @@ static int MyRegistry_QueryString2(HKEY hKey, LPCWSTR keyName, LPCWSTR valName,
|
|||||||
if (res != ERROR_SUCCESS)
|
if (res != ERROR_SUCCESS)
|
||||||
return False;
|
return False;
|
||||||
{
|
{
|
||||||
Bool res2 = MyRegistry_QueryString(key, valName, dest);
|
BoolInt res2 = MyRegistry_QueryString(key, valName, dest);
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
return res2;
|
return res2;
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ static int MyRegistry_QueryString2_32(HKEY hKey, LPCWSTR keyName, LPCWSTR valNam
|
|||||||
if (res != ERROR_SUCCESS)
|
if (res != ERROR_SUCCESS)
|
||||||
return False;
|
return False;
|
||||||
{
|
{
|
||||||
Bool res2 = MyRegistry_QueryString(key, valName, dest);
|
BoolInt res2 = MyRegistry_QueryString(key, valName, dest);
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
return res2;
|
return res2;
|
||||||
}
|
}
|
||||||
@@ -283,7 +283,7 @@ static void SetShellProgramsGroup(HWND hwndOwner)
|
|||||||
|
|
||||||
for (; i < 3; i++)
|
for (; i < 3; i++)
|
||||||
{
|
{
|
||||||
// Bool isOK = True;
|
// BoolInt isOK = True;
|
||||||
WCHAR link[MAX_PATH + 40];
|
WCHAR link[MAX_PATH + 40];
|
||||||
WCHAR destPath[MAX_PATH + 40];
|
WCHAR destPath[MAX_PATH + 40];
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ static void SetShellProgramsGroup(HWND hwndOwner)
|
|||||||
{
|
{
|
||||||
const size_t baseLen = wcslen(link);
|
const size_t baseLen = wcslen(link);
|
||||||
unsigned k;
|
unsigned k;
|
||||||
Bool needDelete = False;
|
BoolInt needDelete = False;
|
||||||
|
|
||||||
for (k = 0; k < 2; k++)
|
for (k = 0; k < 2; k++)
|
||||||
{
|
{
|
||||||
@@ -347,7 +347,7 @@ static const WCHAR * const k_AppPaths_7zFm = L"Software\\Microsoft\\Windows\\Cur
|
|||||||
static const WCHAR * const k_Uninstall_7zip = k_REG_Uninstall L"7-Zip";
|
static const WCHAR * const k_Uninstall_7zip = k_REG_Uninstall L"7-Zip";
|
||||||
|
|
||||||
|
|
||||||
static Bool AreEqual_Path_PrefixName(const wchar_t *s, const wchar_t *prefix, const wchar_t *name)
|
static BoolInt AreEqual_Path_PrefixName(const wchar_t *s, const wchar_t *prefix, const wchar_t *name)
|
||||||
{
|
{
|
||||||
if (!IsString1PrefixedByString2_NoCase(s, prefix))
|
if (!IsString1PrefixedByString2_NoCase(s, prefix))
|
||||||
return False;
|
return False;
|
||||||
@@ -444,7 +444,7 @@ static void WriteCLSID()
|
|||||||
|
|
||||||
static const wchar_t *GetCmdParam(const wchar_t *s)
|
static const wchar_t *GetCmdParam(const wchar_t *s)
|
||||||
{
|
{
|
||||||
Bool quoteMode = False;
|
BoolInt quoteMode = False;
|
||||||
for (;; s++)
|
for (;; s++)
|
||||||
{
|
{
|
||||||
wchar_t c = *s;
|
wchar_t c = *s;
|
||||||
@@ -469,7 +469,7 @@ static void RemoveQuotes(wchar_t *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool DoesFileOrDirExist()
|
static BoolInt DoesFileOrDirExist()
|
||||||
{
|
{
|
||||||
return (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES);
|
return (GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES);
|
||||||
}
|
}
|
||||||
@@ -491,7 +491,7 @@ static BOOL RemoveFileAfterReboot()
|
|||||||
|
|
||||||
#define IS_LIMIT_CHAR(c) (c == 0 || c == ' ')
|
#define IS_LIMIT_CHAR(c) (c == 0 || c == ' ')
|
||||||
|
|
||||||
static Bool IsThereSpace(const wchar_t *s)
|
static BoolInt IsThereSpace(const wchar_t *s)
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@@ -505,7 +505,7 @@ static Bool IsThereSpace(const wchar_t *s)
|
|||||||
|
|
||||||
static void AddPathParam(wchar_t *dest, const wchar_t *src)
|
static void AddPathParam(wchar_t *dest, const wchar_t *src)
|
||||||
{
|
{
|
||||||
Bool needQuote = IsThereSpace(src);
|
BoolInt needQuote = IsThereSpace(src);
|
||||||
if (needQuote)
|
if (needQuote)
|
||||||
wcscat(dest, L"\"");
|
wcscat(dest, L"\"");
|
||||||
wcscat(dest, src);
|
wcscat(dest, src);
|
||||||
@@ -515,9 +515,9 @@ static void AddPathParam(wchar_t *dest, const wchar_t *src)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Bool GetErrorMessage(DWORD errorCode, WCHAR *message)
|
static BoolInt GetErrorMessage(DWORD errorCode, WCHAR *message)
|
||||||
{
|
{
|
||||||
LPVOID msgBuf;
|
LPWSTR msgBuf;
|
||||||
if (FormatMessageW(
|
if (FormatMessageW(
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||||
| FORMAT_MESSAGE_FROM_SYSTEM
|
| FORMAT_MESSAGE_FROM_SYSTEM
|
||||||
@@ -546,7 +546,7 @@ static BOOL RemoveDir()
|
|||||||
#define k_Lang L"Lang"
|
#define k_Lang L"Lang"
|
||||||
|
|
||||||
// NUM_LANG_TXT_FILES files are placed before en.ttt
|
// NUM_LANG_TXT_FILES files are placed before en.ttt
|
||||||
#define NUM_LANG_TXT_FILES 87
|
#define NUM_LANG_TXT_FILES 88
|
||||||
|
|
||||||
#ifdef _64BIT_INSTALLER
|
#ifdef _64BIT_INSTALLER
|
||||||
#define NUM_EXTRA_FILES_64BIT 1
|
#define NUM_EXTRA_FILES_64BIT 1
|
||||||
@@ -558,7 +558,7 @@ static BOOL RemoveDir()
|
|||||||
|
|
||||||
static const char * const k_Names =
|
static const char * const k_Names =
|
||||||
"af an ar ast az ba be bg bn br ca co cs cy da de el eo es et eu ext"
|
"af an ar ast az ba be bg bn br ca co cs cy da de el eo es et eu ext"
|
||||||
" fa fi fr fur fy ga gl gu he hi hr hu hy id io is it ja ka kaa kk ko ku ku-ckb ky"
|
" fa fi fr fur fy ga gl gu he hi hr hu hy id io is it ja ka kaa kab kk ko ku ku-ckb ky"
|
||||||
" lij lt lv mk mn mng mng2 mr ms nb ne nl nn pa-in pl ps pt pt-br ro ru"
|
" lij lt lv mk mn mng mng2 mr ms nb ne nl nn pa-in pl ps pt pt-br ro ru"
|
||||||
" sa si sk sl sq sr-spc sr-spl sv ta th tr tt ug uk uz va vi yo zh-cn zh-tw"
|
" sa si sk sl sq sr-spc sr-spl sv ta th tr tt ug uk uz va vi yo zh-cn zh-tw"
|
||||||
" en.ttt"
|
" en.ttt"
|
||||||
@@ -586,7 +586,7 @@ static int Install()
|
|||||||
SRes res = SZ_OK;
|
SRes res = SZ_OK;
|
||||||
WRes winRes = 0;
|
WRes winRes = 0;
|
||||||
|
|
||||||
// Bool needReboot = False;
|
// BoolInt needReboot = False;
|
||||||
const size_t pathLen = wcslen(path);
|
const size_t pathLen = wcslen(path);
|
||||||
|
|
||||||
if (!g_SilentMode)
|
if (!g_SilentMode)
|
||||||
@@ -805,7 +805,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
lpCmdLine, int nCmdShow)
|
lpCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
const wchar_t *cmdParams;
|
const wchar_t *cmdParams;
|
||||||
Bool useTemp = True;
|
BoolInt useTemp = True;
|
||||||
|
|
||||||
UNUSED_VAR(hPrevInstance)
|
UNUSED_VAR(hPrevInstance)
|
||||||
UNUSED_VAR(lpCmdLine)
|
UNUSED_VAR(lpCmdLine)
|
||||||
@@ -1005,7 +1005,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
if (path[0] == 0)
|
if (path[0] == 0)
|
||||||
{
|
{
|
||||||
HKEY key = 0;
|
HKEY key = 0;
|
||||||
Bool ok = False;
|
BoolInt ok = False;
|
||||||
LONG res = RegOpenKeyExW(HKEY_CURRENT_USER, k_Reg_Software_7zip, 0, KEY_READ | k_Reg_WOW_Flag, &key);
|
LONG res = RegOpenKeyExW(HKEY_CURRENT_USER, k_Reg_Software_7zip, 0, KEY_READ | k_Reg_WOW_Flag, &key);
|
||||||
if (res == ERROR_SUCCESS)
|
if (res == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="7zipUninstall" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
|
||||||
|
|
||||||
CFG=7zipUninstall - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "7zipUninstall.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "7zipUninstall.mak" CFG="7zipUninstall - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "7zipUninstall - Win32 Release" (based on "Win32 (x86) Application")
|
|
||||||
!MESSAGE "7zipUninstall - Win32 Debug" (based on "Win32 (x86) Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
MTL=midl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "7zipUninstall - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE2" /D "UNICODE2" /FAcs /Yu"Precomp.h" /FD /GF /c
|
|
||||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
|
||||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 /nologo /subsystem:windows /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 /nologo /subsystem:windows /machine:I386 /out:"Release/Uninstall.exe"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "7zipUninstall - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE2" /D "UNICODE2" /Yu"Precomp.h" /FD /GZ /c
|
|
||||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
|
||||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 /nologo /subsystem:windows /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 /nologo /subsystem:windows /debug /machine:I386 /out:"Debug/Uninstall.exe" /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "7zipUninstall - Win32 Release"
|
|
||||||
# Name "7zipUninstall - Win32 Debug"
|
|
||||||
# Begin Group "Common"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zTypes.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zVersion.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Spec"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\Precomp.c
|
|
||||||
# ADD CPP /Yc"Precomp.h"
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\Precomp.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zipUninstall.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\resource.rc
|
|
||||||
# End Source File
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
|
||||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "7zipUninstall"=.\7zipUninstall.dsp - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Global:
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<3>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
PROG = 7zipUninstall.exe
|
PROG = 7zipUninstall.exe
|
||||||
|
MY_FIXED = 1
|
||||||
|
|
||||||
!IFDEF _64BIT_INSTALLER
|
!IFDEF _64BIT_INSTALLER
|
||||||
CFLAGS = $(CFLAGS) -D_64BIT_INSTALLER
|
CFLAGS = $(CFLAGS) -D_64BIT_INSTALLER
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* LzmaUtil.c -- Test application for LZMA compression
|
/* LzmaUtil.c -- Test application for LZMA compression
|
||||||
2017-04-27 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "../../Precomp.h"
|
#include "../../Precomp.h"
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ static int main2(int numArgs, const char *args[], char *rs)
|
|||||||
char c;
|
char c;
|
||||||
int res;
|
int res;
|
||||||
int encodeMode;
|
int encodeMode;
|
||||||
Bool useOutFile = False;
|
BoolInt useOutFile = False;
|
||||||
|
|
||||||
FileSeqInStream_CreateVTable(&inStream);
|
FileSeqInStream_CreateVTable(&inStream);
|
||||||
File_Construct(&inStream.file);
|
File_Construct(&inStream.file);
|
||||||
|
|||||||
@@ -1,168 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="LzmaUtil" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
|
||||||
|
|
||||||
CFG=LzmaUtil - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "LzmaUtil.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "LzmaUtil.mak" CFG="LzmaUtil - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "LzmaUtil - Win32 Release" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE "LzmaUtil - Win32 Debug" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "LzmaUtil - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /MT /W4 /WX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
|
|
||||||
# SUBTRACT CPP /YX
|
|
||||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 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\7lzma.exe"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "LzmaUtil - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# 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 CPP /nologo /MTd /W4 /WX /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
|
|
||||||
# SUBTRACT CPP /YX
|
|
||||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 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\7lzma.exe" /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "LzmaUtil - Win32 Release"
|
|
||||||
# Name "LzmaUtil - Win32 Debug"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zFile.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zFile.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zStream.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zVersion.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Alloc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Alloc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\CpuArch.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzFind.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzFind.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzFindMt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzFindMt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzHash.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaDec.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaDec.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaEnc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaEnc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LzmaUtil.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Threads.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Threads.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Types.h
|
|
||||||
# End Source File
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
|
||||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "LzmaUtil"=.\LzmaUtil.dsp - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Global:
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<3>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
@@ -1,178 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="LzmaLib" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
|
||||||
|
|
||||||
CFG=LzmaLib - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "LzmaLib.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "LzmaLib.mak" CFG="LzmaLib - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "LzmaLib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
|
||||||
!MESSAGE "LzmaLib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
MTL=midl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "LzmaLib - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /Gr /MT /W3 /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /FD /c
|
|
||||||
# SUBTRACT CPP /YX
|
|
||||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
|
||||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 /nologo /dll /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 /nologo /dll /machine:I386 /out:"C:\Util\LZMA.dll" /opt:NOWIN98
|
|
||||||
# SUBTRACT LINK32 /pdb:none
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "LzmaLib - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /D "COMPRESS_MF_MT" /FD /GZ /c
|
|
||||||
# SUBTRACT CPP /YX
|
|
||||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
|
||||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 /nologo /dll /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 /nologo /dll /debug /machine:I386 /out:"C:\Util\LZMA.dll" /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "LzmaLib - Win32 Release"
|
|
||||||
# Name "LzmaLib - Win32 Debug"
|
|
||||||
# Begin Group "Spec"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LzmaLib.def
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LzmaLibExports.c
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zTypes.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Alloc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Alloc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\IStream.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzFind.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzFind.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzFindMt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzFindMt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzHash.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaDec.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaDec.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaEnc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaEnc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaLib.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaLib.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\resource.rc
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Threads.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Threads.h
|
|
||||||
# End Source File
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
|
||||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "LzmaLib"=.\LzmaLib.dsp - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Global:
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<3>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* SfxSetup.c - 7z SFX Setup
|
/* SfxSetup.c - 7z SFX Setup
|
||||||
2017-04-04 : Igor Pavlov : Public domain */
|
2019-02-02 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ static WRes MyCreateDir(const WCHAR *name)
|
|||||||
|
|
||||||
#define kSignatureSearchLimit (1 << 22)
|
#define kSignatureSearchLimit (1 << 22)
|
||||||
|
|
||||||
static Bool FindSignature(CSzFile *stream, UInt64 *resPos)
|
static BoolInt FindSignature(CSzFile *stream, UInt64 *resPos)
|
||||||
{
|
{
|
||||||
Byte buf[kBufferSize];
|
Byte buf[kBufferSize];
|
||||||
size_t numPrevBytes = 0;
|
size_t numPrevBytes = 0;
|
||||||
@@ -163,7 +163,7 @@ static Bool FindSignature(CSzFile *stream, UInt64 *resPos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool DoesFileOrDirExist(const WCHAR *path)
|
static BoolInt DoesFileOrDirExist(const WCHAR *path)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATAW fd;
|
WIN32_FIND_DATAW fd;
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
@@ -254,7 +254,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
DWORD winRes;
|
DWORD winRes;
|
||||||
const wchar_t *cmdLineParams;
|
const wchar_t *cmdLineParams;
|
||||||
const char *errorMessage = NULL;
|
const char *errorMessage = NULL;
|
||||||
Bool useShellExecute = True;
|
BoolInt useShellExecute = True;
|
||||||
DWORD exitCode = 0;
|
DWORD exitCode = 0;
|
||||||
|
|
||||||
LoadSecurityDlls();
|
LoadSecurityDlls();
|
||||||
@@ -287,7 +287,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
cmdLineParams = GetCommandLineW();
|
cmdLineParams = GetCommandLineW();
|
||||||
#ifndef UNDER_CE
|
#ifndef UNDER_CE
|
||||||
{
|
{
|
||||||
Bool quoteMode = False;
|
BoolInt quoteMode = False;
|
||||||
for (;; cmdLineParams++)
|
for (;; cmdLineParams++)
|
||||||
{
|
{
|
||||||
wchar_t c = *cmdLineParams;
|
wchar_t c = *cmdLineParams;
|
||||||
@@ -379,7 +379,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
|
|
||||||
if (res == SZ_OK)
|
if (res == SZ_OK)
|
||||||
{
|
{
|
||||||
lookStream.buf = ISzAlloc_Alloc(&allocImp, kInputBufSize);
|
lookStream.buf = (Byte *)ISzAlloc_Alloc(&allocImp, kInputBufSize);
|
||||||
if (!lookStream.buf)
|
if (!lookStream.buf)
|
||||||
res = SZ_ERROR_MEM;
|
res = SZ_ERROR_MEM;
|
||||||
else
|
else
|
||||||
@@ -420,7 +420,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
|
|
||||||
temp = path + pathLen;
|
temp = path + pathLen;
|
||||||
|
|
||||||
SzArEx_GetFileNameUtf16(&db, i, temp);
|
SzArEx_GetFileNameUtf16(&db, i, (UInt16 *)temp);
|
||||||
{
|
{
|
||||||
res = SzArEx_Extract(&db, &lookStream.vt, i,
|
res = SzArEx_Extract(&db, &lookStream.vt, i,
|
||||||
&blockIndex, &outBuffer, &outBufferSize,
|
&blockIndex, &outBuffer, &outBufferSize,
|
||||||
@@ -527,7 +527,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
{
|
{
|
||||||
WCHAR *temp = path + pathLen;
|
WCHAR *temp = path + pathLen;
|
||||||
UInt32 j;
|
UInt32 j;
|
||||||
SzArEx_GetFileNameUtf16(&db, executeFileIndex, temp);
|
SzArEx_GetFileNameUtf16(&db, executeFileIndex, (UInt16 *)temp);
|
||||||
for (j = 0; temp[j] != 0; j++)
|
for (j = 0; temp[j] != 0; j++)
|
||||||
if (temp[j] == '/')
|
if (temp[j] == '/')
|
||||||
temp[j] = CHAR_PATH_SEPARATOR;
|
temp[j] = CHAR_PATH_SEPARATOR;
|
||||||
|
|||||||
@@ -1,231 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="SfxSetup" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
|
||||||
|
|
||||||
CFG=SfxSetup - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "SfxSetup.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "SfxSetup.mak" CFG="SfxSetup - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "SfxSetup - Win32 Release" (based on "Win32 (x86) Application")
|
|
||||||
!MESSAGE "SfxSetup - Win32 Debug" (based on "Win32 (x86) Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
MTL=midl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "SfxSetup - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /c
|
|
||||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
|
||||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 /nologo /subsystem:windows /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 /nologo /subsystem:windows /machine:I386
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "SfxSetup - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Ignore_Export_Lib 0
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c
|
|
||||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
|
||||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 /nologo /subsystem:windows /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 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "SfxSetup - Win32 Release"
|
|
||||||
# Name "SfxSetup - Win32 Debug"
|
|
||||||
# Begin Group "Common"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7z.h
|
|
||||||
# End 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
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zBuf.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zCrc.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zCrc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zCrcOpt.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zDec.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zFile.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zFile.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zStream.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\7zTypes.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bcj2.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bcj2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bra.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bra.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Bra86.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\BraIA64.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\CpuArch.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\CpuArch.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Delta.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Delta.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\DllSecur.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\DllSecur.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Lzma2Dec.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Lzma2Dec.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaDec.c
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\LzmaDec.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Spec"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\Precomp.c
|
|
||||||
# ADD CPP /Yc"Precomp.h"
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\Precomp.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\SfxSetup.c
|
|
||||||
# End Source File
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
|
||||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "SfxSetup"=.\SfxSetup.dsp - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Global:
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<3>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
PROG = 7zS2.sfx
|
PROG = 7zS2.sfx
|
||||||
|
MY_FIXED = 1
|
||||||
|
|
||||||
C_OBJS = \
|
C_OBJS = \
|
||||||
$O\7zAlloc.obj \
|
$O\7zAlloc.obj \
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
PROG = 7zS2con.sfx
|
PROG = 7zS2con.sfx
|
||||||
|
MY_FIXED = 1
|
||||||
CFLAGS = $(CFLAGS) -D_CONSOLE
|
CFLAGS = $(CFLAGS) -D_CONSOLE
|
||||||
|
|
||||||
C_OBJS = \
|
C_OBJS = \
|
||||||
|
|||||||
12
C/Xz.c
12
C/Xz.c
@@ -1,5 +1,5 @@
|
|||||||
/* Xz.c - Xz
|
/* Xz.c - Xz
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2017-05-12 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "XzCrc64.h"
|
#include "XzCrc64.h"
|
||||||
|
|
||||||
const Byte XZ_SIG[XZ_SIG_SIZE] = { 0xFD, '7', 'z', 'X', 'Z', 0 };
|
const Byte XZ_SIG[XZ_SIG_SIZE] = { 0xFD, '7', 'z', 'X', 'Z', 0 };
|
||||||
const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE] = { 'Y', 'Z' };
|
/* const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE] = { 'Y', 'Z' }; */
|
||||||
|
|
||||||
unsigned Xz_WriteVarInt(Byte *buf, UInt64 v)
|
unsigned Xz_WriteVarInt(Byte *buf, UInt64 v)
|
||||||
{
|
{
|
||||||
@@ -26,16 +26,16 @@ unsigned Xz_WriteVarInt(Byte *buf, UInt64 v)
|
|||||||
|
|
||||||
void Xz_Construct(CXzStream *p)
|
void Xz_Construct(CXzStream *p)
|
||||||
{
|
{
|
||||||
p->numBlocks = p->numBlocksAllocated = 0;
|
p->numBlocks = 0;
|
||||||
p->blocks = 0;
|
p->blocks = NULL;
|
||||||
p->flags = 0;
|
p->flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Xz_Free(CXzStream *p, ISzAllocPtr alloc)
|
void Xz_Free(CXzStream *p, ISzAllocPtr alloc)
|
||||||
{
|
{
|
||||||
ISzAlloc_Free(alloc, p->blocks);
|
ISzAlloc_Free(alloc, p->blocks);
|
||||||
p->numBlocks = p->numBlocksAllocated = 0;
|
p->numBlocks = 0;
|
||||||
p->blocks = 0;
|
p->blocks = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned XzFlags_GetCheckSize(CXzStreamFlags f)
|
unsigned XzFlags_GetCheckSize(CXzStreamFlags f)
|
||||||
|
|||||||
225
C/Xz.h
225
C/Xz.h
@@ -1,5 +1,5 @@
|
|||||||
/* Xz.h - Xz interface
|
/* Xz.h - Xz interface
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __XZ_H
|
#ifndef __XZ_H
|
||||||
#define __XZ_H
|
#define __XZ_H
|
||||||
@@ -50,9 +50,10 @@ typedef struct
|
|||||||
#define XzBlock_GetNumFilters(p) (((p)->flags & XZ_BF_NUM_FILTERS_MASK) + 1)
|
#define XzBlock_GetNumFilters(p) (((p)->flags & XZ_BF_NUM_FILTERS_MASK) + 1)
|
||||||
#define XzBlock_HasPackSize(p) (((p)->flags & XZ_BF_PACK_SIZE) != 0)
|
#define XzBlock_HasPackSize(p) (((p)->flags & XZ_BF_PACK_SIZE) != 0)
|
||||||
#define XzBlock_HasUnpackSize(p) (((p)->flags & XZ_BF_UNPACK_SIZE) != 0)
|
#define XzBlock_HasUnpackSize(p) (((p)->flags & XZ_BF_UNPACK_SIZE) != 0)
|
||||||
|
#define XzBlock_HasUnsupportedFlags(p) (((p)->flags & ~(XZ_BF_NUM_FILTERS_MASK | XZ_BF_PACK_SIZE | XZ_BF_UNPACK_SIZE)) != 0)
|
||||||
|
|
||||||
SRes XzBlock_Parse(CXzBlock *p, const Byte *header);
|
SRes XzBlock_Parse(CXzBlock *p, const Byte *header);
|
||||||
SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, Bool *isIndex, UInt32 *headerSizeRes);
|
SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, BoolInt *isIndex, UInt32 *headerSizeRes);
|
||||||
|
|
||||||
/* ---------- xz stream ---------- */
|
/* ---------- xz stream ---------- */
|
||||||
|
|
||||||
@@ -60,7 +61,13 @@ SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, Bool *isIndex, UInt
|
|||||||
#define XZ_FOOTER_SIG_SIZE 2
|
#define XZ_FOOTER_SIG_SIZE 2
|
||||||
|
|
||||||
extern const Byte XZ_SIG[XZ_SIG_SIZE];
|
extern const Byte XZ_SIG[XZ_SIG_SIZE];
|
||||||
|
|
||||||
|
/*
|
||||||
extern const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE];
|
extern const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE];
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define XZ_FOOTER_SIG_0 'Y'
|
||||||
|
#define XZ_FOOTER_SIG_1 'Z'
|
||||||
|
|
||||||
#define XZ_STREAM_FLAGS_SIZE 2
|
#define XZ_STREAM_FLAGS_SIZE 2
|
||||||
#define XZ_STREAM_CRC_SIZE 4
|
#define XZ_STREAM_CRC_SIZE 4
|
||||||
@@ -106,7 +113,6 @@ typedef struct
|
|||||||
{
|
{
|
||||||
CXzStreamFlags flags;
|
CXzStreamFlags flags;
|
||||||
size_t numBlocks;
|
size_t numBlocks;
|
||||||
size_t numBlocksAllocated;
|
|
||||||
CXzBlockSizes *blocks;
|
CXzBlockSizes *blocks;
|
||||||
UInt64 startOffset;
|
UInt64 startOffset;
|
||||||
} CXzStream;
|
} CXzStream;
|
||||||
@@ -133,6 +139,9 @@ SRes Xzs_ReadBackward(CXzs *p, ILookInStream *inStream, Int64 *startOffset, ICom
|
|||||||
UInt64 Xzs_GetNumBlocks(const CXzs *p);
|
UInt64 Xzs_GetNumBlocks(const CXzs *p);
|
||||||
UInt64 Xzs_GetUnpackSize(const CXzs *p);
|
UInt64 Xzs_GetUnpackSize(const CXzs *p);
|
||||||
|
|
||||||
|
|
||||||
|
// ECoderStatus values are identical to ELzmaStatus values of LZMA2 decoder
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
CODER_STATUS_NOT_SPECIFIED, /* use main error code instead */
|
CODER_STATUS_NOT_SPECIFIED, /* use main error code instead */
|
||||||
@@ -141,22 +150,31 @@ typedef enum
|
|||||||
CODER_STATUS_NEEDS_MORE_INPUT /* you must provide more input bytes */
|
CODER_STATUS_NEEDS_MORE_INPUT /* you must provide more input bytes */
|
||||||
} ECoderStatus;
|
} ECoderStatus;
|
||||||
|
|
||||||
|
|
||||||
|
// ECoderFinishMode values are identical to ELzmaFinishMode
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
CODER_FINISH_ANY, /* finish at any point */
|
CODER_FINISH_ANY, /* finish at any point */
|
||||||
CODER_FINISH_END /* block must be finished at the end */
|
CODER_FINISH_END /* block must be finished at the end */
|
||||||
} ECoderFinishMode;
|
} ECoderFinishMode;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _IStateCoder
|
typedef struct _IStateCoder
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
void (*Free)(void *p, ISzAllocPtr alloc);
|
void (*Free)(void *p, ISzAllocPtr alloc);
|
||||||
SRes (*SetProps)(void *p, const Byte *props, size_t propSize, ISzAllocPtr alloc);
|
SRes (*SetProps)(void *p, const Byte *props, size_t propSize, ISzAllocPtr alloc);
|
||||||
void (*Init)(void *p);
|
void (*Init)(void *p);
|
||||||
SRes (*Code)(void *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
SRes (*Code2)(void *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
|
||||||
int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished);
|
int srcWasFinished, ECoderFinishMode finishMode,
|
||||||
|
// int *wasFinished,
|
||||||
|
ECoderStatus *status);
|
||||||
|
SizeT (*Filter)(void *p, Byte *data, SizeT size);
|
||||||
} IStateCoder;
|
} IStateCoder;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MIXCODER_NUM_FILTERS_MAX 4
|
#define MIXCODER_NUM_FILTERS_MAX 4
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -164,20 +182,23 @@ typedef struct
|
|||||||
ISzAllocPtr alloc;
|
ISzAllocPtr alloc;
|
||||||
Byte *buf;
|
Byte *buf;
|
||||||
unsigned numCoders;
|
unsigned numCoders;
|
||||||
|
|
||||||
|
Byte *outBuf;
|
||||||
|
size_t outBufSize;
|
||||||
|
size_t outWritten; // is equal to lzmaDecoder.dicPos (in outBuf mode)
|
||||||
|
BoolInt wasFinished;
|
||||||
|
SRes res;
|
||||||
|
ECoderStatus status;
|
||||||
|
// BoolInt SingleBufMode;
|
||||||
|
|
||||||
int finished[MIXCODER_NUM_FILTERS_MAX - 1];
|
int finished[MIXCODER_NUM_FILTERS_MAX - 1];
|
||||||
size_t pos[MIXCODER_NUM_FILTERS_MAX - 1];
|
size_t pos[MIXCODER_NUM_FILTERS_MAX - 1];
|
||||||
size_t size[MIXCODER_NUM_FILTERS_MAX - 1];
|
size_t size[MIXCODER_NUM_FILTERS_MAX - 1];
|
||||||
UInt64 ids[MIXCODER_NUM_FILTERS_MAX];
|
UInt64 ids[MIXCODER_NUM_FILTERS_MAX];
|
||||||
|
SRes results[MIXCODER_NUM_FILTERS_MAX];
|
||||||
IStateCoder coders[MIXCODER_NUM_FILTERS_MAX];
|
IStateCoder coders[MIXCODER_NUM_FILTERS_MAX];
|
||||||
} CMixCoder;
|
} CMixCoder;
|
||||||
|
|
||||||
void MixCoder_Construct(CMixCoder *p, ISzAllocPtr alloc);
|
|
||||||
void MixCoder_Free(CMixCoder *p);
|
|
||||||
void MixCoder_Init(CMixCoder *p);
|
|
||||||
SRes MixCoder_SetFromMethod(CMixCoder *p, unsigned coderIndex, UInt64 methodId);
|
|
||||||
SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
|
|
||||||
const Byte *src, SizeT *srcLen, int srcWasFinished,
|
|
||||||
ECoderFinishMode finishMode, ECoderStatus *status);
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@@ -191,6 +212,7 @@ typedef enum
|
|||||||
XZ_STATE_BLOCK_FOOTER
|
XZ_STATE_BLOCK_FOOTER
|
||||||
} EXzState;
|
} EXzState;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
EXzState state;
|
EXzState state;
|
||||||
@@ -204,7 +226,7 @@ typedef struct
|
|||||||
UInt64 packSize;
|
UInt64 packSize;
|
||||||
UInt64 unpackSize;
|
UInt64 unpackSize;
|
||||||
|
|
||||||
UInt64 numBlocks;
|
UInt64 numBlocks; // number of finished blocks in current stream
|
||||||
UInt64 indexSize;
|
UInt64 indexSize;
|
||||||
UInt64 indexPos;
|
UInt64 indexPos;
|
||||||
UInt64 padSize;
|
UInt64 padSize;
|
||||||
@@ -218,14 +240,65 @@ typedef struct
|
|||||||
CXzBlock block;
|
CXzBlock block;
|
||||||
CXzCheck check;
|
CXzCheck check;
|
||||||
CSha256 sha;
|
CSha256 sha;
|
||||||
|
|
||||||
|
BoolInt parseMode;
|
||||||
|
BoolInt headerParsedOk;
|
||||||
|
BoolInt decodeToStreamSignature;
|
||||||
|
unsigned decodeOnlyOneBlock;
|
||||||
|
|
||||||
|
Byte *outBuf;
|
||||||
|
size_t outBufSize;
|
||||||
|
size_t outDataWritten; // the size of data in (outBuf) that were fully unpacked
|
||||||
|
|
||||||
Byte shaDigest[SHA256_DIGEST_SIZE];
|
Byte shaDigest[SHA256_DIGEST_SIZE];
|
||||||
Byte buf[XZ_BLOCK_HEADER_SIZE_MAX];
|
Byte buf[XZ_BLOCK_HEADER_SIZE_MAX];
|
||||||
} CXzUnpacker;
|
} CXzUnpacker;
|
||||||
|
|
||||||
|
/* alloc : aligned for cache line allocation is better */
|
||||||
void XzUnpacker_Construct(CXzUnpacker *p, ISzAllocPtr alloc);
|
void XzUnpacker_Construct(CXzUnpacker *p, ISzAllocPtr alloc);
|
||||||
void XzUnpacker_Init(CXzUnpacker *p);
|
void XzUnpacker_Init(CXzUnpacker *p);
|
||||||
|
void XzUnpacker_SetOutBuf(CXzUnpacker *p, Byte *outBuf, size_t outBufSize);
|
||||||
void XzUnpacker_Free(CXzUnpacker *p);
|
void XzUnpacker_Free(CXzUnpacker *p);
|
||||||
|
|
||||||
|
/*
|
||||||
|
XzUnpacker
|
||||||
|
The sequence for decoding functions:
|
||||||
|
{
|
||||||
|
XzUnpacker_Construct()
|
||||||
|
[Decoding_Calls]
|
||||||
|
XzUnpacker_Free()
|
||||||
|
}
|
||||||
|
|
||||||
|
[Decoding_Calls]
|
||||||
|
|
||||||
|
There are 3 types of interfaces for [Decoding_Calls] calls:
|
||||||
|
|
||||||
|
Interface-1 : Partial output buffers:
|
||||||
|
{
|
||||||
|
XzUnpacker_Init()
|
||||||
|
for()
|
||||||
|
XzUnpacker_Code();
|
||||||
|
}
|
||||||
|
|
||||||
|
Interface-2 : Direct output buffer:
|
||||||
|
Use it, if you know exact size of decoded data, and you need
|
||||||
|
whole xz unpacked data in one output buffer.
|
||||||
|
xz unpacker doesn't allocate additional buffer for lzma2 dictionary in that mode.
|
||||||
|
{
|
||||||
|
XzUnpacker_Init()
|
||||||
|
XzUnpacker_SetOutBufMode(); // to set output buffer and size
|
||||||
|
for()
|
||||||
|
XzUnpacker_Code(); // (dest = NULL) in XzUnpacker_Code()
|
||||||
|
}
|
||||||
|
|
||||||
|
Interface-3 : Direct output buffer : One call full decoding
|
||||||
|
It unpacks whole input buffer to output buffer in one call.
|
||||||
|
It uses Interface-2 internally.
|
||||||
|
{
|
||||||
|
XzUnpacker_CodeFull()
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
finishMode:
|
finishMode:
|
||||||
It has meaning only if the decoding reaches output limit (*destLen).
|
It has meaning only if the decoding reaches output limit (*destLen).
|
||||||
@@ -255,20 +328,132 @@ Returns:
|
|||||||
|
|
||||||
|
|
||||||
SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
|
SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
|
||||||
const Byte *src, SizeT *srcLen, ECoderFinishMode finishMode,
|
const Byte *src, SizeT *srcLen, int srcFinished,
|
||||||
ECoderStatus *status);
|
ECoderFinishMode finishMode, ECoderStatus *status);
|
||||||
|
|
||||||
Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p);
|
SRes XzUnpacker_CodeFull(CXzUnpacker *p, Byte *dest, SizeT *destLen,
|
||||||
|
const Byte *src, SizeT *srcLen,
|
||||||
|
ECoderFinishMode finishMode, ECoderStatus *status);
|
||||||
|
|
||||||
|
BoolInt XzUnpacker_IsStreamWasFinished(const CXzUnpacker *p);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Call XzUnpacker_GetExtraSize after XzUnpacker_Code function to detect real size of
|
XzUnpacker_GetExtraSize() returns then number of uncofirmed bytes,
|
||||||
xz stream in two cases:
|
if it's in (XZ_STATE_STREAM_HEADER) state or in (XZ_STATE_STREAM_PADDING) state.
|
||||||
XzUnpacker_Code() returns:
|
These bytes can be some bytes after xz archive, or
|
||||||
|
it can be start of new xz stream.
|
||||||
|
|
||||||
|
Call XzUnpacker_GetExtraSize() after XzUnpacker_Code() function to detect real size of
|
||||||
|
xz stream in two cases, if XzUnpacker_Code() returns:
|
||||||
res == SZ_OK && status == CODER_STATUS_NEEDS_MORE_INPUT
|
res == SZ_OK && status == CODER_STATUS_NEEDS_MORE_INPUT
|
||||||
res == SZ_ERROR_NO_ARCHIVE
|
res == SZ_ERROR_NO_ARCHIVE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
UInt64 XzUnpacker_GetExtraSize(CXzUnpacker *p);
|
UInt64 XzUnpacker_GetExtraSize(const CXzUnpacker *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
for random block decoding:
|
||||||
|
XzUnpacker_Init();
|
||||||
|
set CXzUnpacker::streamFlags
|
||||||
|
XzUnpacker_PrepareToRandomBlockDecoding()
|
||||||
|
loop
|
||||||
|
{
|
||||||
|
XzUnpacker_Code()
|
||||||
|
XzUnpacker_IsBlockFinished()
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void XzUnpacker_PrepareToRandomBlockDecoding(CXzUnpacker *p);
|
||||||
|
BoolInt XzUnpacker_IsBlockFinished(const CXzUnpacker *p);
|
||||||
|
|
||||||
|
#define XzUnpacker_GetPackSizeForIndex(p) ((p)->packSize + (p)->blockHeaderSize + XzFlags_GetCheckSize((p)->streamFlags))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------- Multi Threading Decoding ---------- */
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
size_t inBufSize_ST;
|
||||||
|
size_t outStep_ST;
|
||||||
|
BoolInt ignoreErrors;
|
||||||
|
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
unsigned numThreads;
|
||||||
|
size_t inBufSize_MT;
|
||||||
|
size_t memUseMax;
|
||||||
|
#endif
|
||||||
|
} CXzDecMtProps;
|
||||||
|
|
||||||
|
void XzDecMtProps_Init(CXzDecMtProps *p);
|
||||||
|
|
||||||
|
|
||||||
|
typedef void * CXzDecMtHandle;
|
||||||
|
|
||||||
|
/*
|
||||||
|
alloc : XzDecMt uses CAlignOffsetAlloc for addresses allocated by (alloc).
|
||||||
|
allocMid : for big allocations, aligned allocation is better
|
||||||
|
*/
|
||||||
|
|
||||||
|
CXzDecMtHandle XzDecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid);
|
||||||
|
void XzDecMt_Destroy(CXzDecMtHandle p);
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Byte UnpackSize_Defined;
|
||||||
|
Byte NumStreams_Defined;
|
||||||
|
Byte NumBlocks_Defined;
|
||||||
|
|
||||||
|
Byte DataAfterEnd;
|
||||||
|
Byte DecodingTruncated; // Decoding was Truncated, we need only partial output data
|
||||||
|
|
||||||
|
UInt64 InSize; // pack size processed
|
||||||
|
UInt64 OutSize;
|
||||||
|
|
||||||
|
UInt64 NumStreams;
|
||||||
|
UInt64 NumBlocks;
|
||||||
|
|
||||||
|
SRes DecodeRes;
|
||||||
|
SRes ReadRes;
|
||||||
|
SRes ProgressRes;
|
||||||
|
SRes CombinedRes;
|
||||||
|
SRes CombinedRes_Type;
|
||||||
|
|
||||||
|
} CXzStatInfo;
|
||||||
|
|
||||||
|
void XzStatInfo_Clear(CXzStatInfo *p);
|
||||||
|
|
||||||
|
/*
|
||||||
|
XzDecMt_Decode()
|
||||||
|
SRes:
|
||||||
|
SZ_OK - OK
|
||||||
|
SZ_ERROR_MEM - Memory allocation error
|
||||||
|
SZ_ERROR_NO_ARCHIVE - is not xz archive
|
||||||
|
SZ_ERROR_ARCHIVE - Headers error
|
||||||
|
SZ_ERROR_DATA - Data Error
|
||||||
|
SZ_ERROR_CRC - CRC Error
|
||||||
|
SZ_ERROR_INPUT_EOF - it needs more input data
|
||||||
|
SZ_ERROR_WRITE - ISeqOutStream error
|
||||||
|
(SZ_ERROR_READ) - ISeqInStream errors
|
||||||
|
(SZ_ERROR_PROGRESS) - ICompressProgress errors
|
||||||
|
// SZ_ERROR_THREAD - error in multi-threading functions
|
||||||
|
MY_SRes_HRESULT_FROM_WRes(WRes_error) - error in multi-threading function
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRes XzDecMt_Decode(CXzDecMtHandle p,
|
||||||
|
const CXzDecMtProps *props,
|
||||||
|
const UInt64 *outDataSize, // NULL means undefined
|
||||||
|
int finishMode, // 0 - partial unpacking is allowed, 1 - xz stream(s) must be finished
|
||||||
|
ISeqOutStream *outStream,
|
||||||
|
// Byte *outBuf, size_t *outBufSize,
|
||||||
|
ISeqInStream *inStream,
|
||||||
|
// const Byte *inData, size_t inDataSize,
|
||||||
|
CXzStatInfo *stat,
|
||||||
|
int *isMT, // 0 means that ST (Single-Thread) version was used
|
||||||
|
ICompressProgress *progress);
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
|
||||||
|
|||||||
16
C/XzCrc64.c
16
C/XzCrc64.c
@@ -1,5 +1,5 @@
|
|||||||
/* XzCrc64.c -- CRC64 calculation
|
/* XzCrc64.c -- CRC64 calculation
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2017-05-23 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -9,9 +9,9 @@
|
|||||||
#define kCrc64Poly UINT64_CONST(0xC96C5795D7870F42)
|
#define kCrc64Poly UINT64_CONST(0xC96C5795D7870F42)
|
||||||
|
|
||||||
#ifdef MY_CPU_LE
|
#ifdef MY_CPU_LE
|
||||||
#define CRC_NUM_TABLES 4
|
#define CRC64_NUM_TABLES 4
|
||||||
#else
|
#else
|
||||||
#define CRC_NUM_TABLES 5
|
#define CRC64_NUM_TABLES 5
|
||||||
#define CRC_UINT64_SWAP(v) \
|
#define CRC_UINT64_SWAP(v) \
|
||||||
((v >> 56) \
|
((v >> 56) \
|
||||||
| ((v >> 40) & ((UInt64)0xFF << 8)) \
|
| ((v >> 40) & ((UInt64)0xFF << 8)) \
|
||||||
@@ -29,10 +29,10 @@
|
|||||||
UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table);
|
UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef UInt64 (MY_FAST_CALL *CRC_FUNC)(UInt64 v, const void *data, size_t size, const UInt64 *table);
|
typedef UInt64 (MY_FAST_CALL *CRC64_FUNC)(UInt64 v, const void *data, size_t size, const UInt64 *table);
|
||||||
|
|
||||||
static CRC_FUNC g_Crc64Update;
|
static CRC64_FUNC g_Crc64Update;
|
||||||
UInt64 g_Crc64Table[256 * CRC_NUM_TABLES];
|
UInt64 g_Crc64Table[256 * CRC64_NUM_TABLES];
|
||||||
|
|
||||||
UInt64 MY_FAST_CALL Crc64Update(UInt64 v, const void *data, size_t size)
|
UInt64 MY_FAST_CALL Crc64Update(UInt64 v, const void *data, size_t size)
|
||||||
{
|
{
|
||||||
@@ -55,7 +55,7 @@ void MY_FAST_CALL Crc64GenerateTable()
|
|||||||
r = (r >> 1) ^ (kCrc64Poly & ((UInt64)0 - (r & 1)));
|
r = (r >> 1) ^ (kCrc64Poly & ((UInt64)0 - (r & 1)));
|
||||||
g_Crc64Table[i] = r;
|
g_Crc64Table[i] = r;
|
||||||
}
|
}
|
||||||
for (i = 256; i < 256 * CRC_NUM_TABLES; i++)
|
for (i = 256; i < 256 * CRC64_NUM_TABLES; i++)
|
||||||
{
|
{
|
||||||
UInt64 r = g_Crc64Table[(size_t)i - 256];
|
UInt64 r = g_Crc64Table[(size_t)i - 256];
|
||||||
g_Crc64Table[i] = g_Crc64Table[r & 0xFF] ^ (r >> 8);
|
g_Crc64Table[i] = g_Crc64Table[r & 0xFF] ^ (r >> 8);
|
||||||
@@ -74,7 +74,7 @@ void MY_FAST_CALL Crc64GenerateTable()
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--)
|
for (i = 256 * CRC64_NUM_TABLES - 1; i >= 256; i--)
|
||||||
{
|
{
|
||||||
UInt64 x = g_Crc64Table[(size_t)i - 256];
|
UInt64 x = g_Crc64Table[(size_t)i - 256];
|
||||||
g_Crc64Table[i] = CRC_UINT64_SWAP(x);
|
g_Crc64Table[i] = CRC_UINT64_SWAP(x);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* XzCrc64Opt.c -- CRC64 calculation
|
/* XzCrc64Opt.c -- CRC64 calculation
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2017-06-30 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -7,13 +7,13 @@
|
|||||||
|
|
||||||
#ifndef MY_CPU_BE
|
#ifndef MY_CPU_BE
|
||||||
|
|
||||||
#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
#define CRC64_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
||||||
|
|
||||||
UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table)
|
UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table)
|
||||||
{
|
{
|
||||||
const Byte *p = (const Byte *)data;
|
const Byte *p = (const Byte *)data;
|
||||||
for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)
|
for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)
|
||||||
v = CRC_UPDATE_BYTE_2(v, *p);
|
v = CRC64_UPDATE_BYTE_2(v, *p);
|
||||||
for (; size >= 4; size -= 4, p += 4)
|
for (; size >= 4; size -= 4, p += 4)
|
||||||
{
|
{
|
||||||
UInt32 d = (UInt32)v ^ *(const UInt32 *)p;
|
UInt32 d = (UInt32)v ^ *(const UInt32 *)p;
|
||||||
@@ -24,7 +24,7 @@ UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, con
|
|||||||
^ (table + 0x000)[((d >> 24))];
|
^ (table + 0x000)[((d >> 24))];
|
||||||
}
|
}
|
||||||
for (; size > 0; size--, p++)
|
for (; size > 0; size--, p++)
|
||||||
v = CRC_UPDATE_BYTE_2(v, *p);
|
v = CRC64_UPDATE_BYTE_2(v, *p);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, con
|
|||||||
| ((v << 40) & ((UInt64)0xFF << 48)) \
|
| ((v << 40) & ((UInt64)0xFF << 48)) \
|
||||||
| ((v << 56)))
|
| ((v << 56)))
|
||||||
|
|
||||||
#define CRC_UPDATE_BYTE_2_BE(crc, b) (table[(Byte)((crc) >> 56) ^ (b)] ^ ((crc) << 8))
|
#define CRC64_UPDATE_BYTE_2_BE(crc, b) (table[(Byte)((crc) >> 56) ^ (b)] ^ ((crc) << 8))
|
||||||
|
|
||||||
UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table)
|
UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table)
|
||||||
{
|
{
|
||||||
@@ -51,7 +51,7 @@ UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size
|
|||||||
table += 0x100;
|
table += 0x100;
|
||||||
v = CRC_UINT64_SWAP(v);
|
v = CRC_UINT64_SWAP(v);
|
||||||
for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)
|
for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)
|
||||||
v = CRC_UPDATE_BYTE_2_BE(v, *p);
|
v = CRC64_UPDATE_BYTE_2_BE(v, *p);
|
||||||
for (; size >= 4; size -= 4, p += 4)
|
for (; size >= 4; size -= 4, p += 4)
|
||||||
{
|
{
|
||||||
UInt32 d = (UInt32)(v >> 32) ^ *(const UInt32 *)p;
|
UInt32 d = (UInt32)(v >> 32) ^ *(const UInt32 *)p;
|
||||||
@@ -62,7 +62,7 @@ UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size
|
|||||||
^ (table + 0x300)[((d >> 24))];
|
^ (table + 0x300)[((d >> 24))];
|
||||||
}
|
}
|
||||||
for (; size > 0; size--, p++)
|
for (; size > 0; size--, p++)
|
||||||
v = CRC_UPDATE_BYTE_2_BE(v, *p);
|
v = CRC64_UPDATE_BYTE_2_BE(v, *p);
|
||||||
return CRC_UINT64_SWAP(v);
|
return CRC_UINT64_SWAP(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
C/XzEnc.h
27
C/XzEnc.h
@@ -1,5 +1,5 @@
|
|||||||
/* XzEnc.h -- Xz Encode
|
/* XzEnc.h -- Xz Encode
|
||||||
2011-02-07 : Igor Pavlov : Public domain */
|
2017-06-27 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __XZ_ENC_H
|
#ifndef __XZ_ENC_H
|
||||||
#define __XZ_ENC_H
|
#define __XZ_ENC_H
|
||||||
@@ -10,6 +10,11 @@
|
|||||||
|
|
||||||
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
|
||||||
|
#define XZ_PROPS__BLOCK_SIZE__AUTO LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO
|
||||||
|
#define XZ_PROPS__BLOCK_SIZE__SOLID LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UInt32 id;
|
UInt32 id;
|
||||||
@@ -20,15 +25,31 @@ typedef struct
|
|||||||
|
|
||||||
void XzFilterProps_Init(CXzFilterProps *p);
|
void XzFilterProps_Init(CXzFilterProps *p);
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const CLzma2EncProps *lzma2Props;
|
CLzma2EncProps lzma2Props;
|
||||||
const CXzFilterProps *filterProps;
|
CXzFilterProps filterProps;
|
||||||
unsigned checkId;
|
unsigned checkId;
|
||||||
|
UInt64 blockSize;
|
||||||
|
int numBlockThreads_Reduced;
|
||||||
|
int numBlockThreads_Max;
|
||||||
|
int numTotalThreads;
|
||||||
|
int forceWriteSizesInHeader;
|
||||||
|
UInt64 reduceSize;
|
||||||
} CXzProps;
|
} CXzProps;
|
||||||
|
|
||||||
void XzProps_Init(CXzProps *p);
|
void XzProps_Init(CXzProps *p);
|
||||||
|
|
||||||
|
|
||||||
|
typedef void * CXzEncHandle;
|
||||||
|
|
||||||
|
CXzEncHandle XzEnc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
||||||
|
void XzEnc_Destroy(CXzEncHandle p);
|
||||||
|
SRes XzEnc_SetProps(CXzEncHandle p, const CXzProps *props);
|
||||||
|
void XzEnc_SetDataSize(CXzEncHandle p, UInt64 expectedDataSiize);
|
||||||
|
SRes XzEnc_Encode(CXzEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress);
|
||||||
|
|
||||||
SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,
|
SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,
|
||||||
const CXzProps *props, ICompressProgress *progress);
|
const CXzProps *props, ICompressProgress *progress);
|
||||||
|
|
||||||
|
|||||||
38
C/XzIn.c
38
C/XzIn.c
@@ -1,5 +1,5 @@
|
|||||||
/* XzIn.c - Xz input
|
/* XzIn.c - Xz input
|
||||||
2017-04-03 : Igor Pavlov : Public domain */
|
2018-07-04 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -9,6 +9,12 @@
|
|||||||
#include "CpuArch.h"
|
#include "CpuArch.h"
|
||||||
#include "Xz.h"
|
#include "Xz.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define XZ_FOOTER_SIG_CHECK(p) (memcmp((p), XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) == 0)
|
||||||
|
*/
|
||||||
|
#define XZ_FOOTER_SIG_CHECK(p) ((p)[0] == XZ_FOOTER_SIG_0 && (p)[1] == XZ_FOOTER_SIG_1)
|
||||||
|
|
||||||
|
|
||||||
SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream)
|
SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream)
|
||||||
{
|
{
|
||||||
Byte sig[XZ_STREAM_HEADER_SIZE];
|
Byte sig[XZ_STREAM_HEADER_SIZE];
|
||||||
@@ -22,13 +28,13 @@ SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream)
|
|||||||
{ unsigned s = Xz_ReadVarInt(buf + pos, size - pos, res); \
|
{ unsigned s = Xz_ReadVarInt(buf + pos, size - pos, res); \
|
||||||
if (s == 0) return SZ_ERROR_ARCHIVE; pos += s; }
|
if (s == 0) return SZ_ERROR_ARCHIVE; pos += s; }
|
||||||
|
|
||||||
SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, Bool *isIndex, UInt32 *headerSizeRes)
|
SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, BoolInt *isIndex, UInt32 *headerSizeRes)
|
||||||
{
|
{
|
||||||
Byte header[XZ_BLOCK_HEADER_SIZE_MAX];
|
Byte header[XZ_BLOCK_HEADER_SIZE_MAX];
|
||||||
unsigned headerSize;
|
unsigned headerSize;
|
||||||
*headerSizeRes = 0;
|
*headerSizeRes = 0;
|
||||||
RINOK(SeqInStream_ReadByte(inStream, &header[0]));
|
RINOK(SeqInStream_ReadByte(inStream, &header[0]));
|
||||||
headerSize = ((unsigned)header[0] << 2) + 4;
|
headerSize = (unsigned)header[0];
|
||||||
if (headerSize == 0)
|
if (headerSize == 0)
|
||||||
{
|
{
|
||||||
*headerSizeRes = 1;
|
*headerSizeRes = 1;
|
||||||
@@ -37,12 +43,13 @@ SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, Bool *isIndex, UInt
|
|||||||
}
|
}
|
||||||
|
|
||||||
*isIndex = False;
|
*isIndex = False;
|
||||||
|
headerSize = (headerSize << 2) + 4;
|
||||||
*headerSizeRes = headerSize;
|
*headerSizeRes = headerSize;
|
||||||
RINOK(SeqInStream_Read(inStream, header + 1, headerSize - 1));
|
RINOK(SeqInStream_Read(inStream, header + 1, headerSize - 1));
|
||||||
return XzBlock_Parse(p, header);
|
return XzBlock_Parse(p, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ADD_SIZE_CHECH(size, val) \
|
#define ADD_SIZE_CHECK(size, val) \
|
||||||
{ UInt64 newSize = size + (val); if (newSize < size) return XZ_SIZE_OVERFLOW; size = newSize; }
|
{ UInt64 newSize = size + (val); if (newSize < size) return XZ_SIZE_OVERFLOW; size = newSize; }
|
||||||
|
|
||||||
UInt64 Xz_GetUnpackSize(const CXzStream *p)
|
UInt64 Xz_GetUnpackSize(const CXzStream *p)
|
||||||
@@ -50,7 +57,7 @@ UInt64 Xz_GetUnpackSize(const CXzStream *p)
|
|||||||
UInt64 size = 0;
|
UInt64 size = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < p->numBlocks; i++)
|
for (i = 0; i < p->numBlocks; i++)
|
||||||
ADD_SIZE_CHECH(size, p->blocks[i].unpackSize);
|
ADD_SIZE_CHECK(size, p->blocks[i].unpackSize);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +66,7 @@ UInt64 Xz_GetPackSize(const CXzStream *p)
|
|||||||
UInt64 size = 0;
|
UInt64 size = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < p->numBlocks; i++)
|
for (i = 0; i < p->numBlocks; i++)
|
||||||
ADD_SIZE_CHECH(size, (p->blocks[i].totalSize + 3) & ~(UInt64)3);
|
ADD_SIZE_CHECK(size, (p->blocks[i].totalSize + 3) & ~(UInt64)3);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,9 +103,8 @@ static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAllocPt
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
p->numBlocks = numBlocks;
|
p->numBlocks = numBlocks;
|
||||||
p->numBlocksAllocated = numBlocks;
|
p->blocks = (CXzBlockSizes *)ISzAlloc_Alloc(alloc, sizeof(CXzBlockSizes) * numBlocks);
|
||||||
p->blocks = ISzAlloc_Alloc(alloc, sizeof(CXzBlockSizes) * numBlocks);
|
if (!p->blocks)
|
||||||
if (p->blocks == 0)
|
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
for (i = 0; i < numBlocks; i++)
|
for (i = 0; i < numBlocks; i++)
|
||||||
{
|
{
|
||||||
@@ -125,8 +131,8 @@ static SRes Xz_ReadIndex(CXzStream *p, ILookInStream *stream, UInt64 indexSize,
|
|||||||
size = (size_t)indexSize;
|
size = (size_t)indexSize;
|
||||||
if (size != indexSize)
|
if (size != indexSize)
|
||||||
return SZ_ERROR_UNSUPPORTED;
|
return SZ_ERROR_UNSUPPORTED;
|
||||||
buf = ISzAlloc_Alloc(alloc, size);
|
buf = (Byte *)ISzAlloc_Alloc(alloc, size);
|
||||||
if (buf == 0)
|
if (!buf)
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
res = LookInStream_Read2(stream, buf, size, SZ_ERROR_UNSUPPORTED);
|
res = LookInStream_Read2(stream, buf, size, SZ_ERROR_UNSUPPORTED);
|
||||||
if (res == SZ_OK)
|
if (res == SZ_OK)
|
||||||
@@ -154,7 +160,7 @@ static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOff
|
|||||||
pos -= XZ_STREAM_FOOTER_SIZE;
|
pos -= XZ_STREAM_FOOTER_SIZE;
|
||||||
RINOK(LookInStream_SeekRead_ForArc(stream, pos, buf, XZ_STREAM_FOOTER_SIZE));
|
RINOK(LookInStream_SeekRead_ForArc(stream, pos, buf, XZ_STREAM_FOOTER_SIZE));
|
||||||
|
|
||||||
if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)
|
if (!XZ_FOOTER_SIG_CHECK(buf + 10))
|
||||||
{
|
{
|
||||||
UInt32 total = 0;
|
UInt32 total = 0;
|
||||||
pos += XZ_STREAM_FOOTER_SIZE;
|
pos += XZ_STREAM_FOOTER_SIZE;
|
||||||
@@ -187,7 +193,7 @@ static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOff
|
|||||||
return SZ_ERROR_NO_ARCHIVE;
|
return SZ_ERROR_NO_ARCHIVE;
|
||||||
pos -= XZ_STREAM_FOOTER_SIZE;
|
pos -= XZ_STREAM_FOOTER_SIZE;
|
||||||
RINOK(LookInStream_SeekRead_ForArc(stream, pos, buf, XZ_STREAM_FOOTER_SIZE));
|
RINOK(LookInStream_SeekRead_ForArc(stream, pos, buf, XZ_STREAM_FOOTER_SIZE));
|
||||||
if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)
|
if (!XZ_FOOTER_SIG_CHECK(buf + 10))
|
||||||
return SZ_ERROR_NO_ARCHIVE;
|
return SZ_ERROR_NO_ARCHIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +268,7 @@ UInt64 Xzs_GetUnpackSize(const CXzs *p)
|
|||||||
UInt64 size = 0;
|
UInt64 size = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < p->num; i++)
|
for (i = 0; i < p->num; i++)
|
||||||
ADD_SIZE_CHECH(size, Xz_GetUnpackSize(&p->streams[i]));
|
ADD_SIZE_CHECK(size, Xz_GetUnpackSize(&p->streams[i]));
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +278,7 @@ UInt64 Xzs_GetPackSize(const CXzs *p)
|
|||||||
UInt64 size = 0;
|
UInt64 size = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < p->num; i++)
|
for (i = 0; i < p->num; i++)
|
||||||
ADD_SIZE_CHECH(size, Xz_GetTotalSize(&p->streams[i]));
|
ADD_SIZE_CHECK(size, Xz_GetTotalSize(&p->streams[i]));
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@@ -294,7 +300,7 @@ SRes Xzs_ReadBackward(CXzs *p, ILookInStream *stream, Int64 *startOffset, ICompr
|
|||||||
{
|
{
|
||||||
size_t newNum = p->num + p->num / 4 + 1;
|
size_t newNum = p->num + p->num / 4 + 1;
|
||||||
Byte *data = (Byte *)ISzAlloc_Alloc(alloc, newNum * sizeof(CXzStream));
|
Byte *data = (Byte *)ISzAlloc_Alloc(alloc, newNum * sizeof(CXzStream));
|
||||||
if (data == 0)
|
if (!data)
|
||||||
return SZ_ERROR_MEM;
|
return SZ_ERROR_MEM;
|
||||||
p->numAllocated = newNum;
|
p->numAllocated = newNum;
|
||||||
if (p->num != 0)
|
if (p->num != 0)
|
||||||
|
|||||||
502
COPYING
Normal file
502
COPYING
Normal file
@@ -0,0 +1,502 @@
|
|||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 2.1, February 1999
|
||||||
|
|
||||||
|
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
[This is the first released version of the Lesser GPL. It also counts
|
||||||
|
as the successor of the GNU Library Public License, version 2, hence
|
||||||
|
the version number 2.1.]
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
Licenses are intended to guarantee your freedom to share and change
|
||||||
|
free software--to make sure the software is free for all its users.
|
||||||
|
|
||||||
|
This license, the Lesser General Public License, applies to some
|
||||||
|
specially designated software packages--typically libraries--of the
|
||||||
|
Free Software Foundation and other authors who decide to use it. You
|
||||||
|
can use it too, but we suggest you first think carefully about whether
|
||||||
|
this license or the ordinary General Public License is the better
|
||||||
|
strategy to use in any particular case, based on the explanations below.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom of use,
|
||||||
|
not price. Our General Public Licenses are designed to make sure that
|
||||||
|
you have the freedom to distribute copies of free software (and charge
|
||||||
|
for this service if you wish); that you receive source code or can get
|
||||||
|
it if you want it; that you can change the software and use pieces of
|
||||||
|
it in new free programs; and that you are informed that you can do
|
||||||
|
these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
distributors to deny you these rights or to ask you to surrender these
|
||||||
|
rights. These restrictions translate to certain responsibilities for
|
||||||
|
you if you distribute copies of the library or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of the library, whether gratis
|
||||||
|
or for a fee, you must give the recipients all the rights that we gave
|
||||||
|
you. You must make sure that they, too, receive or can get the source
|
||||||
|
code. If you link other code with the library, you must provide
|
||||||
|
complete object files to the recipients, so that they can relink them
|
||||||
|
with the library after making changes to the library and recompiling
|
||||||
|
it. And you must show them these terms so they know their rights.
|
||||||
|
|
||||||
|
We protect your rights with a two-step method: (1) we copyright the
|
||||||
|
library, and (2) we offer you this license, which gives you legal
|
||||||
|
permission to copy, distribute and/or modify the library.
|
||||||
|
|
||||||
|
To protect each distributor, we want to make it very clear that
|
||||||
|
there is no warranty for the free library. Also, if the library is
|
||||||
|
modified by someone else and passed on, the recipients should know
|
||||||
|
that what they have is not the original version, so that the original
|
||||||
|
author's reputation will not be affected by problems that might be
|
||||||
|
introduced by others.
|
||||||
|
|
||||||
|
Finally, software patents pose a constant threat to the existence of
|
||||||
|
any free program. We wish to make sure that a company cannot
|
||||||
|
effectively restrict the users of a free program by obtaining a
|
||||||
|
restrictive license from a patent holder. Therefore, we insist that
|
||||||
|
any patent license obtained for a version of the library must be
|
||||||
|
consistent with the full freedom of use specified in this license.
|
||||||
|
|
||||||
|
Most GNU software, including some libraries, is covered by the
|
||||||
|
ordinary GNU General Public License. This license, the GNU Lesser
|
||||||
|
General Public License, applies to certain designated libraries, and
|
||||||
|
is quite different from the ordinary General Public License. We use
|
||||||
|
this license for certain libraries in order to permit linking those
|
||||||
|
libraries into non-free programs.
|
||||||
|
|
||||||
|
When a program is linked with a library, whether statically or using
|
||||||
|
a shared library, the combination of the two is legally speaking a
|
||||||
|
combined work, a derivative of the original library. The ordinary
|
||||||
|
General Public License therefore permits such linking only if the
|
||||||
|
entire combination fits its criteria of freedom. The Lesser General
|
||||||
|
Public License permits more lax criteria for linking other code with
|
||||||
|
the library.
|
||||||
|
|
||||||
|
We call this license the "Lesser" General Public License because it
|
||||||
|
does Less to protect the user's freedom than the ordinary General
|
||||||
|
Public License. It also provides other free software developers Less
|
||||||
|
of an advantage over competing non-free programs. These disadvantages
|
||||||
|
are the reason we use the ordinary General Public License for many
|
||||||
|
libraries. However, the Lesser license provides advantages in certain
|
||||||
|
special circumstances.
|
||||||
|
|
||||||
|
For example, on rare occasions, there may be a special need to
|
||||||
|
encourage the widest possible use of a certain library, so that it becomes
|
||||||
|
a de-facto standard. To achieve this, non-free programs must be
|
||||||
|
allowed to use the library. A more frequent case is that a free
|
||||||
|
library does the same job as widely used non-free libraries. In this
|
||||||
|
case, there is little to gain by limiting the free library to free
|
||||||
|
software only, so we use the Lesser General Public License.
|
||||||
|
|
||||||
|
In other cases, permission to use a particular library in non-free
|
||||||
|
programs enables a greater number of people to use a large body of
|
||||||
|
free software. For example, permission to use the GNU C Library in
|
||||||
|
non-free programs enables many more people to use the whole GNU
|
||||||
|
operating system, as well as its variant, the GNU/Linux operating
|
||||||
|
system.
|
||||||
|
|
||||||
|
Although the Lesser General Public License is Less protective of the
|
||||||
|
users' freedom, it does ensure that the user of a program that is
|
||||||
|
linked with the Library has the freedom and the wherewithal to run
|
||||||
|
that program using a modified version of the Library.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow. Pay close attention to the difference between a
|
||||||
|
"work based on the library" and a "work that uses the library". The
|
||||||
|
former contains code derived from the library, whereas the latter must
|
||||||
|
be combined with the library in order to run.
|
||||||
|
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License Agreement applies to any software library or other
|
||||||
|
program which contains a notice placed by the copyright holder or
|
||||||
|
other authorized party saying it may be distributed under the terms of
|
||||||
|
this Lesser General Public License (also called "this License").
|
||||||
|
Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
A "library" means a collection of software functions and/or data
|
||||||
|
prepared so as to be conveniently linked with application programs
|
||||||
|
(which use some of those functions and data) to form executables.
|
||||||
|
|
||||||
|
The "Library", below, refers to any such software library or work
|
||||||
|
which has been distributed under these terms. A "work based on the
|
||||||
|
Library" means either the Library or any derivative work under
|
||||||
|
copyright law: that is to say, a work containing the Library or a
|
||||||
|
portion of it, either verbatim or with modifications and/or translated
|
||||||
|
straightforwardly into another language. (Hereinafter, translation is
|
||||||
|
included without limitation in the term "modification".)
|
||||||
|
|
||||||
|
"Source code" for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For a library, complete source code means
|
||||||
|
all the source code for all modules it contains, plus any associated
|
||||||
|
interface definition files, plus the scripts used to control compilation
|
||||||
|
and installation of the library.
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running a program using the Library is not restricted, and output from
|
||||||
|
such a program is covered only if its contents constitute a work based
|
||||||
|
on the Library (independent of the use of the Library in a tool for
|
||||||
|
writing it). Whether that is true depends on what the Library does
|
||||||
|
and what the program that uses the Library does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Library's
|
||||||
|
complete source code as you receive it, in any medium, provided that
|
||||||
|
you conspicuously and appropriately publish on each copy an
|
||||||
|
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||||
|
all the notices that refer to this License and to the absence of any
|
||||||
|
warranty; and distribute a copy of this License along with the
|
||||||
|
Library.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy,
|
||||||
|
and you may at your option offer warranty protection in exchange for a
|
||||||
|
fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Library or any portion
|
||||||
|
of it, thus forming a work based on the Library, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The modified work must itself be a software library.
|
||||||
|
|
||||||
|
b) You must cause the files modified to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
c) You must cause the whole of the work to be licensed at no
|
||||||
|
charge to all third parties under the terms of this License.
|
||||||
|
|
||||||
|
d) If a facility in the modified Library refers to a function or a
|
||||||
|
table of data to be supplied by an application program that uses
|
||||||
|
the facility, other than as an argument passed when the facility
|
||||||
|
is invoked, then you must make a good faith effort to ensure that,
|
||||||
|
in the event an application does not supply such function or
|
||||||
|
table, the facility still operates, and performs whatever part of
|
||||||
|
its purpose remains meaningful.
|
||||||
|
|
||||||
|
(For example, a function in a library to compute square roots has
|
||||||
|
a purpose that is entirely well-defined independent of the
|
||||||
|
application. Therefore, Subsection 2d requires that any
|
||||||
|
application-supplied function or table used by this function must
|
||||||
|
be optional: if the application does not supply it, the square
|
||||||
|
root function must still compute square roots.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Library,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Library, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote
|
||||||
|
it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Library.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Library
|
||||||
|
with the Library (or with a work based on the Library) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||||
|
License instead of this License to a given copy of the Library. To do
|
||||||
|
this, you must alter all the notices that refer to this License, so
|
||||||
|
that they refer to the ordinary GNU General Public License, version 2,
|
||||||
|
instead of to this License. (If a newer version than version 2 of the
|
||||||
|
ordinary GNU General Public License has appeared, then you can specify
|
||||||
|
that version instead if you wish.) Do not make any other change in
|
||||||
|
these notices.
|
||||||
|
|
||||||
|
Once this change is made in a given copy, it is irreversible for
|
||||||
|
that copy, so the ordinary GNU General Public License applies to all
|
||||||
|
subsequent copies and derivative works made from that copy.
|
||||||
|
|
||||||
|
This option is useful when you wish to copy part of the code of
|
||||||
|
the Library into a program that is not a library.
|
||||||
|
|
||||||
|
4. You may copy and distribute the Library (or a portion or
|
||||||
|
derivative of it, under Section 2) in object code or executable form
|
||||||
|
under the terms of Sections 1 and 2 above provided that you accompany
|
||||||
|
it with the complete corresponding machine-readable source code, which
|
||||||
|
must be distributed under the terms of Sections 1 and 2 above on a
|
||||||
|
medium customarily used for software interchange.
|
||||||
|
|
||||||
|
If distribution of object code is made by offering access to copy
|
||||||
|
from a designated place, then offering equivalent access to copy the
|
||||||
|
source code from the same place satisfies the requirement to
|
||||||
|
distribute the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
5. A program that contains no derivative of any portion of the
|
||||||
|
Library, but is designed to work with the Library by being compiled or
|
||||||
|
linked with it, is called a "work that uses the Library". Such a
|
||||||
|
work, in isolation, is not a derivative work of the Library, and
|
||||||
|
therefore falls outside the scope of this License.
|
||||||
|
|
||||||
|
However, linking a "work that uses the Library" with the Library
|
||||||
|
creates an executable that is a derivative of the Library (because it
|
||||||
|
contains portions of the Library), rather than a "work that uses the
|
||||||
|
library". The executable is therefore covered by this License.
|
||||||
|
Section 6 states terms for distribution of such executables.
|
||||||
|
|
||||||
|
When a "work that uses the Library" uses material from a header file
|
||||||
|
that is part of the Library, the object code for the work may be a
|
||||||
|
derivative work of the Library even though the source code is not.
|
||||||
|
Whether this is true is especially significant if the work can be
|
||||||
|
linked without the Library, or if the work is itself a library. The
|
||||||
|
threshold for this to be true is not precisely defined by law.
|
||||||
|
|
||||||
|
If such an object file uses only numerical parameters, data
|
||||||
|
structure layouts and accessors, and small macros and small inline
|
||||||
|
functions (ten lines or less in length), then the use of the object
|
||||||
|
file is unrestricted, regardless of whether it is legally a derivative
|
||||||
|
work. (Executables containing this object code plus portions of the
|
||||||
|
Library will still fall under Section 6.)
|
||||||
|
|
||||||
|
Otherwise, if the work is a derivative of the Library, you may
|
||||||
|
distribute the object code for the work under the terms of Section 6.
|
||||||
|
Any executables containing that work also fall under Section 6,
|
||||||
|
whether or not they are linked directly with the Library itself.
|
||||||
|
|
||||||
|
6. As an exception to the Sections above, you may also combine or
|
||||||
|
link a "work that uses the Library" with the Library to produce a
|
||||||
|
work containing portions of the Library, and distribute that work
|
||||||
|
under terms of your choice, provided that the terms permit
|
||||||
|
modification of the work for the customer's own use and reverse
|
||||||
|
engineering for debugging such modifications.
|
||||||
|
|
||||||
|
You must give prominent notice with each copy of the work that the
|
||||||
|
Library is used in it and that the Library and its use are covered by
|
||||||
|
this License. You must supply a copy of this License. If the work
|
||||||
|
during execution displays copyright notices, you must include the
|
||||||
|
copyright notice for the Library among them, as well as a reference
|
||||||
|
directing the user to the copy of this License. Also, you must do one
|
||||||
|
of these things:
|
||||||
|
|
||||||
|
a) Accompany the work with the complete corresponding
|
||||||
|
machine-readable source code for the Library including whatever
|
||||||
|
changes were used in the work (which must be distributed under
|
||||||
|
Sections 1 and 2 above); and, if the work is an executable linked
|
||||||
|
with the Library, with the complete machine-readable "work that
|
||||||
|
uses the Library", as object code and/or source code, so that the
|
||||||
|
user can modify the Library and then relink to produce a modified
|
||||||
|
executable containing the modified Library. (It is understood
|
||||||
|
that the user who changes the contents of definitions files in the
|
||||||
|
Library will not necessarily be able to recompile the application
|
||||||
|
to use the modified definitions.)
|
||||||
|
|
||||||
|
b) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (1) uses at run time a
|
||||||
|
copy of the library already present on the user's computer system,
|
||||||
|
rather than copying library functions into the executable, and (2)
|
||||||
|
will operate properly with a modified version of the library, if
|
||||||
|
the user installs one, as long as the modified version is
|
||||||
|
interface-compatible with the version that the work was made with.
|
||||||
|
|
||||||
|
c) Accompany the work with a written offer, valid for at
|
||||||
|
least three years, to give the same user the materials
|
||||||
|
specified in Subsection 6a, above, for a charge no more
|
||||||
|
than the cost of performing this distribution.
|
||||||
|
|
||||||
|
d) If distribution of the work is made by offering access to copy
|
||||||
|
from a designated place, offer equivalent access to copy the above
|
||||||
|
specified materials from the same place.
|
||||||
|
|
||||||
|
e) Verify that the user has already received a copy of these
|
||||||
|
materials or that you have already sent this user a copy.
|
||||||
|
|
||||||
|
For an executable, the required form of the "work that uses the
|
||||||
|
Library" must include any data and utility programs needed for
|
||||||
|
reproducing the executable from it. However, as a special exception,
|
||||||
|
the materials to be distributed need not include anything that is
|
||||||
|
normally distributed (in either source or binary form) with the major
|
||||||
|
components (compiler, kernel, and so on) of the operating system on
|
||||||
|
which the executable runs, unless that component itself accompanies
|
||||||
|
the executable.
|
||||||
|
|
||||||
|
It may happen that this requirement contradicts the license
|
||||||
|
restrictions of other proprietary libraries that do not normally
|
||||||
|
accompany the operating system. Such a contradiction means you cannot
|
||||||
|
use both them and the Library together in an executable that you
|
||||||
|
distribute.
|
||||||
|
|
||||||
|
7. You may place library facilities that are a work based on the
|
||||||
|
Library side-by-side in a single library together with other library
|
||||||
|
facilities not covered by this License, and distribute such a combined
|
||||||
|
library, provided that the separate distribution of the work based on
|
||||||
|
the Library and of the other library facilities is otherwise
|
||||||
|
permitted, and provided that you do these two things:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work
|
||||||
|
based on the Library, uncombined with any other library
|
||||||
|
facilities. This must be distributed under the terms of the
|
||||||
|
Sections above.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library of the fact
|
||||||
|
that part of it is a work based on the Library, and explaining
|
||||||
|
where to find the accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
8. You may not copy, modify, sublicense, link with, or distribute
|
||||||
|
the Library except as expressly provided under this License. Any
|
||||||
|
attempt otherwise to copy, modify, sublicense, link with, or
|
||||||
|
distribute the Library is void, and will automatically terminate your
|
||||||
|
rights under this License. However, parties who have received copies,
|
||||||
|
or rights, from you under this License will not have their licenses
|
||||||
|
terminated so long as such parties remain in full compliance.
|
||||||
|
|
||||||
|
9. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Library or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Library (or any work based on the
|
||||||
|
Library), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Library or works based on it.
|
||||||
|
|
||||||
|
10. Each time you redistribute the Library (or any work based on the
|
||||||
|
Library), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute, link with or modify the Library
|
||||||
|
subject to these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties with
|
||||||
|
this License.
|
||||||
|
|
||||||
|
11. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Library at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Library by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Library.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under any
|
||||||
|
particular circumstance, the balance of the section is intended to apply,
|
||||||
|
and the section as a whole is intended to apply in other circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
12. If the distribution and/or use of the Library is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Library under this License may add
|
||||||
|
an explicit geographical distribution limitation excluding those countries,
|
||||||
|
so that distribution is permitted only in or among countries not thus
|
||||||
|
excluded. In such case, this License incorporates the limitation as if
|
||||||
|
written in the body of this License.
|
||||||
|
|
||||||
|
13. The Free Software Foundation may publish revised and/or new
|
||||||
|
versions of the Lesser General Public License from time to time.
|
||||||
|
Such new versions will be similar in spirit to the present version,
|
||||||
|
but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Library
|
||||||
|
specifies a version number of this License which applies to it and
|
||||||
|
"any later version", you have the option of following the terms and
|
||||||
|
conditions either of that version or of any later version published by
|
||||||
|
the Free Software Foundation. If the Library does not specify a
|
||||||
|
license version number, you may choose any version ever published by
|
||||||
|
the Free Software Foundation.
|
||||||
|
|
||||||
|
14. If you wish to incorporate parts of the Library into other free
|
||||||
|
programs whose distribution conditions are incompatible with these,
|
||||||
|
write to the author to ask for permission. For software which is
|
||||||
|
copyrighted by the Free Software Foundation, write to the Free
|
||||||
|
Software Foundation; we sometimes make exceptions for this. Our
|
||||||
|
decision will be guided by the two goals of preserving the free status
|
||||||
|
of all derivatives of our free software and of promoting the sharing
|
||||||
|
and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||||
|
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||||
|
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||||
|
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||||
|
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||||
|
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||||
|
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||||
|
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||||
|
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||||
|
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||||
|
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||||
|
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||||
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||||
|
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||||
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||||
|
DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Libraries
|
||||||
|
|
||||||
|
If you develop a new library, and you want it to be of the greatest
|
||||||
|
possible use to the public, we recommend making it free software that
|
||||||
|
everyone can redistribute and change. You can do so by permitting
|
||||||
|
redistribution under these terms (or, alternatively, under the terms of the
|
||||||
|
ordinary General Public License).
|
||||||
|
|
||||||
|
To apply these terms, attach the following notices to the library. It is
|
||||||
|
safest to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least the
|
||||||
|
"copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the library's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||||
|
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1990
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
That's all there is to it!
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
C_OBJS = $(C_OBJS) \
|
C_OBJS = $(C_OBJS) \
|
||||||
$O\Aes.obj
|
$O\Aes.obj
|
||||||
|
|
||||||
!IF "$(CPU)" != "IA64" && "$(CPU)" != "MIPS" && "$(CPU)" != "ARM" && "$(CPU)" != "ARM64"
|
!IF "$(PLATFORM)" != "ia64" && "$(PLATFORM)" != "mips" && "$(PLATFORM)" != "arm" && "$(PLATFORM)" != "arm64"
|
||||||
ASM_OBJS = $(ASM_OBJS) \
|
ASM_OBJS = $(ASM_OBJS) \
|
||||||
$O\AesOpt.obj
|
$O\AesOpt.obj
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|||||||
@@ -1,642 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="7z" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
|
||||||
|
|
||||||
CFG=7z - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "7z.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "7z.mak" CFG="7z - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "7z - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
|
||||||
!MESSAGE "7z - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
MTL=midl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "7z - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir "Release"
|
|
||||||
# PROP BASE Intermediate_Dir "Release"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir "Release"
|
|
||||||
# PROP Intermediate_Dir "Release"
|
|
||||||
# PROP Ignore_Export_Lib 1
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
|
|
||||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
|
||||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 /nologo /dll /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 /nologo /dll /machine:I386 /out:"C:\Program Files\7-zip\Formats\7z.dll" /opt:NOWIN98
|
|
||||||
# SUBTRACT LINK32 /pdb:none
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "7z - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir "Debug"
|
|
||||||
# PROP BASE Intermediate_Dir "Debug"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir "Debug"
|
|
||||||
# PROP Intermediate_Dir "Debug"
|
|
||||||
# PROP Ignore_Export_Lib 1
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
|
|
||||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
|
||||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
|
||||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
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 /nologo /dll /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 /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-zip\Formats\7z.dll" /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "7z - Win32 Release"
|
|
||||||
# Name "7z - Win32 Debug"
|
|
||||||
# Begin Group "Spec"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Archive.def
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\ArchiveExports.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\DllExports.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\resource.rc
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\StdAfx.cpp
|
|
||||||
# ADD CPP /Yc"StdAfx.h"
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\StdAfx.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Engine"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zCompressionMode.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zCompressionMode.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zDecode.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zDecode.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zEncode.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zEncode.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zExtract.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zFolderInStream.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zFolderInStream.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zHandler.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zHandler.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zHandlerOut.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zHeader.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zHeader.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zIn.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zIn.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zItem.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zOut.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zOut.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zProperties.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zProperties.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zRegister.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zSpecStream.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zSpecStream.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zUpdate.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\7zUpdate.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Interface"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\IArchive.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\ICoder.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\IMyUnknown.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\IPassword.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\IProgress.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\IStream.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\PropID.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Common"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\Buffer.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\CRC.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\DynamicBuffer.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\IntToString.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\IntToString.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\MyString.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\MyString.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\MyVector.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\MyVector.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\NewHandler.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\StringConvert.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\StringToInt.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\StringToInt.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\Wildcard.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Common\Wildcard.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Archive Common"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\CoderMixer2.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\CoderMixer2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\HandlerOut.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\HandlerOut.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\InStreamWithCRC.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\InStreamWithCRC.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\ItemNameUtils.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\ItemNameUtils.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\MultiStream.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\MultiStream.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\OutStreamWithCRC.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\OutStreamWithCRC.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\ParseProperties.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\Common\ParseProperties.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "7-Zip Common"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\CreateCoder.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\CreateCoder.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\FilterCoder.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\FilterCoder.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\InOutTempBuffer.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\InOutTempBuffer.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\LimitedStreams.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\LimitedStreams.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\LockedStream.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\LockedStream.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\MethodId.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\MethodId.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\MethodProps.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\MethodProps.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\OutBuffer.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\OutBuffer.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\ProgressUtils.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\PropId.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\RegisterArc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\RegisterCodec.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\StreamBinder.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\StreamBinder.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\StreamObjects.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\StreamObjects.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\StreamUtils.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\StreamUtils.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\VirtThread.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Common\VirtThread.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Windows"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\DLL.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\DLL.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\FileDir.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\FileDir.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\FileFind.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\FileFind.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\FileIO.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\FileIO.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\FileName.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\FileName.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\Handle.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\PropVariant.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\Synchronization.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\Synchronization.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\System.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\System.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\Windows\Thread.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Compress"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Compress\CopyCoder.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\Compress\CopyCoder.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "C"
|
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\7zCrc.c
|
|
||||||
# SUBTRACT CPP /YX /Yc /Yu
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\7zCrc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\7zCrcOpt.c
|
|
||||||
# SUBTRACT CPP /YX /Yc /Yu
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\Alloc.c
|
|
||||||
# SUBTRACT CPP /YX /Yc /Yu
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\Alloc.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\CpuArch.c
|
|
||||||
# SUBTRACT CPP /YX /Yc /Yu
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\Threads.c
|
|
||||||
# SUBTRACT CPP /YX /Yc /Yu
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\Threads.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
|
||||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "7z"=".\7z.dsp" - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Global:
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<3>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
@@ -13,7 +13,9 @@ struct CMethodFull: public CMethodProps
|
|||||||
{
|
{
|
||||||
CMethodId Id;
|
CMethodId Id;
|
||||||
UInt32 NumStreams;
|
UInt32 NumStreams;
|
||||||
|
int CodecIndex;
|
||||||
|
|
||||||
|
CMethodFull(): CodecIndex(-1) {}
|
||||||
bool IsSimpleCoder() const { return NumStreams == 1; }
|
bool IsSimpleCoder() const { return NumStreams == 1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -236,8 +236,8 @@ HRESULT CDecoder::Decode(
|
|||||||
|
|
||||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||||
|
|
||||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
#if !defined(_7ZIP_ST)
|
||||||
, bool mtMode, UInt32 numThreads
|
, bool mtMode, UInt32 numThreads, UInt64 memUsage
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -312,7 +312,7 @@ HRESULT CDecoder::Decode(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
CCreatedCoder cod;
|
CCreatedCoder cod;
|
||||||
RINOK(CreateCoder(
|
RINOK(CreateCoder_Id(
|
||||||
EXTERNAL_CODECS_LOC_VARS
|
EXTERNAL_CODECS_LOC_VARS
|
||||||
coderInfo.MethodID, false, cod));
|
coderInfo.MethodID, false, cod));
|
||||||
|
|
||||||
@@ -355,11 +355,41 @@ HRESULT CDecoder::Decode(
|
|||||||
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
#if !defined(_7ZIP_ST)
|
||||||
|
bool mt_wasUsed = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < folderInfo.Coders.Size(); i++)
|
for (i = 0; i < folderInfo.Coders.Size(); i++)
|
||||||
{
|
{
|
||||||
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
const CCoderInfo &coderInfo = folderInfo.Coders[i];
|
||||||
IUnknown *decoder = _mixer->GetCoder(i).GetUnknown();
|
IUnknown *decoder = _mixer->GetCoder(i).GetUnknown();
|
||||||
|
|
||||||
|
#if !defined(_7ZIP_ST)
|
||||||
|
if (!mt_wasUsed)
|
||||||
|
{
|
||||||
|
if (mtMode)
|
||||||
|
{
|
||||||
|
CMyComPtr<ICompressSetCoderMt> setCoderMt;
|
||||||
|
decoder->QueryInterface(IID_ICompressSetCoderMt, (void **)&setCoderMt);
|
||||||
|
if (setCoderMt)
|
||||||
|
{
|
||||||
|
mt_wasUsed = true;
|
||||||
|
RINOK(setCoderMt->SetNumberOfThreads(numThreads));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if (memUsage != 0)
|
||||||
|
{
|
||||||
|
CMyComPtr<ICompressSetMemLimit> setMemLimit;
|
||||||
|
decoder->QueryInterface(IID_ICompressSetMemLimit, (void **)&setMemLimit);
|
||||||
|
if (setMemLimit)
|
||||||
|
{
|
||||||
|
mt_wasUsed = true;
|
||||||
|
RINOK(setMemLimit->SetMemLimit(memUsage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
|
CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties;
|
||||||
decoder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
|
decoder->QueryInterface(IID_ICompressSetDecoderProperties2, (void **)&setDecoderProperties);
|
||||||
@@ -376,18 +406,6 @@ HRESULT CDecoder::Decode(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
|
||||||
if (mtMode)
|
|
||||||
{
|
|
||||||
CMyComPtr<ICompressSetCoderMt> setCoderMt;
|
|
||||||
decoder->QueryInterface(IID_ICompressSetCoderMt, (void **)&setCoderMt);
|
|
||||||
if (setCoderMt)
|
|
||||||
{
|
|
||||||
RINOK(setCoderMt->SetNumberOfThreads(numThreads));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _NO_CRYPTO
|
#ifndef _NO_CRYPTO
|
||||||
{
|
{
|
||||||
CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
|
CMyComPtr<ICryptoSetPassword> cryptoSetPassword;
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ public:
|
|||||||
|
|
||||||
_7Z_DECODER_CRYPRO_VARS_DECL
|
_7Z_DECODER_CRYPRO_VARS_DECL
|
||||||
|
|
||||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
#if !defined(_7ZIP_ST)
|
||||||
, bool mtMode, UInt32 numThreads
|
, bool mtMode, UInt32 numThreads, UInt64 memUsage
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -154,9 +154,18 @@ HRESULT CEncoder::CreateMixerCoder(
|
|||||||
|
|
||||||
CCreatedCoder cod;
|
CCreatedCoder cod;
|
||||||
|
|
||||||
RINOK(CreateCoder(
|
if (methodFull.CodecIndex >= 0)
|
||||||
|
{
|
||||||
|
RINOK(CreateCoder_Index(
|
||||||
|
EXTERNAL_CODECS_LOC_VARS
|
||||||
|
methodFull.CodecIndex, true, cod));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RINOK(CreateCoder_Id(
|
||||||
EXTERNAL_CODECS_LOC_VARS
|
EXTERNAL_CODECS_LOC_VARS
|
||||||
methodFull.Id, true, cod));
|
methodFull.Id, true, cod));
|
||||||
|
}
|
||||||
|
|
||||||
if (cod.NumStreams != methodFull.NumStreams)
|
if (cod.NumStreams != methodFull.NumStreams)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
@@ -370,6 +379,17 @@ HRESULT CEncoder::Encode(
|
|||||||
resetInitVector->ResetInitVector();
|
resetInitVector->ResetInitVector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
CMyComPtr<ICompressSetCoderPropertiesOpt> optProps;
|
||||||
|
coder->QueryInterface(IID_ICompressSetCoderPropertiesOpt, (void **)&optProps);
|
||||||
|
if (optProps)
|
||||||
|
{
|
||||||
|
PROPID propID = NCoderPropID::kExpectedDataSize;
|
||||||
|
NWindows::NCOM::CPropVariant prop = (UInt64)unpackSize;
|
||||||
|
RINOK(optProps->SetCoderPropertiesOpt(&propID, &prop, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
|
CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
|
||||||
coder->QueryInterface(IID_ICompressWriteCoderProperties, (void **)&writeCoderProperties);
|
coder->QueryInterface(IID_ICompressWriteCoderProperties, (void **)&writeCoderProperties);
|
||||||
|
|
||||||
@@ -380,7 +400,7 @@ HRESULT CEncoder::Encode(
|
|||||||
CDynBufSeqOutStream *outStreamSpec = new CDynBufSeqOutStream;
|
CDynBufSeqOutStream *outStreamSpec = new CDynBufSeqOutStream;
|
||||||
CMyComPtr<ISequentialOutStream> dynOutStream(outStreamSpec);
|
CMyComPtr<ISequentialOutStream> dynOutStream(outStreamSpec);
|
||||||
outStreamSpec->Init();
|
outStreamSpec->Init();
|
||||||
writeCoderProperties->WriteCoderProperties(dynOutStream);
|
RINOK(writeCoderProperties->WriteCoderProperties(dynOutStream));
|
||||||
outStreamSpec->CopyToBuffer(props);
|
outStreamSpec->CopyToBuffer(props);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -152,6 +152,12 @@ STDMETHODIMP CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *proc
|
|||||||
if (_fileIsOpen)
|
if (_fileIsOpen)
|
||||||
{
|
{
|
||||||
UInt32 cur = (size < _rem ? size : (UInt32)_rem);
|
UInt32 cur = (size < _rem ? size : (UInt32)_rem);
|
||||||
|
if (_calcCrc)
|
||||||
|
{
|
||||||
|
const UInt32 k_Step = (UInt32)1 << 20;
|
||||||
|
if (cur > k_Step)
|
||||||
|
cur = k_Step;
|
||||||
|
}
|
||||||
HRESULT result = S_OK;
|
HRESULT result = S_OK;
|
||||||
if (_stream)
|
if (_stream)
|
||||||
result = _stream->Write(data, cur, &cur);
|
result = _stream->Write(data, cur, &cur);
|
||||||
@@ -363,8 +369,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
, dataAfterEnd_Error
|
, dataAfterEnd_Error
|
||||||
|
|
||||||
_7Z_DECODER_CRYPRO_VARS
|
_7Z_DECODER_CRYPRO_VARS
|
||||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
#if !defined(_7ZIP_ST)
|
||||||
, true, _numThreads
|
, true, _numThreads, _memUsage
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -80,14 +80,17 @@ STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSiz
|
|||||||
{
|
{
|
||||||
if (_stream)
|
if (_stream)
|
||||||
{
|
{
|
||||||
UInt32 processed2;
|
UInt32 cur = size;
|
||||||
RINOK(_stream->Read(data, size, &processed2));
|
const UInt32 kMax = (UInt32)1 << 20;
|
||||||
if (processed2 != 0)
|
if (cur > kMax)
|
||||||
|
cur = kMax;
|
||||||
|
RINOK(_stream->Read(data, cur, &cur));
|
||||||
|
if (cur != 0)
|
||||||
{
|
{
|
||||||
_crc = CrcUpdate(_crc, data, processed2);
|
_crc = CrcUpdate(_crc, data, cur);
|
||||||
_pos += processed2;
|
_pos += cur;
|
||||||
if (processedSize)
|
if (processedSize)
|
||||||
*processedSize = processed2;
|
*processedSize = cur;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ CHandler::CHandler()
|
|||||||
_crcSize = 4;
|
_crcSize = 4;
|
||||||
|
|
||||||
#ifdef __7Z_SET_PROPERTIES
|
#ifdef __7Z_SET_PROPERTIES
|
||||||
_numThreads = NSystem::GetNumberOfProcessors();
|
|
||||||
_useMultiThreadMixer = true;
|
_useMultiThreadMixer = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -237,6 +236,13 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
|||||||
prop = v;
|
prop = v;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case kpidReadOnly:
|
||||||
|
{
|
||||||
|
if (!_db.CanUpdate())
|
||||||
|
prop = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
prop.Detach(value);
|
prop.Detach(value);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
@@ -714,8 +720,8 @@ STDMETHODIMP CHandler::Close()
|
|||||||
STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
|
STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
|
||||||
{
|
{
|
||||||
COM_TRY_BEGIN
|
COM_TRY_BEGIN
|
||||||
const UInt32 numProcessors = NSystem::GetNumberOfProcessors();
|
|
||||||
_numThreads = numProcessors;
|
InitCommon();
|
||||||
_useMultiThreadMixer = true;
|
_useMultiThreadMixer = true;
|
||||||
|
|
||||||
for (UInt32 i = 0; i < numProps; i++)
|
for (UInt32 i = 0; i < numProps; i++)
|
||||||
@@ -734,13 +740,15 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
|||||||
RINOK(PROPVARIANT_to_bool(value, _useMultiThreadMixer));
|
RINOK(PROPVARIANT_to_bool(value, _useMultiThreadMixer));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
|
||||||
{
|
{
|
||||||
RINOK(ParseMtProp(name.Ptr(2), value, numProcessors, _numThreads));
|
HRESULT hres;
|
||||||
continue;
|
if (SetCommonProperty(name, value, hres))
|
||||||
|
{
|
||||||
|
RINOK(hres);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
return E_INVALIDARG;
|
||||||
return E_INVALIDARG;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|||||||
@@ -8,16 +8,6 @@
|
|||||||
|
|
||||||
#include "../../Common/CreateCoder.h"
|
#include "../../Common/CreateCoder.h"
|
||||||
|
|
||||||
#ifndef EXTRACT_ONLY
|
|
||||||
#include "../Common/HandlerOut.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "7zCompressionMode.h"
|
|
||||||
#include "7zIn.h"
|
|
||||||
|
|
||||||
namespace NArchive {
|
|
||||||
namespace N7z {
|
|
||||||
|
|
||||||
#ifndef __7Z_SET_PROPERTIES
|
#ifndef __7Z_SET_PROPERTIES
|
||||||
|
|
||||||
#ifdef EXTRACT_ONLY
|
#ifdef EXTRACT_ONLY
|
||||||
@@ -30,6 +20,16 @@ namespace N7z {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// #ifdef __7Z_SET_PROPERTIES
|
||||||
|
#include "../Common/HandlerOut.h"
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
#include "7zCompressionMode.h"
|
||||||
|
#include "7zIn.h"
|
||||||
|
|
||||||
|
namespace NArchive {
|
||||||
|
namespace N7z {
|
||||||
|
|
||||||
|
|
||||||
#ifndef EXTRACT_ONLY
|
#ifndef EXTRACT_ONLY
|
||||||
|
|
||||||
@@ -38,8 +38,6 @@ class COutHandler: public CMultiMethodProps
|
|||||||
HRESULT SetSolidFromString(const UString &s);
|
HRESULT SetSolidFromString(const UString &s);
|
||||||
HRESULT SetSolidFromPROPVARIANT(const PROPVARIANT &value);
|
HRESULT SetSolidFromPROPVARIANT(const PROPVARIANT &value);
|
||||||
public:
|
public:
|
||||||
bool _removeSfxBlock;
|
|
||||||
|
|
||||||
UInt64 _numSolidFiles;
|
UInt64 _numSolidFiles;
|
||||||
UInt64 _numSolidBytes;
|
UInt64 _numSolidBytes;
|
||||||
bool _numSolidBytesDefined;
|
bool _numSolidBytesDefined;
|
||||||
@@ -58,6 +56,8 @@ public:
|
|||||||
|
|
||||||
bool _useMultiThreadMixer;
|
bool _useMultiThreadMixer;
|
||||||
|
|
||||||
|
bool _removeSfxBlock;
|
||||||
|
|
||||||
// bool _volumeMode;
|
// bool _volumeMode;
|
||||||
|
|
||||||
void InitSolidFiles() { _numSolidFiles = (UInt64)(Int64)(-1); }
|
void InitSolidFiles() { _numSolidFiles = (UInt64)(Int64)(-1); }
|
||||||
@@ -70,9 +70,10 @@ public:
|
|||||||
_numSolidBytesDefined = false;
|
_numSolidBytesDefined = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitProps7z();
|
||||||
void InitProps();
|
void InitProps();
|
||||||
|
|
||||||
COutHandler() { InitProps(); }
|
COutHandler() { InitProps7z(); }
|
||||||
|
|
||||||
HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
|
HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
|
||||||
};
|
};
|
||||||
@@ -82,16 +83,23 @@ public:
|
|||||||
class CHandler:
|
class CHandler:
|
||||||
public IInArchive,
|
public IInArchive,
|
||||||
public IArchiveGetRawProps,
|
public IArchiveGetRawProps,
|
||||||
|
|
||||||
#ifdef __7Z_SET_PROPERTIES
|
#ifdef __7Z_SET_PROPERTIES
|
||||||
public ISetProperties,
|
public ISetProperties,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef EXTRACT_ONLY
|
#ifndef EXTRACT_ONLY
|
||||||
public IOutArchive,
|
public IOutArchive,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PUBLIC_ISetCompressCodecsInfo
|
PUBLIC_ISetCompressCodecsInfo
|
||||||
public CMyUnknownImp
|
|
||||||
|
public CMyUnknownImp,
|
||||||
|
|
||||||
#ifndef EXTRACT_ONLY
|
#ifndef EXTRACT_ONLY
|
||||||
, public COutHandler
|
public COutHandler
|
||||||
|
#else
|
||||||
|
public CCommonMethodProps
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -135,7 +143,6 @@ private:
|
|||||||
#ifdef EXTRACT_ONLY
|
#ifdef EXTRACT_ONLY
|
||||||
|
|
||||||
#ifdef __7Z_SET_PROPERTIES
|
#ifdef __7Z_SET_PROPERTIES
|
||||||
UInt32 _numThreads;
|
|
||||||
bool _useMultiThreadMixer;
|
bool _useMultiThreadMixer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include "7zOut.h"
|
#include "7zOut.h"
|
||||||
#include "7zUpdate.h"
|
#include "7zUpdate.h"
|
||||||
|
|
||||||
|
#ifndef EXTRACT_ONLY
|
||||||
|
|
||||||
using namespace NWindows;
|
using namespace NWindows;
|
||||||
|
|
||||||
namespace NArchive {
|
namespace NArchive {
|
||||||
@@ -41,9 +43,11 @@ STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
|
|||||||
|
|
||||||
HRESULT CHandler::PropsMethod_To_FullMethod(CMethodFull &dest, const COneMethodInfo &m)
|
HRESULT CHandler::PropsMethod_To_FullMethod(CMethodFull &dest, const COneMethodInfo &m)
|
||||||
{
|
{
|
||||||
if (!FindMethod(
|
dest.CodecIndex = FindMethod_Index(
|
||||||
EXTERNAL_CODECS_VARS
|
EXTERNAL_CODECS_VARS
|
||||||
m.MethodName, dest.Id, dest.NumStreams))
|
m.MethodName, true,
|
||||||
|
dest.Id, dest.NumStreams);
|
||||||
|
if (dest.CodecIndex < 0)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
(CProps &)dest = (CProps &)m;
|
(CProps &)dest = (CProps &)m;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
@@ -263,6 +267,9 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
|||||||
db = &_db;
|
db = &_db;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (db && !db->CanUpdate())
|
||||||
|
return E_NOTIMPL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CMyComPtr<IArchiveGetRawProps> getRawProps;
|
CMyComPtr<IArchiveGetRawProps> getRawProps;
|
||||||
updateCallback->QueryInterface(IID_IArchiveGetRawProps, (void **)&getRawProps);
|
updateCallback->QueryInterface(IID_IArchiveGetRawProps, (void **)&getRawProps);
|
||||||
@@ -699,10 +706,8 @@ static HRESULT ParseBond(UString &srcString, UInt32 &coder, UInt32 &stream)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void COutHandler::InitProps()
|
void COutHandler::InitProps7z()
|
||||||
{
|
{
|
||||||
CMultiMethodProps::Init();
|
|
||||||
|
|
||||||
_removeSfxBlock = false;
|
_removeSfxBlock = false;
|
||||||
_compressHeaders = true;
|
_compressHeaders = true;
|
||||||
_encryptHeadersSpecified = false;
|
_encryptHeadersSpecified = false;
|
||||||
@@ -722,6 +727,14 @@ void COutHandler::InitProps()
|
|||||||
_useTypeSorting = false;
|
_useTypeSorting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void COutHandler::InitProps()
|
||||||
|
{
|
||||||
|
CMultiMethodProps::Init();
|
||||||
|
InitProps7z();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT COutHandler::SetSolidFromString(const UString &s)
|
HRESULT COutHandler::SetSolidFromString(const UString &s)
|
||||||
{
|
{
|
||||||
UString s2 = s;
|
UString s2 = s;
|
||||||
@@ -762,6 +775,10 @@ HRESULT COutHandler::SetSolidFromString(const UString &s)
|
|||||||
}
|
}
|
||||||
_numSolidBytes = (v << numBits);
|
_numSolidBytes = (v << numBits);
|
||||||
_numSolidBytesDefined = true;
|
_numSolidBytesDefined = true;
|
||||||
|
/*
|
||||||
|
if (_numSolidBytes == 0)
|
||||||
|
_numSolidFiles = 1;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
@@ -921,3 +938,5 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVAR
|
|||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -1115,11 +1115,11 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
|
|||||||
, dataAfterEnd_Error
|
, dataAfterEnd_Error
|
||||||
|
|
||||||
_7Z_DECODER_CRYPRO_VARS
|
_7Z_DECODER_CRYPRO_VARS
|
||||||
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
#if !defined(_7ZIP_ST)
|
||||||
, false // mtMode
|
, false // mtMode
|
||||||
, 1 // numThreads
|
, 1 // numThreads
|
||||||
|
, 0 // memUsage
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
RINOK(result);
|
RINOK(result);
|
||||||
@@ -1465,21 +1465,24 @@ void CDbEx::FillLinks()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (indexInFolder != 0)
|
if (indexInFolder != 0)
|
||||||
|
{
|
||||||
folderIndex++;
|
folderIndex++;
|
||||||
/*
|
// 18.06
|
||||||
if (indexInFolder != 0)
|
ThereIsHeaderError = true;
|
||||||
ThrowIncorrect();
|
// ThrowIncorrect();
|
||||||
*/
|
}
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (folderIndex >= NumFolders)
|
if (folderIndex >= NumFolders)
|
||||||
return;
|
return;
|
||||||
FolderStartFileIndex[folderIndex] = i;
|
FolderStartFileIndex[folderIndex] = i;
|
||||||
/*
|
|
||||||
if (NumUnpackStreamsVector[folderIndex] != 0)
|
if (NumUnpackStreamsVector[folderIndex] != 0)
|
||||||
ThrowIncorrect();;
|
{
|
||||||
*/
|
// 18.06
|
||||||
|
ThereIsHeaderError = true;
|
||||||
|
// ThrowIncorrect();
|
||||||
|
}
|
||||||
folderIndex++;
|
folderIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,6 +257,16 @@ struct CDbEx: public CDatabase
|
|||||||
PhySize = 0;
|
PhySize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CanUpdate() const
|
||||||
|
{
|
||||||
|
if (ThereIsHeaderError
|
||||||
|
|| UnexpectedEnd
|
||||||
|
|| StartHeaderWasRecovered
|
||||||
|
|| UnsupportedFeatureError)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void FillLinks();
|
void FillLinks();
|
||||||
|
|
||||||
UInt64 GetFolderStreamPos(CNum folderIndex, unsigned indexInFolder) const
|
UInt64 GetFolderStreamPos(CNum folderIndex, unsigned indexInFolder) const
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ HRESULT COutArchive::EncodeStream(
|
|||||||
outFolders.FolderUnpackCRCs.Vals.Add(CrcCalc(data, data.Size()));
|
outFolders.FolderUnpackCRCs.Vals.Add(CrcCalc(data, data.Size()));
|
||||||
// outFolders.NumUnpackStreamsVector.Add(1);
|
// outFolders.NumUnpackStreamsVector.Add(1);
|
||||||
UInt64 dataSize64 = data.Size();
|
UInt64 dataSize64 = data.Size();
|
||||||
UInt64 unpackSize;
|
UInt64 unpackSize = data.Size();
|
||||||
RINOK(encoder.Encode(
|
RINOK(encoder.Encode(
|
||||||
EXTERNAL_CODECS_LOC_VARS
|
EXTERNAL_CODECS_LOC_VARS
|
||||||
stream,
|
stream,
|
||||||
|
|||||||
@@ -124,13 +124,13 @@ static int Parse_EXE(const Byte *buf, size_t size, CFilterMode *filterMode)
|
|||||||
#define ELF_DATA_2LSB 1
|
#define ELF_DATA_2LSB 1
|
||||||
#define ELF_DATA_2MSB 2
|
#define ELF_DATA_2MSB 2
|
||||||
|
|
||||||
static UInt16 Get16(const Byte *p, Bool be) { if (be) return (UInt16)GetBe16(p); return (UInt16)GetUi16(p); }
|
static UInt16 Get16(const Byte *p, BoolInt be) { if (be) return (UInt16)GetBe16(p); return (UInt16)GetUi16(p); }
|
||||||
static UInt32 Get32(const Byte *p, Bool be) { if (be) return GetBe32(p); return GetUi32(p); }
|
static UInt32 Get32(const Byte *p, BoolInt be) { if (be) return GetBe32(p); return GetUi32(p); }
|
||||||
// static UInt64 Get64(const Byte *p, Bool be) { if (be) return GetBe64(p); return GetUi64(p); }
|
// static UInt64 Get64(const Byte *p, BoolInt be) { if (be) return GetBe64(p); return GetUi64(p); }
|
||||||
|
|
||||||
static int Parse_ELF(const Byte *buf, size_t size, CFilterMode *filterMode)
|
static int Parse_ELF(const Byte *buf, size_t size, CFilterMode *filterMode)
|
||||||
{
|
{
|
||||||
Bool /* is32, */ be;
|
BoolInt /* is32, */ be;
|
||||||
UInt32 filterId;
|
UInt32 filterId;
|
||||||
|
|
||||||
if (size < 512 || buf[6] != 1) /* ver */
|
if (size < 512 || buf[6] != 1) /* ver */
|
||||||
@@ -200,7 +200,7 @@ static unsigned Parse_MACH(const Byte *buf, size_t size, CFilterMode *filterMode
|
|||||||
if (size < 512)
|
if (size < 512)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Bool /* mode64, */ be;
|
BoolInt /* mode64, */ be;
|
||||||
switch (GetUi32(buf))
|
switch (GetUi32(buf))
|
||||||
{
|
{
|
||||||
case MACH_SIG_BE_32: /* mode64 = False; */ be = True; break;
|
case MACH_SIG_BE_32: /* mode64 = False; */ be = True; break;
|
||||||
@@ -239,7 +239,7 @@ static unsigned Parse_MACH(const Byte *buf, size_t size, CFilterMode *filterMode
|
|||||||
|
|
||||||
#define RIFF_SIG 0x46464952
|
#define RIFF_SIG 0x46464952
|
||||||
|
|
||||||
static Bool Parse_WAV(const Byte *buf, size_t size, CFilterMode *filterMode)
|
static BoolInt Parse_WAV(const Byte *buf, size_t size, CFilterMode *filterMode)
|
||||||
{
|
{
|
||||||
UInt32 subChunkSize, pos;
|
UInt32 subChunkSize, pos;
|
||||||
if (size < 0x2C)
|
if (size < 0x2C)
|
||||||
@@ -285,7 +285,7 @@ static Bool Parse_WAV(const Byte *buf, size_t size, CFilterMode *filterMode)
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool ParseFile(const Byte *buf, size_t size, CFilterMode *filterMode)
|
static BoolInt ParseFile(const Byte *buf, size_t size, CFilterMode *filterMode)
|
||||||
{
|
{
|
||||||
filterMode->Id = 0;
|
filterMode->Id = 0;
|
||||||
filterMode->Delta = 0;
|
filterMode->Delta = 0;
|
||||||
@@ -894,7 +894,7 @@ HRESULT CAnalysis::GetFilterGroup(UInt32 index, const CUpdateItem &ui, CFilterMo
|
|||||||
// RINOK(Callback->SetOperationResult2(index, NUpdate::NOperationResult::kOK));
|
// RINOK(Callback->SetOperationResult2(index, NUpdate::NOperationResult::kOK));
|
||||||
if (result == S_OK)
|
if (result == S_OK)
|
||||||
{
|
{
|
||||||
Bool parseRes = ParseFile(Buffer, size, &filterModeTemp);
|
BoolInt parseRes = ParseFile(Buffer, size, &filterModeTemp);
|
||||||
if (parseRes && filterModeTemp.Delta == 0)
|
if (parseRes && filterModeTemp.Delta == 0)
|
||||||
{
|
{
|
||||||
filterModeTemp.SetDelta();
|
filterModeTemp.SetDelta();
|
||||||
@@ -1507,7 +1507,8 @@ void CThreadDecoder::Execute()
|
|||||||
|
|
||||||
_7Z_DECODER_CRYPRO_VARS
|
_7Z_DECODER_CRYPRO_VARS
|
||||||
#ifndef _7ZIP_ST
|
#ifndef _7ZIP_ST
|
||||||
, MtMode, NumThreads
|
, MtMode, NumThreads,
|
||||||
|
0 // MemUsage
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
);
|
);
|
||||||
@@ -1647,6 +1648,9 @@ HRESULT Update(
|
|||||||
|
|
||||||
for (CNum fi = db->FolderStartFileIndex[i]; indexInFolder < numUnpackStreams; fi++)
|
for (CNum fi = db->FolderStartFileIndex[i]; indexInFolder < numUnpackStreams; fi++)
|
||||||
{
|
{
|
||||||
|
if (fi >= db->Files.Size())
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
const CFileItem &file = db->Files[fi];
|
const CFileItem &file = db->Files[fi];
|
||||||
if (file.HasStream)
|
if (file.HasStream)
|
||||||
{
|
{
|
||||||
@@ -1696,13 +1700,14 @@ HRESULT Update(
|
|||||||
|
|
||||||
UInt64 inSizeForReduce = 0;
|
UInt64 inSizeForReduce = 0;
|
||||||
{
|
{
|
||||||
|
bool isSolid = (numSolidFiles > 1 && options.NumSolidBytes != 0);
|
||||||
FOR_VECTOR (i, updateItems)
|
FOR_VECTOR (i, updateItems)
|
||||||
{
|
{
|
||||||
const CUpdateItem &ui = updateItems[i];
|
const CUpdateItem &ui = updateItems[i];
|
||||||
if (ui.NewData)
|
if (ui.NewData)
|
||||||
{
|
{
|
||||||
complexity += ui.Size;
|
complexity += ui.Size;
|
||||||
if (numSolidFiles != 1)
|
if (isSolid)
|
||||||
inSizeForReduce += ui.Size;
|
inSizeForReduce += ui.Size;
|
||||||
else if (inSizeForReduce < ui.Size)
|
else if (inSizeForReduce < ui.Size)
|
||||||
inSizeForReduce = ui.Size;
|
inSizeForReduce = ui.Size;
|
||||||
@@ -2142,8 +2147,8 @@ HRESULT Update(
|
|||||||
#ifndef _7ZIP_ST
|
#ifndef _7ZIP_ST
|
||||||
, false // mtMode
|
, false // mtMode
|
||||||
, 1 // numThreads
|
, 1 // numThreads
|
||||||
|
, 0 // memUsage
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
RINOK(res);
|
RINOK(res);
|
||||||
@@ -2171,6 +2176,7 @@ HRESULT Update(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curUnpackSize = sizeToEncode;
|
||||||
|
|
||||||
HRESULT encodeRes = encoder.Encode(
|
HRESULT encodeRes = encoder.Encode(
|
||||||
EXTERNAL_CODECS_LOC_VARS
|
EXTERNAL_CODECS_LOC_VARS
|
||||||
@@ -2292,7 +2298,8 @@ HRESULT Update(
|
|||||||
continue;
|
continue;
|
||||||
CRecordVector<CRefItem> refItems;
|
CRecordVector<CRefItem> refItems;
|
||||||
refItems.ClearAndSetSize(numFiles);
|
refItems.ClearAndSetSize(numFiles);
|
||||||
bool sortByType = (options.UseTypeSorting && numSolidFiles > 1);
|
// bool sortByType = (options.UseTypeSorting && isSoid); // numSolidFiles > 1
|
||||||
|
bool sortByType = options.UseTypeSorting;
|
||||||
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
@@ -2358,7 +2365,9 @@ HRESULT Update(
|
|||||||
inStreamSpec->Init(updateCallback, &indices[i], numSubFiles);
|
inStreamSpec->Init(updateCallback, &indices[i], numSubFiles);
|
||||||
|
|
||||||
unsigned startPackIndex = newDatabase.PackSizes.Size();
|
unsigned startPackIndex = newDatabase.PackSizes.Size();
|
||||||
UInt64 curFolderUnpackSize;
|
UInt64 curFolderUnpackSize = totalSize;
|
||||||
|
// curFolderUnpackSize = (UInt64)(Int64)-1;
|
||||||
|
|
||||||
RINOK(encoder.Encode(
|
RINOK(encoder.Encode(
|
||||||
EXTERNAL_CODECS_LOC_VARS
|
EXTERNAL_CODECS_LOC_VARS
|
||||||
solidInStream,
|
solidInStream,
|
||||||
|
|||||||
@@ -170,8 +170,8 @@ static bool OctalToNumber32(const char *s, unsigned size, UInt32 &res)
|
|||||||
res = 0;
|
res = 0;
|
||||||
char sz[32];
|
char sz[32];
|
||||||
size = RemoveTailSpaces(sz, s, size);
|
size = RemoveTailSpaces(sz, s, size);
|
||||||
if (size == 0)
|
if (size == 0 || strcmp(sz, "-1") == 0)
|
||||||
return true; // some items doesn't contaion any numbers
|
return true; // some items don't contain any numbers
|
||||||
const char *end;
|
const char *end;
|
||||||
UInt64 res64 = ConvertOctStringToUInt64(sz, &end);
|
UInt64 res64 = ConvertOctStringToUInt64(sz, &end);
|
||||||
if ((unsigned)(end - sz) != size)
|
if ((unsigned)(end - sz) != size)
|
||||||
@@ -185,8 +185,8 @@ static bool DecimalToNumber(const char *s, unsigned size, UInt64 &res)
|
|||||||
res = 0;
|
res = 0;
|
||||||
char sz[32];
|
char sz[32];
|
||||||
size = RemoveTailSpaces(sz, s, size);
|
size = RemoveTailSpaces(sz, s, size);
|
||||||
if (size == 0)
|
if (size == 0 || strcmp(sz, "-1") == 0)
|
||||||
return true; // some items doesn't contaion any numbers
|
return true; // some items don't contain any numbers
|
||||||
const char *end;
|
const char *end;
|
||||||
res = ConvertStringToUInt64(sz, &end);
|
res = ConvertStringToUInt64(sz, &end);
|
||||||
return ((unsigned)(end - sz) == size);
|
return ((unsigned)(end - sz) == size);
|
||||||
|
|||||||
@@ -366,7 +366,13 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
size = prop.uhVal.QuadPart;
|
size = prop.uhVal.QuadPart;
|
||||||
}
|
}
|
||||||
return UpdateArchive(size, outStream, _props, updateCallback);
|
|
||||||
|
CMethodProps props2 = _props;
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
props2.AddProp_NumThreads(_props._numThreads);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return UpdateArchive(size, outStream, props2, updateCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexInArchive != 0)
|
if (indexInArchive != 0)
|
||||||
|
|||||||
@@ -549,9 +549,9 @@ private:
|
|||||||
|
|
||||||
Byte *TempBuf;
|
Byte *TempBuf;
|
||||||
UInt32 TempBufSize;
|
UInt32 TempBufSize;
|
||||||
|
UInt32 TempBufWritten;
|
||||||
unsigned NumIdenticalFiles;
|
unsigned NumIdenticalFiles;
|
||||||
bool TempBufMode;
|
bool TempBufMode;
|
||||||
UInt32 m_BufStartFolderOffset;
|
|
||||||
|
|
||||||
unsigned m_StartIndex;
|
unsigned m_StartIndex;
|
||||||
unsigned m_CurrentIndex;
|
unsigned m_CurrentIndex;
|
||||||
@@ -575,7 +575,6 @@ private:
|
|||||||
HRESULT OpenFile();
|
HRESULT OpenFile();
|
||||||
HRESULT CloseFileWithResOp(Int32 resOp);
|
HRESULT CloseFileWithResOp(Int32 resOp);
|
||||||
HRESULT CloseFile();
|
HRESULT CloseFile();
|
||||||
HRESULT Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK);
|
|
||||||
public:
|
public:
|
||||||
HRESULT WriteEmptyFiles();
|
HRESULT WriteEmptyFiles();
|
||||||
|
|
||||||
@@ -672,11 +671,11 @@ HRESULT CFolderOutStream::OpenFile()
|
|||||||
FreeTempBuf();
|
FreeTempBuf();
|
||||||
TempBuf = (Byte *)MyAlloc(item.Size);
|
TempBuf = (Byte *)MyAlloc(item.Size);
|
||||||
TempBufSize = item.Size;
|
TempBufSize = item.Size;
|
||||||
if (TempBuf == NULL)
|
if (!TempBuf)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
TempBufMode = true;
|
TempBufMode = true;
|
||||||
m_BufStartFolderOffset = item.Offset;
|
TempBufWritten = 0;
|
||||||
}
|
}
|
||||||
else if (numExtractItems == 1)
|
else if (numExtractItems == 1)
|
||||||
{
|
{
|
||||||
@@ -725,8 +724,9 @@ HRESULT CFolderOutStream::WriteEmptyFiles()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT CFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK)
|
HRESULT CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||||
{
|
{
|
||||||
|
// (data == NULL) means Error_Data for solid folder flushing
|
||||||
COM_TRY_BEGIN
|
COM_TRY_BEGIN
|
||||||
|
|
||||||
UInt32 realProcessed = 0;
|
UInt32 realProcessed = 0;
|
||||||
@@ -741,21 +741,34 @@ HRESULT CFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processe
|
|||||||
HRESULT res = S_OK;
|
HRESULT res = S_OK;
|
||||||
if (numBytesToWrite != 0)
|
if (numBytesToWrite != 0)
|
||||||
{
|
{
|
||||||
if (!isOK)
|
if (!data)
|
||||||
m_IsOk = false;
|
m_IsOk = false;
|
||||||
|
|
||||||
if (m_RealOutStream)
|
if (m_RealOutStream)
|
||||||
{
|
{
|
||||||
UInt32 processedSizeLocal = 0;
|
UInt32 processedSizeLocal = 0;
|
||||||
res = m_RealOutStream->Write((const Byte *)data, numBytesToWrite, &processedSizeLocal);
|
// 18.01 : we don't want ZEROs instead of missing data
|
||||||
|
if (data)
|
||||||
|
res = m_RealOutStream->Write((const Byte *)data, numBytesToWrite, &processedSizeLocal);
|
||||||
|
else
|
||||||
|
processedSizeLocal = numBytesToWrite;
|
||||||
numBytesToWrite = processedSizeLocal;
|
numBytesToWrite = processedSizeLocal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TempBufMode && TempBuf)
|
if (TempBufMode && TempBuf)
|
||||||
memcpy(TempBuf + (m_PosInFolder - m_BufStartFolderOffset), data, numBytesToWrite);
|
{
|
||||||
|
if (data)
|
||||||
|
{
|
||||||
|
memcpy(TempBuf + TempBufWritten, data, numBytesToWrite);
|
||||||
|
TempBufWritten += numBytesToWrite;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
realProcessed += numBytesToWrite;
|
realProcessed += numBytesToWrite;
|
||||||
if (processedSize)
|
if (processedSize)
|
||||||
*processedSize = realProcessed;
|
*processedSize = realProcessed;
|
||||||
data = (const void *)((const Byte *)data + numBytesToWrite);
|
if (data)
|
||||||
|
data = (const void *)((const Byte *)data + numBytesToWrite);
|
||||||
size -= numBytesToWrite;
|
size -= numBytesToWrite;
|
||||||
m_RemainFileSize -= numBytesToWrite;
|
m_RemainFileSize -= numBytesToWrite;
|
||||||
m_PosInFolder += numBytesToWrite;
|
m_PosInFolder += numBytesToWrite;
|
||||||
@@ -773,7 +786,7 @@ HRESULT CFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processe
|
|||||||
m_FileIsOpen = true;
|
m_FileIsOpen = true;
|
||||||
m_CurrentIndex++;
|
m_CurrentIndex++;
|
||||||
if (result == S_OK && m_RealOutStream && TempBuf)
|
if (result == S_OK && m_RealOutStream && TempBuf)
|
||||||
result = WriteStream(m_RealOutStream, TempBuf, (size_t)(m_PosInFolder - m_BufStartFolderOffset));
|
result = WriteStream(m_RealOutStream, TempBuf, TempBufWritten);
|
||||||
|
|
||||||
if (!TempBuf && TempBufMode && m_RealOutStream)
|
if (!TempBuf && TempBufMode && m_RealOutStream)
|
||||||
{
|
{
|
||||||
@@ -822,7 +835,8 @@ HRESULT CFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processe
|
|||||||
realProcessed += numBytesToWrite;
|
realProcessed += numBytesToWrite;
|
||||||
if (processedSize)
|
if (processedSize)
|
||||||
*processedSize = realProcessed;
|
*processedSize = realProcessed;
|
||||||
data = (const void *)((const Byte *)data + numBytesToWrite);
|
if (data)
|
||||||
|
data = (const void *)((const Byte *)data + numBytesToWrite);
|
||||||
size -= numBytesToWrite;
|
size -= numBytesToWrite;
|
||||||
m_PosInFolder += numBytesToWrite;
|
m_PosInFolder += numBytesToWrite;
|
||||||
}
|
}
|
||||||
@@ -843,12 +857,6 @@ HRESULT CFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
|
||||||
{
|
|
||||||
return Write2(data, size, processedSize, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT CFolderOutStream::FlushCorrupted(unsigned folderIndex)
|
HRESULT CFolderOutStream::FlushCorrupted(unsigned folderIndex)
|
||||||
{
|
{
|
||||||
if (!NeedMoreWrite())
|
if (!NeedMoreWrite())
|
||||||
@@ -862,19 +870,16 @@ HRESULT CFolderOutStream::FlushCorrupted(unsigned folderIndex)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned kBufSize = (1 << 12);
|
|
||||||
Byte buf[kBufSize];
|
|
||||||
for (unsigned i = 0; i < kBufSize; i++)
|
|
||||||
buf[i] = 0;
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (!NeedMoreWrite())
|
if (!NeedMoreWrite())
|
||||||
return S_OK;
|
return S_OK;
|
||||||
UInt64 remain = GetRemain();
|
UInt64 remain = GetRemain();
|
||||||
UInt32 size = (remain < kBufSize ? (UInt32)remain : (UInt32)kBufSize);
|
UInt32 size = (UInt32)1 << 20;
|
||||||
|
if (size > remain)
|
||||||
|
size = (UInt32)remain;
|
||||||
UInt32 processedSizeLocal = 0;
|
UInt32 processedSizeLocal = 0;
|
||||||
RINOK(Write2(buf, size, &processedSizeLocal, false));
|
RINOK(Write(NULL, size, &processedSizeLocal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ HRESULT CCoder::CheckDataAfterEnd(bool &dataAfterEnd_Error /* , bool &InternalPa
|
|||||||
{
|
{
|
||||||
CMyComPtr<ICompressGetInStreamProcessedSize2> getInStreamProcessedSize2;
|
CMyComPtr<ICompressGetInStreamProcessedSize2> getInStreamProcessedSize2;
|
||||||
Coder2.QueryInterface(IID_ICompressGetInStreamProcessedSize2, (void **)&getInStreamProcessedSize2);
|
Coder2.QueryInterface(IID_ICompressGetInStreamProcessedSize2, (void **)&getInStreamProcessedSize2);
|
||||||
|
if (getInStreamProcessedSize2)
|
||||||
FOR_VECTOR (i, PackSizePointers)
|
FOR_VECTOR (i, PackSizePointers)
|
||||||
{
|
{
|
||||||
if (!PackSizePointers[i])
|
if (!PackSizePointers[i])
|
||||||
|
|||||||
@@ -2,18 +2,92 @@
|
|||||||
|
|
||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
|
|
||||||
#ifndef _7ZIP_ST
|
#include "../../../Common/StringToInt.h"
|
||||||
#include "../../../Windows/System.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../Common/ParseProperties.h"
|
#include "../Common/ParseProperties.h"
|
||||||
|
|
||||||
#include "HandlerOut.h"
|
#include "HandlerOut.h"
|
||||||
|
|
||||||
using namespace NWindows;
|
|
||||||
|
|
||||||
namespace NArchive {
|
namespace NArchive {
|
||||||
|
|
||||||
|
bool ParseSizeString(const wchar_t *s, const PROPVARIANT &prop, UInt64 percentsBase, UInt64 &res)
|
||||||
|
{
|
||||||
|
if (*s == 0)
|
||||||
|
{
|
||||||
|
switch (prop.vt)
|
||||||
|
{
|
||||||
|
case VT_UI4: res = prop.ulVal; return true;
|
||||||
|
case VT_UI8: res = prop.uhVal.QuadPart; return true;
|
||||||
|
case VT_BSTR:
|
||||||
|
s = prop.bstrVal;
|
||||||
|
break;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (prop.vt != VT_EMPTY)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const wchar_t *end;
|
||||||
|
UInt64 v = ConvertStringToUInt64(s, &end);
|
||||||
|
if (s == end)
|
||||||
|
return false;
|
||||||
|
wchar_t c = *end;
|
||||||
|
if (c == 0)
|
||||||
|
{
|
||||||
|
res = v;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (end[1] != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (c == '%')
|
||||||
|
{
|
||||||
|
res = percentsBase / 100 * v;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned numBits;
|
||||||
|
switch (MyCharLower_Ascii(c))
|
||||||
|
{
|
||||||
|
case 'b': numBits = 0; break;
|
||||||
|
case 'k': numBits = 10; break;
|
||||||
|
case 'm': numBits = 20; break;
|
||||||
|
case 'g': numBits = 30; break;
|
||||||
|
case 't': numBits = 40; break;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
UInt64 val2 = v << numBits;
|
||||||
|
if ((val2 >> numBits) != v)
|
||||||
|
return false;
|
||||||
|
res = val2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CCommonMethodProps::SetCommonProperty(const UString &name, const PROPVARIANT &value, HRESULT &hres)
|
||||||
|
{
|
||||||
|
hres = S_OK;
|
||||||
|
|
||||||
|
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
||||||
|
{
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
hres = ParseMtProp(name.Ptr(2), value, _numProcessors, _numThreads);
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.IsPrefixedBy_Ascii_NoCase("memuse"))
|
||||||
|
{
|
||||||
|
if (!ParseSizeString(name.Ptr(6), value, _memAvail, _memUsage))
|
||||||
|
hres = E_INVALIDARG;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef EXTRACT_ONLY
|
||||||
|
|
||||||
static void SetMethodProp32(COneMethodInfo &m, PROPID propID, UInt32 value)
|
static void SetMethodProp32(COneMethodInfo &m, PROPID propID, UInt32 value)
|
||||||
{
|
{
|
||||||
if (m.FindProp(propID) < 0)
|
if (m.FindProp(propID) < 0)
|
||||||
@@ -34,21 +108,23 @@ void CMultiMethodProps::SetMethodThreadsTo(COneMethodInfo &oneMethodInfo, UInt32
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void CMultiMethodProps::Init()
|
void CMultiMethodProps::InitMulti()
|
||||||
{
|
{
|
||||||
#ifndef _7ZIP_ST
|
|
||||||
_numProcessors = _numThreads = NSystem::GetNumberOfProcessors();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_level = (UInt32)(Int32)-1;
|
_level = (UInt32)(Int32)-1;
|
||||||
_analysisLevel = -1;
|
_analysisLevel = -1;
|
||||||
|
|
||||||
_autoFilter = true;
|
|
||||||
_crcSize = 4;
|
_crcSize = 4;
|
||||||
_filterMethod.Clear();
|
_autoFilter = true;
|
||||||
_methods.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMultiMethodProps::Init()
|
||||||
|
{
|
||||||
|
InitCommon();
|
||||||
|
InitMulti();
|
||||||
|
_methods.Clear();
|
||||||
|
_filterMethod.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value)
|
HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value)
|
||||||
{
|
{
|
||||||
UString name = nameSpec;
|
UString name = nameSpec;
|
||||||
@@ -79,19 +155,17 @@ HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIAN
|
|||||||
return ParsePropToUInt32(name, value, _crcSize);
|
return ParsePropToUInt32(name, value, _crcSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
HRESULT hres;
|
||||||
|
if (SetCommonProperty(name, value, hres))
|
||||||
|
return hres;
|
||||||
|
}
|
||||||
|
|
||||||
UInt32 number;
|
UInt32 number;
|
||||||
unsigned index = ParseStringToUInt32(name, number);
|
unsigned index = ParseStringToUInt32(name, number);
|
||||||
UString realName = name.Ptr(index);
|
UString realName = name.Ptr(index);
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
{
|
{
|
||||||
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
|
||||||
{
|
|
||||||
#ifndef _7ZIP_ST
|
|
||||||
RINOK(ParseMtProp(name.Ptr(2), value, _numProcessors, _numThreads));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
if (name.IsEqualTo("f"))
|
if (name.IsEqualTo("f"))
|
||||||
{
|
{
|
||||||
HRESULT res = PROPVARIANT_to_bool(value, _autoFilter);
|
HRESULT res = PROPVARIANT_to_bool(value, _autoFilter);
|
||||||
@@ -110,20 +184,20 @@ HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIAN
|
|||||||
return _methods[number].ParseMethodFromPROPVARIANT(realName, value);
|
return _methods[number].ParseMethodFromPROPVARIANT(realName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CSingleMethodProps::Init()
|
void CSingleMethodProps::Init()
|
||||||
{
|
{
|
||||||
|
InitCommon();
|
||||||
|
InitSingle();
|
||||||
Clear();
|
Clear();
|
||||||
_level = (UInt32)(Int32)-1;
|
|
||||||
|
|
||||||
#ifndef _7ZIP_ST
|
|
||||||
_numProcessors = _numThreads = NWindows::NSystem::GetNumberOfProcessors();
|
|
||||||
AddProp_NumThreads(_numThreads);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
|
HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
for (UInt32 i = 0; i < numProps; i++)
|
for (UInt32 i = 0; i < numProps; i++)
|
||||||
{
|
{
|
||||||
UString name = names[i];
|
UString name = names[i];
|
||||||
@@ -137,20 +211,22 @@ HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PR
|
|||||||
RINOK(ParsePropToUInt32(name.Ptr(1), value, a));
|
RINOK(ParsePropToUInt32(name.Ptr(1), value, a));
|
||||||
_level = a;
|
_level = a;
|
||||||
AddProp_Level(a);
|
AddProp_Level(a);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
|
||||||
{
|
{
|
||||||
#ifndef _7ZIP_ST
|
HRESULT hres;
|
||||||
RINOK(ParseMtProp(name.Ptr(2), value, _numProcessors, _numThreads));
|
if (SetCommonProperty(name, value, hres))
|
||||||
AddProp_NumThreads(_numThreads);
|
{
|
||||||
#endif
|
RINOK(hres)
|
||||||
}
|
continue;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
RINOK(ParseMethodFromPROPVARIANT(names[i], value));
|
|
||||||
}
|
}
|
||||||
|
RINOK(ParseMethodFromPROPVARIANT(names[i], value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,57 @@
|
|||||||
#ifndef __HANDLER_OUT_H
|
#ifndef __HANDLER_OUT_H
|
||||||
#define __HANDLER_OUT_H
|
#define __HANDLER_OUT_H
|
||||||
|
|
||||||
|
#include "../../../Windows/System.h"
|
||||||
|
|
||||||
#include "../../Common/MethodProps.h"
|
#include "../../Common/MethodProps.h"
|
||||||
|
|
||||||
namespace NArchive {
|
namespace NArchive {
|
||||||
|
|
||||||
class CMultiMethodProps
|
bool ParseSizeString(const wchar_t *name, const PROPVARIANT &prop, UInt64 percentsBase, UInt64 &res);
|
||||||
|
|
||||||
|
class CCommonMethodProps
|
||||||
{
|
{
|
||||||
UInt32 _level;
|
protected:
|
||||||
int _analysisLevel;
|
void InitCommon()
|
||||||
|
{
|
||||||
|
#ifndef _7ZIP_ST
|
||||||
|
_numProcessors = _numThreads = NWindows::NSystem::GetNumberOfProcessors();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UInt64 memAvail = (UInt64)(sizeof(size_t)) << 28;
|
||||||
|
_memAvail = memAvail;
|
||||||
|
_memUsage = memAvail;
|
||||||
|
if (NWindows::NSystem::GetRamSize(memAvail))
|
||||||
|
{
|
||||||
|
_memAvail = memAvail;
|
||||||
|
_memUsage = memAvail / 32 * 17;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifndef _7ZIP_ST
|
#ifndef _7ZIP_ST
|
||||||
UInt32 _numThreads;
|
UInt32 _numThreads;
|
||||||
UInt32 _numProcessors;
|
UInt32 _numProcessors;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
UInt64 _memUsage;
|
||||||
|
UInt64 _memAvail;
|
||||||
|
|
||||||
|
bool SetCommonProperty(const UString &name, const PROPVARIANT &value, HRESULT &hres);
|
||||||
|
|
||||||
|
CCommonMethodProps() { InitCommon(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef EXTRACT_ONLY
|
||||||
|
|
||||||
|
class CMultiMethodProps: public CCommonMethodProps
|
||||||
|
{
|
||||||
|
UInt32 _level;
|
||||||
|
int _analysisLevel;
|
||||||
|
|
||||||
|
void InitMulti();
|
||||||
|
public:
|
||||||
UInt32 _crcSize;
|
UInt32 _crcSize;
|
||||||
CObjectVector<COneMethodInfo> _methods;
|
CObjectVector<COneMethodInfo> _methods;
|
||||||
COneMethodInfo _filterMethod;
|
COneMethodInfo _filterMethod;
|
||||||
@@ -43,27 +80,31 @@ public:
|
|||||||
int GetAnalysisLevel() const { return _analysisLevel; }
|
int GetAnalysisLevel() const { return _analysisLevel; }
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
CMultiMethodProps() { InitMulti(); }
|
||||||
|
|
||||||
CMultiMethodProps() { Init(); }
|
|
||||||
HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
|
HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CSingleMethodProps: public COneMethodInfo
|
|
||||||
|
class CSingleMethodProps: public COneMethodInfo, public CCommonMethodProps
|
||||||
{
|
{
|
||||||
UInt32 _level;
|
UInt32 _level;
|
||||||
|
|
||||||
public:
|
void InitSingle()
|
||||||
#ifndef _7ZIP_ST
|
{
|
||||||
UInt32 _numThreads;
|
_level = (UInt32)(Int32)-1;
|
||||||
UInt32 _numProcessors;
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
public:
|
||||||
void Init();
|
void Init();
|
||||||
CSingleMethodProps() { Init(); }
|
CSingleMethodProps() { InitSingle(); }
|
||||||
|
|
||||||
int GetLevel() const { return _level == (UInt32)(Int32)-1 ? 5 : (int)_level; }
|
int GetLevel() const { return _level == (UInt32)(Int32)-1 ? 5 : (int)_level; }
|
||||||
HRESULT SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
|
HRESULT SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "../Compress/BZip2Decoder.h"
|
#include "../Compress/BZip2Decoder.h"
|
||||||
#include "../Compress/CopyCoder.h"
|
#include "../Compress/CopyCoder.h"
|
||||||
|
#include "../Compress/LzfseDecoder.h"
|
||||||
#include "../Compress/ZlibDecoder.h"
|
#include "../Compress/ZlibDecoder.h"
|
||||||
|
|
||||||
#include "Common/OutStreamWithCRC.h"
|
#include "Common/OutStreamWithCRC.h"
|
||||||
@@ -121,6 +122,7 @@ enum
|
|||||||
METHOD_ADC = 0x80000004,
|
METHOD_ADC = 0x80000004,
|
||||||
METHOD_ZLIB = 0x80000005,
|
METHOD_ZLIB = 0x80000005,
|
||||||
METHOD_BZIP2 = 0x80000006,
|
METHOD_BZIP2 = 0x80000006,
|
||||||
|
METHOD_LZFSE = 0x80000007,
|
||||||
METHOD_COMMENT = 0x7FFFFFFE, // is used to comment "+beg" and "+end" in extra field.
|
METHOD_COMMENT = 0x7FFFFFFE, // is used to comment "+beg" and "+end" in extra field.
|
||||||
METHOD_END = 0xFFFFFFFF
|
METHOD_END = 0xFFFFFFFF
|
||||||
};
|
};
|
||||||
@@ -217,6 +219,7 @@ class CHandler:
|
|||||||
bool _masterCrcError;
|
bool _masterCrcError;
|
||||||
bool _headersError;
|
bool _headersError;
|
||||||
|
|
||||||
|
UInt32 _dataStartOffset;
|
||||||
UInt64 _startPos;
|
UInt64 _startPos;
|
||||||
UInt64 _phySize;
|
UInt64 _phySize;
|
||||||
|
|
||||||
@@ -276,6 +279,7 @@ void CMethods::GetString(AString &res) const
|
|||||||
case METHOD_ADC: s = "ADC"; break;
|
case METHOD_ADC: s = "ADC"; break;
|
||||||
case METHOD_ZLIB: s = "ZLIB"; break;
|
case METHOD_ZLIB: s = "ZLIB"; break;
|
||||||
case METHOD_BZIP2: s = "BZip2"; break;
|
case METHOD_BZIP2: s = "BZip2"; break;
|
||||||
|
case METHOD_LZFSE: s = "LZFSE"; break;
|
||||||
default: ConvertUInt32ToString(type, buf); s = buf;
|
default: ConvertUInt32ToString(type, buf); s = buf;
|
||||||
}
|
}
|
||||||
res.Add_OptSpaced(s);
|
res.Add_OptSpaced(s);
|
||||||
@@ -307,6 +311,10 @@ static const CAppleName k_Names[] =
|
|||||||
{ true, "hfs", "Apple_HFS" },
|
{ true, "hfs", "Apple_HFS" },
|
||||||
{ true, "hfsx", "Apple_HFSX" },
|
{ true, "hfsx", "Apple_HFSX" },
|
||||||
{ true, "ufs", "Apple_UFS" },
|
{ true, "ufs", "Apple_UFS" },
|
||||||
|
|
||||||
|
// efi_sys partition is FAT32, but it's not main file. So we use (IsFs = false)
|
||||||
|
{ false, "efi_sys", "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" },
|
||||||
|
|
||||||
{ false, "free", "Apple_Free" },
|
{ false, "free", "Apple_Free" },
|
||||||
{ false, "ddm", "DDM" },
|
{ false, "ddm", "DDM" },
|
||||||
{ false, NULL, "Apple_partition_map" },
|
{ false, NULL, "Apple_partition_map" },
|
||||||
@@ -326,6 +334,7 @@ static const Byte kProps[] =
|
|||||||
kpidCRC,
|
kpidCRC,
|
||||||
kpidComment,
|
kpidComment,
|
||||||
kpidMethod
|
kpidMethod
|
||||||
|
// kpidOffset
|
||||||
};
|
};
|
||||||
|
|
||||||
IMP_IInArchive_Props
|
IMP_IInArchive_Props
|
||||||
@@ -624,17 +633,40 @@ bool CHandler::ParseBlob(const CByteBuffer &data)
|
|||||||
|
|
||||||
HRESULT CHandler::Open2(IInStream *stream)
|
HRESULT CHandler::Open2(IInStream *stream)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
- usual dmg contains Koly Header at the end:
|
||||||
|
- rare case dmg contains Koly Header at the start.
|
||||||
|
*/
|
||||||
|
|
||||||
|
_dataStartOffset = 0;
|
||||||
RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_startPos));
|
RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_startPos));
|
||||||
|
|
||||||
|
UInt64 fileSize = 0;
|
||||||
|
RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize));
|
||||||
|
RINOK(stream->Seek(_startPos, STREAM_SEEK_SET, NULL));
|
||||||
|
|
||||||
Byte buf[HEADER_SIZE];
|
Byte buf[HEADER_SIZE];
|
||||||
RINOK(ReadStream_FALSE(stream, buf, HEADER_SIZE));
|
RINOK(ReadStream_FALSE(stream, buf, HEADER_SIZE));
|
||||||
|
|
||||||
UInt64 headerPos;
|
UInt64 headerPos;
|
||||||
|
bool startKolyMode = false;
|
||||||
|
|
||||||
if (IsKoly(buf))
|
if (IsKoly(buf))
|
||||||
|
{
|
||||||
|
// it can be normal koly-at-the-end or koly-at-the-start
|
||||||
headerPos = _startPos;
|
headerPos = _startPos;
|
||||||
|
if (_startPos <= (1 << 8))
|
||||||
|
{
|
||||||
|
// we want to support startKolyMode, even if there is
|
||||||
|
// some data before dmg file, like 128 bytes MacBin header
|
||||||
|
_dataStartOffset = HEADER_SIZE;
|
||||||
|
startKolyMode = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RINOK(stream->Seek(0, STREAM_SEEK_END, &headerPos));
|
// we check only koly-at-the-end
|
||||||
|
headerPos = fileSize;
|
||||||
if (headerPos < HEADER_SIZE)
|
if (headerPos < HEADER_SIZE)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
headerPos -= HEADER_SIZE;
|
headerPos -= HEADER_SIZE;
|
||||||
@@ -660,24 +692,35 @@ HRESULT CHandler::Open2(IInStream *stream)
|
|||||||
// CChecksum dataForkChecksum;
|
// CChecksum dataForkChecksum;
|
||||||
// dataForkChecksum.Parse(buf + 0x50);
|
// dataForkChecksum.Parse(buf + 0x50);
|
||||||
|
|
||||||
_startPos = 0;
|
|
||||||
|
|
||||||
UInt64 top = 0;
|
UInt64 top = 0;
|
||||||
if (!dataForkPair.UpdateTop(headerPos, top)) return S_FALSE;
|
UInt64 limit = startKolyMode ? fileSize : headerPos;
|
||||||
if (!xmlPair.UpdateTop(headerPos, top)) return S_FALSE;
|
|
||||||
if (!rsrcPair.UpdateTop(headerPos, top)) return S_FALSE;
|
if (!dataForkPair.UpdateTop(limit, top)) return S_FALSE;
|
||||||
|
if (!xmlPair.UpdateTop(limit, top)) return S_FALSE;
|
||||||
|
if (!rsrcPair.UpdateTop(limit, top)) return S_FALSE;
|
||||||
|
|
||||||
/* Some old dmg files contain garbage data in blobPair field.
|
/* Some old dmg files contain garbage data in blobPair field.
|
||||||
So we need to ignore such garbage case;
|
So we need to ignore such garbage case;
|
||||||
And we still need to detect offset of start of archive for "parser" mode. */
|
And we still need to detect offset of start of archive for "parser" mode. */
|
||||||
|
|
||||||
bool useBlob = blobPair.UpdateTop(headerPos, top);
|
bool useBlob = blobPair.UpdateTop(limit, top);
|
||||||
|
|
||||||
_startPos = 0;
|
|
||||||
_phySize = headerPos + HEADER_SIZE;
|
|
||||||
|
|
||||||
if (top != headerPos)
|
if (startKolyMode)
|
||||||
|
_phySize = top;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
_phySize = headerPos + HEADER_SIZE;
|
||||||
|
_startPos = 0;
|
||||||
|
if (top != headerPos)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
if expected absolute offset is not equal to real header offset,
|
||||||
|
2 cases are possible:
|
||||||
|
- additional (unknown) headers
|
||||||
|
- archive with offset.
|
||||||
|
So we try to read XML with absolute offset to select from these two ways.
|
||||||
|
*/
|
||||||
CForkPair xmlPair2 = xmlPair;
|
CForkPair xmlPair2 = xmlPair;
|
||||||
const char *sz = "<?xml version";
|
const char *sz = "<?xml version";
|
||||||
const unsigned len = (unsigned)strlen(sz);
|
const unsigned len = (unsigned)strlen(sz);
|
||||||
@@ -687,9 +730,11 @@ HRESULT CHandler::Open2(IInStream *stream)
|
|||||||
if (ReadData(stream, xmlPair2, buf2) != S_OK
|
if (ReadData(stream, xmlPair2, buf2) != S_OK
|
||||||
|| memcmp(buf2, sz, len) != 0)
|
|| memcmp(buf2, sz, len) != 0)
|
||||||
{
|
{
|
||||||
|
// if absolute offset is not OK, probably it's archive with offset
|
||||||
_startPos = headerPos - top;
|
_startPos = headerPos - top;
|
||||||
_phySize = top + HEADER_SIZE;
|
_phySize = top + HEADER_SIZE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Byte reserved[0x78]
|
// Byte reserved[0x78]
|
||||||
@@ -743,9 +788,21 @@ HRESULT CHandler::Open2(IInStream *stream)
|
|||||||
if (headSize != RSRC_HEAD_SIZE
|
if (headSize != RSRC_HEAD_SIZE
|
||||||
|| footerOffset >= rsrcPair.Len
|
|| footerOffset >= rsrcPair.Len
|
||||||
|| mainDataSize >= rsrcPair.Len
|
|| mainDataSize >= rsrcPair.Len
|
||||||
|| footerOffset + footerSize != rsrcPair.Len
|
|| footerOffset < mainDataSize
|
||||||
|| footerOffset != headSize + mainDataSize)
|
|| footerOffset != headSize + mainDataSize)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
|
const UInt32 footerEnd = footerOffset + footerSize;
|
||||||
|
if (footerEnd != rsrcPair.Len)
|
||||||
|
{
|
||||||
|
// there is rare case dmg example, where there are 4 additional bytes
|
||||||
|
UInt64 rem = rsrcPair.Len - footerOffset;
|
||||||
|
if (rem < footerSize
|
||||||
|
|| rem - footerSize != 4
|
||||||
|
|| Get32(p + footerEnd) != 0)
|
||||||
|
return S_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (footerSize < 16)
|
if (footerSize < 16)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
if (memcmp(p, p + footerOffset, 16) != 0)
|
if (memcmp(p, p + footerOffset, 16) != 0)
|
||||||
@@ -1034,6 +1091,14 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
case kpidOffset:
|
||||||
|
{
|
||||||
|
prop = item.StartPos;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
case kpidMethod:
|
case kpidMethod:
|
||||||
{
|
{
|
||||||
CMethods m;
|
CMethods m;
|
||||||
@@ -1247,6 +1312,11 @@ STDMETHODIMP CAdcDecoder::Code(ISequentialInStream *inStream,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||||
Int32 testMode, IArchiveExtractCallback *extractCallback)
|
Int32 testMode, IArchiveExtractCallback *extractCallback)
|
||||||
{
|
{
|
||||||
@@ -1292,6 +1362,9 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
CAdcDecoder *adcCoderSpec = new CAdcDecoder();
|
CAdcDecoder *adcCoderSpec = new CAdcDecoder();
|
||||||
CMyComPtr<ICompressCoder> adcCoder = adcCoderSpec;
|
CMyComPtr<ICompressCoder> adcCoder = adcCoderSpec;
|
||||||
|
|
||||||
|
NCompress::NLzfse::CDecoder *lzfseCoderSpec = new NCompress::NLzfse::CDecoder();
|
||||||
|
CMyComPtr<ICompressCoder> lzfseCoder = lzfseCoderSpec;
|
||||||
|
|
||||||
CLocalProgress *lps = new CLocalProgress;
|
CLocalProgress *lps = new CLocalProgress;
|
||||||
CMyComPtr<ICompressProgressInfo> progress = lps;
|
CMyComPtr<ICompressProgressInfo> progress = lps;
|
||||||
lps->Init(extractCallback, false);
|
lps->Init(extractCallback, false);
|
||||||
@@ -1369,7 +1442,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
RINOK(_inStream->Seek(_startPos + item.StartPos + block.PackPos, STREAM_SEEK_SET, NULL));
|
RINOK(_inStream->Seek(_startPos + _dataStartOffset + item.StartPos + block.PackPos, STREAM_SEEK_SET, NULL));
|
||||||
streamSpec->Init(block.PackSize);
|
streamSpec->Init(block.PackSize);
|
||||||
bool realMethod = true;
|
bool realMethod = true;
|
||||||
outStreamSpec->Init(block.UnpSize);
|
outStreamSpec->Init(block.UnpSize);
|
||||||
@@ -1420,6 +1493,12 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case METHOD_LZFSE:
|
||||||
|
{
|
||||||
|
res = lzfseCoder->Code(inStream, outStream, &block.PackSize, &block.UnpSize, progress);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
opRes = NExtract::NOperationResult::kUnsupportedMethod;
|
opRes = NExtract::NOperationResult::kUnsupportedMethod;
|
||||||
break;
|
break;
|
||||||
@@ -1490,6 +1569,9 @@ class CInStream:
|
|||||||
CAdcDecoder *adcCoderSpec;
|
CAdcDecoder *adcCoderSpec;
|
||||||
CMyComPtr<ICompressCoder> adcCoder;
|
CMyComPtr<ICompressCoder> adcCoder;
|
||||||
|
|
||||||
|
NCompress::NLzfse::CDecoder *lzfseCoderSpec;
|
||||||
|
CMyComPtr<ICompressCoder> lzfseCoder;
|
||||||
|
|
||||||
CBufPtrSeqOutStream *outStreamSpec;
|
CBufPtrSeqOutStream *outStreamSpec;
|
||||||
CMyComPtr<ISequentialOutStream> outStream;
|
CMyComPtr<ISequentialOutStream> outStream;
|
||||||
|
|
||||||
@@ -1652,6 +1734,15 @@ STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
|||||||
res = S_FALSE;
|
res = S_FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case METHOD_LZFSE:
|
||||||
|
if (!lzfseCoder)
|
||||||
|
{
|
||||||
|
lzfseCoderSpec = new NCompress::NLzfse::CDecoder();
|
||||||
|
lzfseCoder = lzfseCoderSpec;
|
||||||
|
}
|
||||||
|
res = lzfseCoder->Code(inStream, outStream, &block.PackSize, &block.UnpSize, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
@@ -1738,6 +1829,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
|||||||
case METHOD_ADC:
|
case METHOD_ADC:
|
||||||
case METHOD_ZLIB:
|
case METHOD_ZLIB:
|
||||||
case METHOD_BZIP2:
|
case METHOD_BZIP2:
|
||||||
|
case METHOD_LZFSE:
|
||||||
case METHOD_END:
|
case METHOD_END:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1747,7 +1839,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
|||||||
|
|
||||||
spec->Stream = _inStream;
|
spec->Stream = _inStream;
|
||||||
spec->Size = spec->File->Size;
|
spec->Size = spec->File->Size;
|
||||||
RINOK(spec->InitAndSeek(_startPos));
|
RINOK(spec->InitAndSeek(_startPos + _dataStartOffset));
|
||||||
*stream = specStream.Detach();
|
*stream = specStream.Detach();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
|
|||||||
@@ -567,6 +567,7 @@ static const char * const g_Machines[] =
|
|||||||
|
|
||||||
static const CUInt32PCharPair g_MachinePairs[] =
|
static const CUInt32PCharPair g_MachinePairs[] =
|
||||||
{
|
{
|
||||||
|
{ 243, "RISC-V" },
|
||||||
{ 47787, "Xilinx MicroBlaze" }
|
{ 47787, "Xilinx MicroBlaze" }
|
||||||
// { 0x9026, "Alpha" }
|
// { 0x9026, "Alpha" }
|
||||||
};
|
};
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user