mirror of
https://github.com/aaru-dps/Aaru.Compression.Native.git
synced 2025-12-16 19:24:31 +00:00
Update to lzma 23.01.
This commit is contained in:
212
3rdparty/lzma/CPP/7zip/UI/Common/LoadCodecs.h
vendored
212
3rdparty/lzma/CPP/7zip/UI/Common/LoadCodecs.h
vendored
@@ -1,7 +1,7 @@
|
||||
// LoadCodecs.h
|
||||
|
||||
#ifndef __LOAD_CODECS_H
|
||||
#define __LOAD_CODECS_H
|
||||
#ifndef ZIP7_INC_LOAD_CODECS_H
|
||||
#define ZIP7_INC_LOAD_CODECS_H
|
||||
|
||||
/*
|
||||
Client application uses LoadCodecs.* to load plugins to
|
||||
@@ -10,26 +10,26 @@ CCodecs object, that contains 3 lists of plugins:
|
||||
2) Codecs - external codecs
|
||||
3) Hashers - external hashers
|
||||
|
||||
EXTERNAL_CODECS
|
||||
Z7_EXTERNAL_CODECS
|
||||
---------------
|
||||
|
||||
if EXTERNAL_CODECS is defined, then the code tries to load external
|
||||
if Z7_EXTERNAL_CODECS is defined, then the code tries to load external
|
||||
plugins from DLL files (shared libraries).
|
||||
|
||||
There are two types of executables in 7-Zip:
|
||||
|
||||
1) Executable that uses external plugins must be compiled
|
||||
with EXTERNAL_CODECS defined:
|
||||
with Z7_EXTERNAL_CODECS defined:
|
||||
- 7z.exe, 7zG.exe, 7zFM.exe
|
||||
|
||||
Note: EXTERNAL_CODECS is used also in CPP/7zip/Common/CreateCoder.h
|
||||
Note: Z7_EXTERNAL_CODECS is used also in CPP/7zip/Common/CreateCoder.h
|
||||
that code is used in plugin module (7z.dll).
|
||||
|
||||
2) Standalone modules are compiled without EXTERNAL_CODECS:
|
||||
2) Standalone modules are compiled without Z7_EXTERNAL_CODECS:
|
||||
- SFX modules: 7z.sfx, 7zCon.sfx
|
||||
- standalone versions of console 7-Zip: 7za.exe, 7zr.exe
|
||||
|
||||
if EXTERNAL_CODECS is defined, CCodecs class implements interfaces:
|
||||
if Z7_EXTERNAL_CODECS is defined, CCodecs class implements interfaces:
|
||||
- ICompressCodecsInfo : for Codecs
|
||||
- IHashers : for Hashers
|
||||
|
||||
@@ -51,7 +51,7 @@ EXTERNAL_CODECS
|
||||
#include "../../../Common/MyString.h"
|
||||
#include "../../../Common/ComTry.h"
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
#include "../../../Windows/DLL.h"
|
||||
#endif
|
||||
|
||||
@@ -60,7 +60,7 @@ EXTERNAL_CODECS
|
||||
#include "../../Archive/IArchive.h"
|
||||
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
|
||||
struct CDllCodecInfo
|
||||
{
|
||||
@@ -68,6 +68,8 @@ struct CDllCodecInfo
|
||||
UInt32 CodecIndex;
|
||||
bool EncoderIsAssigned;
|
||||
bool DecoderIsAssigned;
|
||||
bool IsFilter;
|
||||
bool IsFilter_Assigned;
|
||||
CLSID Encoder;
|
||||
CLSID Decoder;
|
||||
};
|
||||
@@ -94,6 +96,7 @@ struct CArcExtInfo
|
||||
struct CArcInfoEx
|
||||
{
|
||||
UInt32 Flags;
|
||||
UInt32 TimeFlags;
|
||||
|
||||
Func_CreateInArchive CreateInArchive;
|
||||
Func_IsArc IsArcFunc;
|
||||
@@ -101,29 +104,48 @@ struct CArcInfoEx
|
||||
UString Name;
|
||||
CObjectVector<CArcExtInfo> Exts;
|
||||
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
Func_CreateOutArchive CreateOutArchive;
|
||||
bool UpdateEnabled;
|
||||
bool NewInterface;
|
||||
// UInt32 Version;
|
||||
UInt32 SignatureOffset;
|
||||
CObjectVector<CByteBuffer> Signatures;
|
||||
/*
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
UStringVector AssociateExts;
|
||||
#endif
|
||||
*/
|
||||
#endif
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
int LibIndex;
|
||||
UInt32 FormatIndex;
|
||||
CLSID ClassID;
|
||||
#endif
|
||||
|
||||
int Compare(const CArcInfoEx &a) const
|
||||
{
|
||||
const int res = Name.Compare(a.Name);
|
||||
if (res != 0)
|
||||
return res;
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
return MyCompare(LibIndex, a.LibIndex);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
/*
|
||||
if (LibIndex < a.LibIndex) return -1;
|
||||
if (LibIndex > a.LibIndex) return 1;
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
|
||||
bool Flags_KeepName() const { return (Flags & NArcInfoFlags::kKeepName) != 0; }
|
||||
bool Flags_FindSignature() const { return (Flags & NArcInfoFlags::kFindSignature) != 0; }
|
||||
|
||||
bool Flags_AltStreams() const { return (Flags & NArcInfoFlags::kAltStreams) != 0; }
|
||||
bool Flags_NtSecure() const { return (Flags & NArcInfoFlags::kNtSecure) != 0; }
|
||||
bool Flags_NtSecurity() const { return (Flags & NArcInfoFlags::kNtSecure) != 0; }
|
||||
bool Flags_SymLinks() const { return (Flags & NArcInfoFlags::kSymLinks) != 0; }
|
||||
bool Flags_HardLinks() const { return (Flags & NArcInfoFlags::kHardLinks) != 0; }
|
||||
|
||||
@@ -133,6 +155,28 @@ struct CArcInfoEx
|
||||
bool Flags_PreArc() const { return (Flags & NArcInfoFlags::kPreArc) != 0; }
|
||||
bool Flags_PureStartOpen() const { return (Flags & NArcInfoFlags::kPureStartOpen) != 0; }
|
||||
bool Flags_ByExtOnlyOpen() const { return (Flags & NArcInfoFlags::kByExtOnlyOpen) != 0; }
|
||||
bool Flags_HashHandler() const { return (Flags & NArcInfoFlags::kHashHandler) != 0; }
|
||||
|
||||
bool Flags_CTime() const { return (Flags & NArcInfoFlags::kCTime) != 0; }
|
||||
bool Flags_ATime() const { return (Flags & NArcInfoFlags::kATime) != 0; }
|
||||
bool Flags_MTime() const { return (Flags & NArcInfoFlags::kMTime) != 0; }
|
||||
|
||||
bool Flags_CTime_Default() const { return (Flags & NArcInfoFlags::kCTime_Default) != 0; }
|
||||
bool Flags_ATime_Default() const { return (Flags & NArcInfoFlags::kATime_Default) != 0; }
|
||||
bool Flags_MTime_Default() const { return (Flags & NArcInfoFlags::kMTime_Default) != 0; }
|
||||
|
||||
UInt32 Get_TimePrecFlags() const
|
||||
{
|
||||
return (TimeFlags >> NArcInfoTimeFlags::kTime_Prec_Mask_bit_index) &
|
||||
(((UInt32)1 << NArcInfoTimeFlags::kTime_Prec_Mask_num_bits) - 1);
|
||||
}
|
||||
|
||||
UInt32 Get_DefaultTimePrec() const
|
||||
{
|
||||
return (TimeFlags >> NArcInfoTimeFlags::kTime_Prec_Default_bit_index) &
|
||||
(((UInt32)1 << NArcInfoTimeFlags::kTime_Prec_Default_num_bits) - 1);
|
||||
}
|
||||
|
||||
|
||||
UString GetMainExt() const
|
||||
{
|
||||
@@ -142,6 +186,16 @@ struct CArcInfoEx
|
||||
}
|
||||
int FindExtension(const UString &ext) const;
|
||||
|
||||
bool Is_7z() const { return Name.IsEqualTo_Ascii_NoCase("7z"); }
|
||||
bool Is_Split() const { return Name.IsEqualTo_Ascii_NoCase("Split"); }
|
||||
bool Is_Xz() const { return Name.IsEqualTo_Ascii_NoCase("xz"); }
|
||||
bool Is_BZip2() const { return Name.IsEqualTo_Ascii_NoCase("bzip2"); }
|
||||
bool Is_GZip() const { return Name.IsEqualTo_Ascii_NoCase("gzip"); }
|
||||
bool Is_Tar() const { return Name.IsEqualTo_Ascii_NoCase("tar"); }
|
||||
bool Is_Zip() const { return Name.IsEqualTo_Ascii_NoCase("zip"); }
|
||||
bool Is_Rar() const { return Name.IsEqualTo_Ascii_NoCase("rar"); }
|
||||
bool Is_Zstd() const { return Name.IsEqualTo_Ascii_NoCase("zstd"); }
|
||||
|
||||
/*
|
||||
UString GetAllExtensions() const
|
||||
{
|
||||
@@ -149,7 +203,7 @@ struct CArcInfoEx
|
||||
for (int i = 0; i < Exts.Size(); i++)
|
||||
{
|
||||
if (i > 0)
|
||||
s += ' ';
|
||||
s.Add_Space();
|
||||
s += Exts[i].Ext;
|
||||
}
|
||||
return s;
|
||||
@@ -158,49 +212,29 @@ struct CArcInfoEx
|
||||
|
||||
void AddExts(const UString &ext, const UString &addExt);
|
||||
|
||||
bool IsSplit() const { return StringsAreEqualNoCase_Ascii(Name, "Split"); }
|
||||
// bool IsRar() const { return StringsAreEqualNoCase_Ascii(Name, "Rar"); }
|
||||
|
||||
CArcInfoEx():
|
||||
Flags(0),
|
||||
TimeFlags(0),
|
||||
CreateInArchive(NULL),
|
||||
IsArcFunc(NULL)
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
, CreateOutArchive(NULL)
|
||||
, UpdateEnabled(false)
|
||||
, NewInterface(false)
|
||||
// , Version(0)
|
||||
, SignatureOffset(0)
|
||||
#endif
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
, LibIndex(-1)
|
||||
#endif
|
||||
{}
|
||||
};
|
||||
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
|
||||
struct CCodecIcons
|
||||
{
|
||||
struct CIconPair
|
||||
{
|
||||
UString Ext;
|
||||
int IconIndex;
|
||||
};
|
||||
CObjectVector<CIconPair> IconPairs;
|
||||
|
||||
void LoadIcons(HMODULE m);
|
||||
bool FindIconIndex(const UString &ext, int &iconIndex) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
|
||||
struct CCodecLib
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
: public CCodecIcons
|
||||
#endif
|
||||
{
|
||||
NWindows::NDLL::CLibrary Lib;
|
||||
FString Path;
|
||||
@@ -212,17 +246,23 @@ struct CCodecLib
|
||||
Func_SetCodecs SetCodecs;
|
||||
|
||||
CMyComPtr<IHashers> ComHashers;
|
||||
|
||||
UInt32 Version;
|
||||
|
||||
/*
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
void LoadIcons() { CCodecIcons::LoadIcons((HMODULE)Lib); }
|
||||
CCodecIcons CodecIcons;
|
||||
void LoadIcons() { CodecIcons.LoadIcons((HMODULE)Lib); }
|
||||
#endif
|
||||
*/
|
||||
|
||||
CCodecLib():
|
||||
CreateObject(NULL),
|
||||
GetMethodProperty(NULL),
|
||||
CreateDecoder(NULL),
|
||||
CreateEncoder(NULL),
|
||||
SetCodecs(NULL)
|
||||
SetCodecs(NULL),
|
||||
Version(0)
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -236,8 +276,23 @@ struct CCodecError
|
||||
CCodecError(): ErrorCode(0) {}
|
||||
};
|
||||
|
||||
class CCodecs:
|
||||
#ifdef EXTERNAL_CODECS
|
||||
|
||||
struct CCodecInfoUser
|
||||
{
|
||||
// unsigned LibIndex;
|
||||
// UInt32 CodecIndex;
|
||||
// UInt64 id;
|
||||
bool EncoderIsAssigned;
|
||||
bool DecoderIsAssigned;
|
||||
bool IsFilter;
|
||||
bool IsFilter_Assigned;
|
||||
UInt32 NumStreams;
|
||||
AString Name;
|
||||
};
|
||||
|
||||
|
||||
class CCodecs Z7_final:
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
public ICompressCodecsInfo,
|
||||
public IHashers,
|
||||
#else
|
||||
@@ -245,9 +300,15 @@ class CCodecs:
|
||||
#endif
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CLASS_NO_COPY(CCodecs);
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
Z7_IFACES_IMP_UNK_2(ICompressCodecsInfo, IHashers)
|
||||
#else
|
||||
Z7_COM_UNKNOWN_IMP_0
|
||||
#endif // Z7_EXTERNAL_CODECS
|
||||
|
||||
Z7_CLASS_NO_COPY(CCodecs)
|
||||
public:
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
|
||||
CObjectVector<CCodecLib> Libs;
|
||||
FString MainDll_ErrorPath;
|
||||
@@ -258,7 +319,7 @@ public:
|
||||
|
||||
class CReleaser
|
||||
{
|
||||
CLASS_NO_COPY(CReleaser);
|
||||
Z7_CLASS_NO_COPY(CReleaser)
|
||||
|
||||
/* CCodecsReleaser object releases CCodecs links.
|
||||
1) CCodecs is COM object that is deleted when all links to that object will be released/
|
||||
@@ -287,25 +348,27 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
CCodecIcons InternalIcons;
|
||||
#endif
|
||||
*/
|
||||
|
||||
CObjectVector<CArcInfoEx> Formats;
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
CRecordVector<CDllCodecInfo> Codecs;
|
||||
CRecordVector<CDllHasherInfo> Hashers;
|
||||
#endif
|
||||
|
||||
bool CaseSensitiveChange;
|
||||
bool CaseSensitive_Change;
|
||||
bool CaseSensitive;
|
||||
|
||||
CCodecs():
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
NeedSetLibCodecs(true),
|
||||
#endif
|
||||
CaseSensitiveChange(false),
|
||||
CaseSensitive_Change(false),
|
||||
CaseSensitive(false)
|
||||
{}
|
||||
|
||||
@@ -321,38 +384,19 @@ public:
|
||||
|
||||
HRESULT Load();
|
||||
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
int FindFormatForArchiveName(const UString &arcPath) const;
|
||||
int FindFormatForExtension(const UString &ext) const;
|
||||
int FindFormatForArchiveType(const UString &arcType) const;
|
||||
bool FindFormatForArchiveType(const UString &arcType, CIntVector &formatIndices) const;
|
||||
#endif
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
|
||||
MY_UNKNOWN_IMP2(ICompressCodecsInfo, IHashers)
|
||||
|
||||
STDMETHOD(GetNumMethods)(UInt32 *numMethods);
|
||||
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(CreateDecoder)(UInt32 index, const GUID *iid, void **coder);
|
||||
STDMETHOD(CreateEncoder)(UInt32 index, const GUID *iid, void **coder);
|
||||
|
||||
STDMETHOD_(UInt32, GetNumHashers)();
|
||||
STDMETHOD(GetHasherProp)(UInt32 index, PROPID propID, PROPVARIANT *value);
|
||||
STDMETHOD(CreateHasher)(UInt32 index, IHasher **hasher);
|
||||
|
||||
#else
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
#endif // EXTERNAL_CODECS
|
||||
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
|
||||
int GetCodec_LibIndex(UInt32 index) const;
|
||||
bool GetCodec_DecoderIsAssigned(UInt32 index) const;
|
||||
bool GetCodec_EncoderIsAssigned(UInt32 index) const;
|
||||
bool GetCodec_IsFilter(UInt32 index, bool &isAssigned) const;
|
||||
UInt32 GetCodec_NumStreams(UInt32 index);
|
||||
HRESULT GetCodec_Id(UInt32 index, UInt64 &id);
|
||||
AString GetCodec_Name(UInt32 index);
|
||||
@@ -369,7 +413,7 @@ public:
|
||||
HRESULT CreateInArchive(unsigned formatIndex, CMyComPtr<IInArchive> &archive) const
|
||||
{
|
||||
const CArcInfoEx &ai = Formats[formatIndex];
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
if (ai.LibIndex < 0)
|
||||
#endif
|
||||
{
|
||||
@@ -378,17 +422,17 @@ public:
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
return CreateArchiveHandler(ai, false, (void **)&archive);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef _SFX
|
||||
#ifndef Z7_SFX
|
||||
|
||||
HRESULT CreateOutArchive(unsigned formatIndex, CMyComPtr<IOutArchive> &archive) const
|
||||
{
|
||||
const CArcInfoEx &ai = Formats[formatIndex];
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
if (ai.LibIndex < 0)
|
||||
#endif
|
||||
{
|
||||
@@ -398,7 +442,7 @@ public:
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
return CreateArchiveHandler(ai, true, (void **)&archive);
|
||||
#endif
|
||||
}
|
||||
@@ -416,21 +460,23 @@ public:
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif // _SFX
|
||||
void Get_CodecsInfoUser_Vector(CObjectVector<CCodecInfoUser> &v);
|
||||
|
||||
#endif // Z7_SFX
|
||||
};
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
#ifdef Z7_EXTERNAL_CODECS
|
||||
#define CREATE_CODECS_OBJECT \
|
||||
CCodecs *codecs = new CCodecs; \
|
||||
CExternalCodecs __externalCodecs; \
|
||||
__externalCodecs.GetCodecs = codecs; \
|
||||
__externalCodecs.GetHashers = codecs; \
|
||||
CExternalCodecs _externalCodecs; \
|
||||
_externalCodecs.GetCodecs = codecs; \
|
||||
_externalCodecs.GetHashers = codecs; \
|
||||
CCodecs::CReleaser codecsReleaser; \
|
||||
codecsReleaser.Set(codecs);
|
||||
#else
|
||||
#define CREATE_CODECS_OBJECT \
|
||||
CCodecs *codecs = new CCodecs; \
|
||||
CMyComPtr<IUnknown> __codecsRef = codecs;
|
||||
CMyComPtr<IUnknown> _codecsRef = codecs;
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user