mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-09 12:07:07 -06:00
4.27 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
31e7b924e8
commit
d66cf2fcf3
105
7zip/Compress/Rar29/DllExports.cpp
Executable file
105
7zip/Compress/Rar29/DllExports.cpp
Executable file
@@ -0,0 +1,105 @@
|
||||
// DLLExports.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/ComTry.h"
|
||||
|
||||
#include "../Rar20/Rar20Decoder.h"
|
||||
#include "Rar29Decoder.h"
|
||||
|
||||
// {23170F69-40C1-278B-0403-010000000000}
|
||||
DEFINE_GUID(CLSID_CCompressRar15Decoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
// {23170F69-40C1-278B-0403-020000000000}
|
||||
DEFINE_GUID(CLSID_CCompressRar20Decoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
// {23170F69-40C1-278B-0403-030000000000}
|
||||
DEFINE_GUID(CLSID_CCompressRar29Decoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x04, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
extern "C"
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
*outObject = 0;
|
||||
|
||||
int correctInterface = (*iid == IID_ICompressCoder);
|
||||
CMyComPtr<ICompressCoder> coder;
|
||||
if (*clsid == CLSID_CCompressRar15Decoder)
|
||||
{
|
||||
if (!correctInterface)
|
||||
return E_NOINTERFACE;
|
||||
coder = (ICompressCoder *)new NCompress::NRar15::CDecoder;
|
||||
}
|
||||
else if (*clsid == CLSID_CCompressRar20Decoder)
|
||||
{
|
||||
if (!correctInterface)
|
||||
return E_NOINTERFACE;
|
||||
coder = (ICompressCoder *)new NCompress::NRar20::CDecoder;
|
||||
}
|
||||
else if (*clsid == CLSID_CCompressRar29Decoder)
|
||||
{
|
||||
if (!correctInterface)
|
||||
return E_NOINTERFACE;
|
||||
coder = (ICompressCoder *)new NCompress::NRar29::CDecoder;
|
||||
}
|
||||
else
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
*outObject = coder.Detach();
|
||||
COM_TRY_END
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
struct CRarMethodItem
|
||||
{
|
||||
char ID[3];
|
||||
const wchar_t *UserName;
|
||||
const GUID *Decoder;
|
||||
};
|
||||
|
||||
static CRarMethodItem g_Methods[] =
|
||||
{
|
||||
{ { 0x04, 0x03, 0x01 }, L"Rar15", &CLSID_CCompressRar15Decoder },
|
||||
{ { 0x04, 0x03, 0x02 }, L"Rar20", &CLSID_CCompressRar20Decoder },
|
||||
{ { 0x04, 0x03, 0x03 }, L"Rar29", &CLSID_CCompressRar29Decoder }
|
||||
};
|
||||
|
||||
STDAPI GetNumberOfMethods(UINT32 *numMethods)
|
||||
{
|
||||
*numMethods = sizeof(g_Methods) / sizeof(g_Methods[1]);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDAPI GetMethodProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
if (index > sizeof(g_Methods) / sizeof(g_Methods[1]))
|
||||
return E_INVALIDARG;
|
||||
VariantClear((tagVARIANT *)value);
|
||||
const CRarMethodItem &method = g_Methods[index];
|
||||
switch(propID)
|
||||
{
|
||||
case NMethodPropID::kID:
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(method.ID,
|
||||
sizeof(method.ID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
case NMethodPropID::kName:
|
||||
if ((value->bstrVal = ::SysAllocString(method.UserName)) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
case NMethodPropID::kDecoder:
|
||||
if ((value->bstrVal = ::SysAllocStringByteLen(
|
||||
(const char *)method.Decoder, sizeof(GUID))) != 0)
|
||||
value->vt = VT_BSTR;
|
||||
return S_OK;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
128
7zip/Compress/Rar29/Original/archive.hpp
Executable file
128
7zip/Compress/Rar29/Original/archive.hpp
Executable file
@@ -0,0 +1,128 @@
|
||||
#ifndef _RAR_ARCHIVE_
|
||||
#define _RAR_ARCHIVE_
|
||||
|
||||
class Pack;
|
||||
|
||||
enum {EN_LOCK=1,EN_VOL=2,EN_FIRSTVOL=4};
|
||||
|
||||
class Archive:public File
|
||||
{
|
||||
private:
|
||||
bool IsSignature(byte *D);
|
||||
void UpdateLatestTime(FileHeader *CurBlock);
|
||||
void Protect(int RecSectors);
|
||||
void ConvertNameCase(char *Name);
|
||||
void ConvertNameCase(wchar *Name);
|
||||
void ConvertUnknownHeader();
|
||||
bool AddArcComment(char *NameToShow);
|
||||
int ReadOldHeader();
|
||||
void PrepareExtraTime(FileHeader *hd,EXTTIME_MODE etm,EXTTIME_MODE etc,EXTTIME_MODE eta,EXTTIME_MODE etarc,Array<byte> &TimeData);
|
||||
|
||||
#if !defined(SHELL_EXT) && !defined(NOCRYPT)
|
||||
CryptData HeadersCrypt;
|
||||
byte HeadersSalt[SALT_SIZE];
|
||||
#endif
|
||||
#ifndef SHELL_EXT
|
||||
ComprDataIO SubDataIO;
|
||||
byte SubDataSalt[SALT_SIZE];
|
||||
#endif
|
||||
RAROptions *Cmd,DummyCmd;
|
||||
|
||||
MarkHeader MarkHead;
|
||||
OldMainHeader OldMhd;
|
||||
|
||||
int RecoverySectors;
|
||||
Int64 RecoveryPos;
|
||||
|
||||
RarTime LatestTime;
|
||||
int LastReadBlock;
|
||||
int CurHeaderType;
|
||||
|
||||
bool SilentOpen;
|
||||
public:
|
||||
Archive(RAROptions *InitCmd=NULL);
|
||||
bool IsArchive(bool EnableBroken);
|
||||
int SearchBlock(int BlockType);
|
||||
int SearchSubBlock(const char *Type);
|
||||
int ReadBlock(int BlockType);
|
||||
void WriteBlock(int BlockType,BaseBlock *wb=NULL);
|
||||
int PrepareNamesToWrite(char *Name,wchar *NameW,char *DestName,byte *DestNameW);
|
||||
void SetLhdSize();
|
||||
int ReadHeader();
|
||||
void CheckArc(bool EnableBroken);
|
||||
void CheckOpen(char *Name,wchar *NameW=NULL);
|
||||
bool WCheckOpen(char *Name,wchar *NameW=NULL);
|
||||
bool TestLock(int Mode);
|
||||
void MakeTemp();
|
||||
void CopyMainHeader(Archive &Src,bool CopySFX=true,char *NameToDisplay=NULL);
|
||||
bool ProcessToFileHead(Archive &Src,bool LastBlockAdded,
|
||||
Pack *Pack=NULL,const char *SkipName=NULL);
|
||||
void TmpToArc(Archive &Src);
|
||||
void CloseNew(int AdjustRecovery,bool CloseVolume);
|
||||
void WriteEndBlock(bool CloseVolume);
|
||||
void CopyFileRecord(Archive &Src);
|
||||
void CopyArchiveData(Archive &Src);
|
||||
bool GetComment(Array<byte> &CmtData);
|
||||
void ViewComment();
|
||||
void ViewFileComment();
|
||||
void SetLatestTime(RarTime *NewTime);
|
||||
void SeekToNext();
|
||||
bool CheckAccess();
|
||||
bool IsArcDir();
|
||||
bool IsArcLabel();
|
||||
void ConvertAttributes();
|
||||
int GetRecoverySize(bool Required);
|
||||
void VolSubtractHeaderSize(int SubSize);
|
||||
void AddSubData(byte *SrcData,int DataSize,File *SrcFile,char *Name,bool AllowSplit);
|
||||
bool ReadSubData(Array<byte> *UnpData,File *DestFile);
|
||||
int GetHeaderType() {return(CurHeaderType);};
|
||||
int ReadCommentData(Array<byte> &CmtData);
|
||||
void WriteCommentData(byte *Data,int DataSize,bool FileComment);
|
||||
RAROptions* GetRAROptions() {return(Cmd);}
|
||||
void SetSilentOpen(bool Mode) {SilentOpen=Mode;}
|
||||
|
||||
BaseBlock ShortBlock;
|
||||
MainHeader NewMhd;
|
||||
FileHeader NewLhd;
|
||||
EndArcHeader EndArcHead;
|
||||
SubBlockHeader SubBlockHead;
|
||||
FileHeader SubHead;
|
||||
CommentHeader CommHead;
|
||||
ProtectHeader ProtectHead;
|
||||
AVHeader AVHead;
|
||||
SignHeader SignHead;
|
||||
UnixOwnersHeader UOHead;
|
||||
MacFInfoHeader MACHead;
|
||||
EAHeader EAHead;
|
||||
StreamHeader StreamHead;
|
||||
|
||||
Int64 CurBlockPos;
|
||||
Int64 NextBlockPos;
|
||||
|
||||
bool OldFormat;
|
||||
bool Solid;
|
||||
bool Volume;
|
||||
bool MainComment;
|
||||
bool Locked;
|
||||
bool Signed;
|
||||
bool NotFirstVolume;
|
||||
bool Protected;
|
||||
bool Encrypted;
|
||||
uint SFXSize;
|
||||
bool BrokenFileHeader;
|
||||
|
||||
bool Splitting;
|
||||
|
||||
ushort HeaderCRC;
|
||||
|
||||
Int64 VolWrite;
|
||||
Int64 AddingFilesSize;
|
||||
uint AddingHeadersSize;
|
||||
|
||||
bool NewArchive;
|
||||
|
||||
char FirstVolumeName[NM];
|
||||
wchar FirstVolumeNameW[NM];
|
||||
};
|
||||
|
||||
#endif
|
||||
121
7zip/Compress/Rar29/Original/array.hpp
Executable file
121
7zip/Compress/Rar29/Original/array.hpp
Executable file
@@ -0,0 +1,121 @@
|
||||
#ifndef _RAR_ARRAY_
|
||||
#define _RAR_ARRAY_
|
||||
|
||||
extern ErrorHandler ErrHandler;
|
||||
|
||||
template <class T> class Array
|
||||
{
|
||||
private:
|
||||
T *Buffer;
|
||||
int BufSize;
|
||||
int AllocSize;
|
||||
public:
|
||||
Array();
|
||||
Array(int Size);
|
||||
~Array();
|
||||
inline void CleanData();
|
||||
inline T& operator [](int Item);
|
||||
inline int Size();
|
||||
void Add(int Items);
|
||||
void Alloc(int Items);
|
||||
void Reset();
|
||||
void operator = (Array<T> &Src);
|
||||
void Push(T Item);
|
||||
};
|
||||
|
||||
template <class T> void Array<T>::CleanData()
|
||||
{
|
||||
Buffer=NULL;
|
||||
BufSize=0;
|
||||
AllocSize=0;
|
||||
}
|
||||
|
||||
|
||||
template <class T> Array<T>::Array()
|
||||
{
|
||||
CleanData();
|
||||
}
|
||||
|
||||
|
||||
template <class T> Array<T>::Array(int Size)
|
||||
{
|
||||
Buffer=(T *)rarmalloc(sizeof(T)*Size);
|
||||
if (Buffer==NULL && Size!=0)
|
||||
ErrHandler.MemoryError();
|
||||
|
||||
AllocSize=BufSize=Size;
|
||||
}
|
||||
|
||||
|
||||
template <class T> Array<T>::~Array()
|
||||
{
|
||||
if (Buffer!=NULL)
|
||||
rarfree(Buffer);
|
||||
}
|
||||
|
||||
|
||||
template <class T> inline T& Array<T>::operator [](int Item)
|
||||
{
|
||||
return(Buffer[Item]);
|
||||
}
|
||||
|
||||
|
||||
template <class T> inline int Array<T>::Size()
|
||||
{
|
||||
return(BufSize);
|
||||
}
|
||||
|
||||
|
||||
template <class T> void Array<T>::Add(int Items)
|
||||
{
|
||||
BufSize+=Items;
|
||||
if (BufSize>AllocSize)
|
||||
{
|
||||
int Suggested=AllocSize+AllocSize/4+32;
|
||||
int NewSize=Max(BufSize,Suggested);
|
||||
|
||||
Buffer=(T *)rarrealloc(Buffer,NewSize*sizeof(T));
|
||||
if (Buffer==NULL)
|
||||
ErrHandler.MemoryError();
|
||||
AllocSize=NewSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T> void Array<T>::Alloc(int Items)
|
||||
{
|
||||
if (Items>AllocSize)
|
||||
Add(Items-BufSize);
|
||||
else
|
||||
BufSize=Items;
|
||||
}
|
||||
|
||||
|
||||
template <class T> void Array<T>::Reset()
|
||||
{
|
||||
if (Buffer!=NULL)
|
||||
{
|
||||
rarfree(Buffer);
|
||||
Buffer=NULL;
|
||||
}
|
||||
BufSize=0;
|
||||
AllocSize=0;
|
||||
}
|
||||
|
||||
|
||||
template <class T> void Array<T>::operator =(Array<T> &Src)
|
||||
{
|
||||
Reset();
|
||||
Alloc(Src.BufSize);
|
||||
if (Src.BufSize!=0)
|
||||
memcpy((void *)Buffer,(void *)Src.Buffer,Src.BufSize*sizeof(T));
|
||||
}
|
||||
|
||||
|
||||
template <class T> void Array<T>::Push(T Item)
|
||||
{
|
||||
Add(1);
|
||||
(*this)[Size()-1]=Item;
|
||||
}
|
||||
|
||||
#endif
|
||||
56
7zip/Compress/Rar29/Original/cmddata.hpp
Executable file
56
7zip/Compress/Rar29/Original/cmddata.hpp
Executable file
@@ -0,0 +1,56 @@
|
||||
#ifndef _RAR_CMDDATA_
|
||||
#define _RAR_CMDDATA_
|
||||
|
||||
#define DefaultStoreList "ace;arj;bz2;cab;gz;jpeg;jpg;lha;lzh;mp3;rar;zip;taz;tgz;z"
|
||||
|
||||
class CommandData:public RAROptions
|
||||
{
|
||||
private:
|
||||
void ProcessSwitchesString(char *Str);
|
||||
void ProcessSwitch(char *Switch);
|
||||
void BadSwitch(char *Switch);
|
||||
bool ExclCheckArgs(StringList *Args,char *CheckName,bool CheckFullPath,int MatchMode);
|
||||
uint GetExclAttr(char *Str);
|
||||
|
||||
bool FileLists;
|
||||
bool NoMoreSwitches;
|
||||
bool TimeConverted;
|
||||
bool BareOutput;
|
||||
public:
|
||||
CommandData();
|
||||
~CommandData();
|
||||
void Init();
|
||||
void Close();
|
||||
void ParseArg(char *Arg,wchar *ArgW);
|
||||
void ParseDone();
|
||||
void ParseEnvVar();
|
||||
void ReadConfig(int argc,char *argv[]);
|
||||
bool IsConfigEnabled(int argc,char *argv[]);
|
||||
void OutTitle();
|
||||
void OutHelp();
|
||||
bool IsSwitch(int Ch);
|
||||
bool ExclCheck(char *CheckName,bool CheckFullPath);
|
||||
bool StoreCheck(char *CheckName);
|
||||
bool TimeCheck(RarTime &ft);
|
||||
int IsProcessFile(FileHeader &NewLhd,bool *ExactMatch=NULL,int MatchType=MATCH_WILDSUBPATH);
|
||||
void ProcessCommand();
|
||||
void AddArcName(char *Name,wchar *NameW);
|
||||
bool GetArcName(char *Name,wchar *NameW,int MaxSize);
|
||||
bool CheckWinSize();
|
||||
|
||||
int GetRecoverySize(char *Str,int DefSize);
|
||||
|
||||
char Command[NM+16];
|
||||
wchar CommandW[NM+16];
|
||||
|
||||
char ArcName[NM];
|
||||
wchar ArcNameW[NM];
|
||||
|
||||
StringList *FileArgs;
|
||||
StringList *ExclArgs;
|
||||
StringList *InclArgs;
|
||||
StringList *ArcNames;
|
||||
StringList *StoreArgs;
|
||||
};
|
||||
|
||||
#endif
|
||||
47
7zip/Compress/Rar29/Original/coder.cpp
Executable file
47
7zip/Compress/Rar29/Original/coder.cpp
Executable file
@@ -0,0 +1,47 @@
|
||||
|
||||
|
||||
inline unsigned int RangeCoder::GetChar()
|
||||
{
|
||||
return(UnpackRead->GetChar());
|
||||
}
|
||||
|
||||
|
||||
void RangeCoder::InitDecoder(Unpack *UnpackRead)
|
||||
{
|
||||
RangeCoder::UnpackRead=UnpackRead;
|
||||
|
||||
low=code=0;
|
||||
range=uint(-1);
|
||||
for (int i=0;i < 4;i++)
|
||||
code=(code << 8) | GetChar();
|
||||
}
|
||||
|
||||
|
||||
#define ARI_DEC_NORMALIZE(code,low,range,read) \
|
||||
{ \
|
||||
while ((low^(low+range))<TOP || range<BOT && ((range=-low&(BOT-1)),1)) \
|
||||
{ \
|
||||
code=(code << 8) | read->GetChar(); \
|
||||
range <<= 8; \
|
||||
low <<= 8; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
inline int RangeCoder::GetCurrentCount()
|
||||
{
|
||||
return (code-low)/(range /= SubRange.scale);
|
||||
}
|
||||
|
||||
|
||||
inline uint RangeCoder::GetCurrentShiftCount(uint SHIFT)
|
||||
{
|
||||
return (code-low)/(range >>= SHIFT);
|
||||
}
|
||||
|
||||
|
||||
inline void RangeCoder::Decode()
|
||||
{
|
||||
low += range*SubRange.LowCount;
|
||||
range *= SubRange.HighCount-SubRange.LowCount;
|
||||
}
|
||||
24
7zip/Compress/Rar29/Original/coder.hpp
Executable file
24
7zip/Compress/Rar29/Original/coder.hpp
Executable file
@@ -0,0 +1,24 @@
|
||||
/****************************************************************************
|
||||
* Contents: 'Carryless rangecoder' by Dmitry Subbotin *
|
||||
****************************************************************************/
|
||||
|
||||
const uint TOP=1 << 24, BOT=1 << 15;
|
||||
|
||||
class RangeCoder
|
||||
{
|
||||
public:
|
||||
void InitDecoder(Unpack *UnpackRead);
|
||||
inline int GetCurrentCount();
|
||||
inline uint GetCurrentShiftCount(uint SHIFT);
|
||||
inline void Decode();
|
||||
inline void PutChar(unsigned int c);
|
||||
inline unsigned int GetChar();
|
||||
|
||||
uint low, code, range;
|
||||
struct SUBRANGE
|
||||
{
|
||||
uint LowCount, HighCount, scale;
|
||||
} SubRange;
|
||||
|
||||
Unpack *UnpackRead;
|
||||
};
|
||||
36
7zip/Compress/Rar29/Original/compress.hpp
Executable file
36
7zip/Compress/Rar29/Original/compress.hpp
Executable file
@@ -0,0 +1,36 @@
|
||||
#ifndef _RAR_COMPRESS_
|
||||
#define _RAR_COMPRESS_
|
||||
|
||||
class ComprDataIO;
|
||||
class PackingFileTable;
|
||||
|
||||
#define CODEBUFSIZE 0x4000
|
||||
#define MAXWINSIZE 0x400000
|
||||
#define MAXWINMASK (MAXWINSIZE-1)
|
||||
|
||||
#define LOW_DIST_REP_COUNT 16
|
||||
|
||||
#define NC 299 /* alphabet = {0, 1, 2, ..., NC - 1} */
|
||||
#define DC 60
|
||||
#define LDC 17
|
||||
#define RC 28
|
||||
#define HUFF_TABLE_SIZE (NC+DC+RC+LDC)
|
||||
#define BC 20
|
||||
|
||||
#define NC20 298 /* alphabet = {0, 1, 2, ..., NC - 1} */
|
||||
#define DC20 48
|
||||
#define RC20 28
|
||||
#define BC20 19
|
||||
#define MC20 257
|
||||
|
||||
enum {CODE_HUFFMAN,CODE_LZ,CODE_LZ2,CODE_REPEATLZ,CODE_CACHELZ,
|
||||
CODE_STARTFILE,CODE_ENDFILE,CODE_VM,CODE_VMDATA};
|
||||
|
||||
|
||||
enum FilterType {
|
||||
FILTER_NONE, FILTER_PPM /*dummy*/, FILTER_E8, FILTER_E8E9,
|
||||
FILTER_UPCASETOLOW, FILTER_AUDIO, FILTER_RGB, FILTER_DELTA,
|
||||
FILTER_ITANIUM, FILTER_E8E9V2
|
||||
};
|
||||
|
||||
#endif
|
||||
42
7zip/Compress/Rar29/Original/consio.hpp
Executable file
42
7zip/Compress/Rar29/Original/consio.hpp
Executable file
@@ -0,0 +1,42 @@
|
||||
#ifndef _RAR_CONSIO_
|
||||
#define _RAR_CONSIO_
|
||||
|
||||
enum {ALARM_SOUND,ERROR_SOUND,QUESTION_SOUND};
|
||||
|
||||
enum PASSWORD_TYPE {PASSWORD_GLOBAL,PASSWORD_FILE,PASSWORD_ARCHIVE};
|
||||
|
||||
void InitConsoleOptions(MESSAGE_TYPE MsgStream,bool Sound);
|
||||
|
||||
#ifndef SILENT
|
||||
void mprintf(const char *fmt,...);
|
||||
void eprintf(const char *fmt,...);
|
||||
void Alarm();
|
||||
void GetPasswordText(char *Str,int MaxLength);
|
||||
unsigned int GetKey();
|
||||
bool GetPassword(PASSWORD_TYPE Type,const char *FileName,char *Password,int MaxLength);
|
||||
int Ask(const char *AskStr);
|
||||
#endif
|
||||
|
||||
int KbdAnsi(char *Addr,int Size);
|
||||
void OutComment(char *Comment,int Size);
|
||||
|
||||
#ifdef SILENT
|
||||
#ifdef __GNUC__
|
||||
#define mprintf(args...)
|
||||
#define eprintf(args...)
|
||||
#else
|
||||
inline void mprintf(const char *fmt,const char *a=NULL,const char *b=NULL) {}
|
||||
inline void eprintf(const char *fmt,const char *a=NULL,const char *b=NULL) {}
|
||||
inline void mprintf(const char *fmt,int b) {}
|
||||
inline void eprintf(const char *fmt,int b) {}
|
||||
inline void mprintf(const char *fmt,const char *a,int b) {}
|
||||
inline void eprintf(const char *fmt,const char *a,int b) {}
|
||||
#endif
|
||||
inline void Alarm() {}
|
||||
inline void GetPasswordText(char *Str,int MaxLength) {}
|
||||
inline unsigned int GetKey() {return(0);}
|
||||
inline bool GetPassword(PASSWORD_TYPE Type,const char *FileName,char *Password,int MaxLength) {return(false);}
|
||||
inline int Ask(const char *AskStr) {return(0);}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
61
7zip/Compress/Rar29/Original/crc.cpp
Executable file
61
7zip/Compress/Rar29/Original/crc.cpp
Executable file
@@ -0,0 +1,61 @@
|
||||
#include "rar.hpp"
|
||||
|
||||
uint CRCTab[256];
|
||||
|
||||
void InitCRC()
|
||||
{
|
||||
for (int I=0;I<256;I++)
|
||||
{
|
||||
uint C=I;
|
||||
for (int J=0;J<8;J++)
|
||||
C=(C & 1) ? (C>>1)^0xEDB88320L : (C>>1);
|
||||
CRCTab[I]=C;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint CRC(uint StartCRC,const void *Addr,uint Size)
|
||||
{
|
||||
if (CRCTab[1]==0)
|
||||
InitCRC();
|
||||
byte *Data=(byte *)Addr;
|
||||
#if defined(LITTLE_ENDIAN) && defined(PRESENT_INT32)
|
||||
while (Size>0 && ((long)Data & 7))
|
||||
{
|
||||
StartCRC=CRCTab[(byte)(StartCRC^Data[0])]^(StartCRC>>8);
|
||||
Size--;
|
||||
Data++;
|
||||
}
|
||||
while (Size>=8)
|
||||
{
|
||||
StartCRC^=*(uint32 *)Data;
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC^=*(uint32 *)(Data+4);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
Data+=8;
|
||||
Size-=8;
|
||||
}
|
||||
#endif
|
||||
for (int I=0;I<Size;I++)
|
||||
StartCRC=CRCTab[(byte)(StartCRC^Data[I])]^(StartCRC>>8);
|
||||
return(StartCRC);
|
||||
}
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
ushort OldCRC(ushort StartCRC,const void *Addr,uint Size)
|
||||
{
|
||||
byte *Data=(byte *)Addr;
|
||||
for (int I=0;I<Size;I++)
|
||||
{
|
||||
StartCRC=(StartCRC+Data[I])&0xffff;
|
||||
StartCRC=((StartCRC<<1)|(StartCRC>>15))&0xffff;
|
||||
}
|
||||
return(StartCRC);
|
||||
}
|
||||
#endif
|
||||
10
7zip/Compress/Rar29/Original/crc.hpp
Executable file
10
7zip/Compress/Rar29/Original/crc.hpp
Executable file
@@ -0,0 +1,10 @@
|
||||
#ifndef _RAR_CRC_
|
||||
#define _RAR_CRC_
|
||||
|
||||
extern uint CRCTab[256];
|
||||
|
||||
void InitCRC();
|
||||
uint CRC(uint StartCRC,const void *Addr,uint Size);
|
||||
ushort OldCRC(ushort StartCRC,const void *Addr,uint Size);
|
||||
|
||||
#endif
|
||||
60
7zip/Compress/Rar29/Original/crypt.hpp
Executable file
60
7zip/Compress/Rar29/Original/crypt.hpp
Executable file
@@ -0,0 +1,60 @@
|
||||
#ifndef _RAR_CRYPT_
|
||||
#define _RAR_CRYPT_
|
||||
|
||||
enum { OLD_DECODE=0,OLD_ENCODE=1,NEW_CRYPT=2 };
|
||||
|
||||
struct CryptKeyCacheItem
|
||||
{
|
||||
#ifndef _SFX_RTL_
|
||||
CryptKeyCacheItem()
|
||||
{
|
||||
*Password=0;
|
||||
}
|
||||
|
||||
~CryptKeyCacheItem()
|
||||
{
|
||||
memset(AESKey,0,sizeof(AESKey));
|
||||
memset(AESInit,0,sizeof(AESInit));
|
||||
memset(Password,0,sizeof(Password));
|
||||
}
|
||||
#endif
|
||||
byte AESKey[16],AESInit[16];
|
||||
char Password[MAXPASSWORD];
|
||||
bool SaltPresent;
|
||||
byte Salt[SALT_SIZE];
|
||||
};
|
||||
|
||||
class CryptData
|
||||
{
|
||||
private:
|
||||
void Encode13(byte *Data,uint Count);
|
||||
void Decode13(byte *Data,uint Count);
|
||||
void Crypt15(byte *Data,uint Count);
|
||||
void UpdKeys(byte *Buf);
|
||||
void Swap(byte *Ch1,byte *Ch2);
|
||||
void SetOldKeys(char *Password);
|
||||
|
||||
Rijndael rin;
|
||||
|
||||
byte SubstTable[256];
|
||||
uint Key[4];
|
||||
ushort OldKey[4];
|
||||
byte PN1,PN2,PN3;
|
||||
|
||||
byte AESKey[16],AESInit[16];
|
||||
|
||||
static CryptKeyCacheItem Cache[4];
|
||||
static int CachePos;
|
||||
public:
|
||||
void SetCryptKeys(char *Password,byte *Salt,bool Encrypt,bool OldOnly=false);
|
||||
void SetAV15Encryption();
|
||||
void SetCmt13Encryption();
|
||||
void EncryptBlock20(byte *Buf);
|
||||
void DecryptBlock20(byte *Buf);
|
||||
void EncryptBlock(byte *Buf,int Size);
|
||||
void DecryptBlock(byte *Buf,int Size);
|
||||
void Crypt(byte *Data,uint Count,int Method);
|
||||
static void SetSalt(byte *Salt,int SaltSize);
|
||||
};
|
||||
|
||||
#endif
|
||||
20
7zip/Compress/Rar29/Original/encname.hpp
Executable file
20
7zip/Compress/Rar29/Original/encname.hpp
Executable file
@@ -0,0 +1,20 @@
|
||||
#ifndef _RAR_ENCNAME_
|
||||
#define _RAR_ENCNAME_
|
||||
|
||||
class EncodeFileName
|
||||
{
|
||||
private:
|
||||
void AddFlags(int Value);
|
||||
|
||||
byte *EncName;
|
||||
byte Flags;
|
||||
int FlagBits;
|
||||
int FlagsPos;
|
||||
int DestSize;
|
||||
public:
|
||||
EncodeFileName();
|
||||
int Encode(char *Name,wchar *NameW,byte *EncName);
|
||||
void Decode(char *Name,byte *EncName,int EncSize,wchar *NameW,int MaxDecSize);
|
||||
};
|
||||
|
||||
#endif
|
||||
356
7zip/Compress/Rar29/Original/errhnd.cpp
Executable file
356
7zip/Compress/Rar29/Original/errhnd.cpp
Executable file
@@ -0,0 +1,356 @@
|
||||
#include "rar.hpp"
|
||||
|
||||
|
||||
static bool UserBreak;
|
||||
|
||||
ErrorHandler::ErrorHandler()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::Clean()
|
||||
{
|
||||
ExitCode=SUCCESS;
|
||||
ErrCount=0;
|
||||
EnableBreak=true;
|
||||
Silent=false;
|
||||
DoShutdown=false;
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::MemoryError()
|
||||
{
|
||||
MemoryErrorMsg();
|
||||
Throw(MEMORY_ERROR);
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::OpenError(const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
OpenErrorMsg(FileName);
|
||||
Throw(OPEN_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::CloseError(const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
if (!UserBreak)
|
||||
{
|
||||
ErrMsg(NULL,St(MErrFClose),FileName);
|
||||
SysErrMsg();
|
||||
}
|
||||
#endif
|
||||
#if !defined(SILENT) || defined(RARDLL)
|
||||
Throw(FATAL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::ReadError(const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
ReadErrorMsg(NULL,FileName);
|
||||
#endif
|
||||
#if !defined(SILENT) || defined(RARDLL)
|
||||
Throw(FATAL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool ErrorHandler::AskRepeatRead(const char *FileName)
|
||||
{
|
||||
#if !defined(SILENT) && !defined(SFX_MODULE) && !defined(_WIN_CE)
|
||||
if (!Silent)
|
||||
{
|
||||
mprintf("\n");
|
||||
Log(NULL,St(MErrRead),FileName);
|
||||
return(Ask(St(MRetryAbort))==1);
|
||||
}
|
||||
#endif
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::WriteError(const char *ArcName,const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
WriteErrorMsg(ArcName,FileName);
|
||||
#endif
|
||||
#if !defined(SILENT) || defined(RARDLL)
|
||||
Throw(WRITE_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN_32
|
||||
void ErrorHandler::WriteErrorFAT(const char *FileName)
|
||||
{
|
||||
#if !defined(SILENT) && !defined(SFX_MODULE)
|
||||
SysErrMsg();
|
||||
ErrMsg(NULL,St(MNTFSRequired),FileName);
|
||||
#endif
|
||||
#if !defined(SILENT) && !defined(SFX_MODULE) || defined(RARDLL)
|
||||
Throw(WRITE_ERROR);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool ErrorHandler::AskRepeatWrite(const char *FileName)
|
||||
{
|
||||
#if !defined(SILENT) && !defined(_WIN_CE)
|
||||
if (!Silent)
|
||||
{
|
||||
mprintf("\n");
|
||||
Log(NULL,St(MErrWrite),FileName);
|
||||
return(Ask(St(MRetryAbort))==1);
|
||||
}
|
||||
#endif
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::SeekError(const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
if (!UserBreak)
|
||||
{
|
||||
ErrMsg(NULL,St(MErrSeek),FileName);
|
||||
SysErrMsg();
|
||||
}
|
||||
#endif
|
||||
#if !defined(SILENT) || defined(RARDLL)
|
||||
Throw(FATAL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::MemoryErrorMsg()
|
||||
{
|
||||
#ifndef SILENT
|
||||
ErrMsg(NULL,St(MErrOutMem));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::OpenErrorMsg(const char *FileName)
|
||||
{
|
||||
OpenErrorMsg(NULL,FileName);
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::OpenErrorMsg(const char *ArcName,const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
Log(ArcName && *ArcName ? ArcName:NULL,St(MCannotOpen),FileName);
|
||||
Alarm();
|
||||
SysErrMsg();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::CreateErrorMsg(const char *FileName)
|
||||
{
|
||||
CreateErrorMsg(NULL,FileName);
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::CreateErrorMsg(const char *ArcName,const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
Log(ArcName && *ArcName ? ArcName:NULL,St(MCannotCreate),FileName);
|
||||
Alarm();
|
||||
#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE) && defined(MAXPATH)
|
||||
if (GetLastError()==ERROR_PATH_NOT_FOUND)
|
||||
{
|
||||
int NameLength=strlen(FileName);
|
||||
if (!IsFullPath(FileName))
|
||||
{
|
||||
char CurDir[NM];
|
||||
GetCurrentDirectory(sizeof(CurDir),CurDir);
|
||||
NameLength+=strlen(CurDir)+1;
|
||||
}
|
||||
if (NameLength>MAXPATH)
|
||||
{
|
||||
Log(ArcName && *ArcName ? ArcName:NULL,St(MMaxPathLimit),MAXPATH);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
SysErrMsg();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::ReadErrorMsg(const char *ArcName,const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
ErrMsg(ArcName,St(MErrRead),FileName);
|
||||
SysErrMsg();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::WriteErrorMsg(const char *ArcName,const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
ErrMsg(ArcName,St(MErrWrite),FileName);
|
||||
SysErrMsg();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::Exit(int ExitCode)
|
||||
{
|
||||
#ifndef SFX_MODULE
|
||||
Alarm();
|
||||
#endif
|
||||
Throw(ExitCode);
|
||||
}
|
||||
|
||||
|
||||
#ifndef GUI
|
||||
void ErrorHandler::ErrMsg(const char *ArcName,const char *fmt,...)
|
||||
{
|
||||
safebuf char Msg[NM+1024];
|
||||
va_list argptr;
|
||||
va_start(argptr,fmt);
|
||||
vsprintf(Msg,fmt,argptr);
|
||||
va_end(argptr);
|
||||
#ifdef _WIN_32
|
||||
if (UserBreak)
|
||||
Sleep(5000);
|
||||
#endif
|
||||
Alarm();
|
||||
if (*Msg)
|
||||
{
|
||||
Log(ArcName,"\n%s",Msg);
|
||||
mprintf("\n%s\n",St(MProgAborted));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void ErrorHandler::SetErrorCode(int Code)
|
||||
{
|
||||
switch(Code)
|
||||
{
|
||||
case WARNING:
|
||||
case USER_BREAK:
|
||||
if (ExitCode==SUCCESS)
|
||||
ExitCode=Code;
|
||||
break;
|
||||
case FATAL_ERROR:
|
||||
if (ExitCode==SUCCESS || ExitCode==WARNING)
|
||||
ExitCode=FATAL_ERROR;
|
||||
break;
|
||||
default:
|
||||
ExitCode=Code;
|
||||
break;
|
||||
}
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
|
||||
#if !defined(GUI) && !defined(_SFX_RTL_)
|
||||
#ifdef _WIN_32
|
||||
BOOL __stdcall ProcessSignal(DWORD SigType)
|
||||
#else
|
||||
#if defined(__sun)
|
||||
extern "C"
|
||||
#endif
|
||||
void _stdfunction ProcessSignal(int SigType)
|
||||
#endif
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
if (SigType==CTRL_LOGOFF_EVENT)
|
||||
return(TRUE);
|
||||
#endif
|
||||
UserBreak=true;
|
||||
mprintf(St(MBreak));
|
||||
for (int I=0;
|
||||
// Igor Pavlov
|
||||
// !File::RemoveCreated() &&
|
||||
I<3;I++)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
Sleep(100);
|
||||
#endif
|
||||
}
|
||||
#if defined(USE_RC) && !defined(SFX_MODULE) && !defined(_WIN_CE)
|
||||
ExtRes.UnloadDLL();
|
||||
#endif
|
||||
exit(USER_BREAK);
|
||||
#ifdef _WIN_32
|
||||
return(TRUE);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void ErrorHandler::SetSignalHandlers(bool Enable)
|
||||
{
|
||||
EnableBreak=Enable;
|
||||
#if !defined(GUI) && !defined(_SFX_RTL_)
|
||||
#ifdef _WIN_32
|
||||
SetConsoleCtrlHandler(Enable ? ProcessSignal:NULL,TRUE);
|
||||
// signal(SIGBREAK,Enable ? ProcessSignal:SIG_IGN);
|
||||
#else
|
||||
signal(SIGINT,Enable ? ProcessSignal:SIG_IGN);
|
||||
signal(SIGTERM,Enable ? ProcessSignal:SIG_IGN);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::Throw(int Code)
|
||||
{
|
||||
if (Code==USER_BREAK && !EnableBreak)
|
||||
return;
|
||||
ErrHandler.SetErrorCode(Code);
|
||||
#ifdef ALLOW_EXCEPTIONS
|
||||
throw Code;
|
||||
#else
|
||||
// Igor Pavlov
|
||||
// File::RemoveCreated();
|
||||
exit(Code);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::SysErrMsg()
|
||||
{
|
||||
#if defined(_WIN_32) && !defined(SFX_MODULE) && !defined(SILENT)
|
||||
#define STRCHR strchr
|
||||
#define ERRCHAR char
|
||||
ERRCHAR *lpMsgBuf=NULL;
|
||||
int ErrType=GetLastError();
|
||||
if (ErrType!=0 && FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,ErrType,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&lpMsgBuf,0,NULL))
|
||||
{
|
||||
ERRCHAR *CurMsg=lpMsgBuf;
|
||||
while (CurMsg!=NULL)
|
||||
{
|
||||
while (*CurMsg=='\r' || *CurMsg=='\n')
|
||||
CurMsg++;
|
||||
if (*CurMsg==0)
|
||||
break;
|
||||
ERRCHAR *EndMsg=STRCHR(CurMsg,'\r');
|
||||
if (EndMsg==NULL)
|
||||
EndMsg=STRCHR(CurMsg,'\n');
|
||||
if (EndMsg!=NULL)
|
||||
{
|
||||
*EndMsg=0;
|
||||
EndMsg++;
|
||||
}
|
||||
Log(NULL,"\n%s",CurMsg);
|
||||
CurMsg=EndMsg;
|
||||
}
|
||||
}
|
||||
LocalFree( lpMsgBuf );
|
||||
#endif
|
||||
}
|
||||
61
7zip/Compress/Rar29/Original/errhnd.hpp
Executable file
61
7zip/Compress/Rar29/Original/errhnd.hpp
Executable file
@@ -0,0 +1,61 @@
|
||||
#ifndef _RAR_ERRHANDLER_
|
||||
#define _RAR_ERRHANDLER_
|
||||
|
||||
#if (defined(GUI) || !defined(_WIN_32)) && !defined(SFX_MODULE) && !defined(_WIN_CE) || defined(RARDLL)
|
||||
#define ALLOW_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define rarmalloc malloc
|
||||
#define rarcalloc calloc
|
||||
#define rarrealloc realloc
|
||||
#define rarfree free
|
||||
#define rarstrdup strdup
|
||||
|
||||
|
||||
|
||||
enum { SUCCESS,WARNING,FATAL_ERROR,CRC_ERROR,LOCK_ERROR,WRITE_ERROR,
|
||||
OPEN_ERROR,USER_ERROR,MEMORY_ERROR,CREATE_ERROR,USER_BREAK=255};
|
||||
|
||||
class ErrorHandler
|
||||
{
|
||||
private:
|
||||
void ErrMsg(const char *ArcName,const char *fmt,...);
|
||||
|
||||
int ExitCode;
|
||||
int ErrCount;
|
||||
bool EnableBreak;
|
||||
bool Silent;
|
||||
bool DoShutdown;
|
||||
public:
|
||||
ErrorHandler();
|
||||
void Clean();
|
||||
void MemoryError();
|
||||
void OpenError(const char *FileName);
|
||||
void CloseError(const char *FileName);
|
||||
void ReadError(const char *FileName);
|
||||
bool AskRepeatRead(const char *FileName);
|
||||
void WriteError(const char *ArcName,const char *FileName);
|
||||
void WriteErrorFAT(const char *FileName);
|
||||
bool AskRepeatWrite(const char *FileName);
|
||||
void SeekError(const char *FileName);
|
||||
void MemoryErrorMsg();
|
||||
void OpenErrorMsg(const char *FileName);
|
||||
void OpenErrorMsg(const char *ArcName,const char *FileName);
|
||||
void CreateErrorMsg(const char *FileName);
|
||||
void CreateErrorMsg(const char *ArcName,const char *FileName);
|
||||
void ReadErrorMsg(const char *ArcName,const char *FileName);
|
||||
void WriteErrorMsg(const char *ArcName,const char *FileName);
|
||||
void Exit(int ExitCode);
|
||||
void SetErrorCode(int Code);
|
||||
int GetErrorCode() {return(ExitCode);}
|
||||
int GetErrorCount() {return(ErrCount);}
|
||||
void SetSignalHandlers(bool Enable);
|
||||
void Throw(int Code);
|
||||
void SetSilent(bool Mode) {Silent=Mode;};
|
||||
void SetShutdown(bool Mode) {DoShutdown=Mode;};
|
||||
void SysErrMsg();
|
||||
};
|
||||
|
||||
#endif
|
||||
8
7zip/Compress/Rar29/Original/extinfo.hpp
Executable file
8
7zip/Compress/Rar29/Original/extinfo.hpp
Executable file
@@ -0,0 +1,8 @@
|
||||
#ifndef _RAR_EXTINFO_
|
||||
#define _RAR_EXTINFO_
|
||||
|
||||
|
||||
void SetExtraInfo(CommandData *Cmd,Archive &Arc,char *Name,wchar *NameW);
|
||||
void SetExtraInfoNew(CommandData *Cmd,Archive &Arc,char *Name,wchar *NameW);
|
||||
|
||||
#endif
|
||||
40
7zip/Compress/Rar29/Original/extract.hpp
Executable file
40
7zip/Compress/Rar29/Original/extract.hpp
Executable file
@@ -0,0 +1,40 @@
|
||||
#ifndef _RAR_EXTRACT_
|
||||
#define _RAR_EXTRACT_
|
||||
|
||||
enum EXTRACT_ARC_CODE {EXTRACT_ARC_NEXT,EXTRACT_ARC_REPEAT};
|
||||
|
||||
class CmdExtract
|
||||
{
|
||||
private:
|
||||
ComprDataIO DataIO;
|
||||
Unpack *Unp;
|
||||
long TotalFileCount;
|
||||
|
||||
long FileCount;
|
||||
long MatchedArgs;
|
||||
bool FirstFile;
|
||||
bool AllMatchesExact;
|
||||
bool ReconstructDone;
|
||||
|
||||
char ArcName[NM];
|
||||
wchar ArcNameW[NM];
|
||||
|
||||
char Password[MAXPASSWORD];
|
||||
bool PasswordAll;
|
||||
bool PrevExtracted;
|
||||
bool SignatureFound;
|
||||
char DestFileName[NM];
|
||||
wchar DestFileNameW[NM];
|
||||
bool PasswordCancelled;
|
||||
public:
|
||||
CmdExtract();
|
||||
~CmdExtract();
|
||||
void DoExtract(CommandData *Cmd);
|
||||
void ExtractArchiveInit(CommandData *Cmd,Archive &Arc);
|
||||
EXTRACT_ARC_CODE ExtractArchive(CommandData *Cmd);
|
||||
bool ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize,
|
||||
bool &Repeat);
|
||||
static void UnstoreFile(ComprDataIO &DataIO,Int64 DestUnpSize);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
7zip/Compress/Rar29/Original/filcreat.hpp
Executable file
12
7zip/Compress/Rar29/Original/filcreat.hpp
Executable file
@@ -0,0 +1,12 @@
|
||||
#ifndef _RAR_FILECREATE_
|
||||
#define _RAR_FILECREATE_
|
||||
|
||||
bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
|
||||
OVERWRITE_MODE Mode,bool *UserReject,Int64 FileSize=INT64ERR,
|
||||
uint FileTime=0);
|
||||
|
||||
#if defined(_WIN_32) && !defined(_WIN_CE)
|
||||
bool UpdateExistingShortName(char *Name,wchar *NameW);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
100
7zip/Compress/Rar29/Original/file.hpp
Executable file
100
7zip/Compress/Rar29/Original/file.hpp
Executable file
@@ -0,0 +1,100 @@
|
||||
#ifndef _RAR_FILE_
|
||||
#define _RAR_FILE_
|
||||
|
||||
#ifdef _WIN_32
|
||||
typedef HANDLE FileHandle;
|
||||
#define BAD_HANDLE INVALID_HANDLE_VALUE
|
||||
#else
|
||||
typedef FILE* FileHandle;
|
||||
#define BAD_HANDLE NULL
|
||||
#endif
|
||||
|
||||
class RAROptions;
|
||||
|
||||
enum FILE_HANDLETYPE {FILE_HANDLENORMAL,FILE_HANDLESTD,FILE_HANDLEERR};
|
||||
|
||||
enum FILE_ERRORTYPE {FILE_SUCCESS,FILE_NOTFOUND,FILE_READERROR};
|
||||
|
||||
struct FileStat
|
||||
{
|
||||
uint FileAttr;
|
||||
uint FileTime;
|
||||
Int64 FileSize;
|
||||
bool IsDir;
|
||||
};
|
||||
|
||||
|
||||
class File
|
||||
{
|
||||
private:
|
||||
void AddFileToList(FileHandle hFile);
|
||||
|
||||
FileHandle hFile;
|
||||
bool LastWrite;
|
||||
FILE_HANDLETYPE HandleType;
|
||||
bool SkipClose;
|
||||
bool IgnoreReadErrors;
|
||||
bool NewFile;
|
||||
bool AllowDelete;
|
||||
bool AllowExceptions;
|
||||
#ifdef _WIN_32
|
||||
bool NoSequentialRead;
|
||||
#endif
|
||||
protected:
|
||||
bool OpenShared;
|
||||
public:
|
||||
char FileName[NM];
|
||||
wchar FileNameW[NM];
|
||||
|
||||
FILE_ERRORTYPE ErrorType;
|
||||
|
||||
uint CloseCount;
|
||||
public:
|
||||
File();
|
||||
virtual ~File();
|
||||
void operator = (File &SrcFile);
|
||||
bool Open(const char *Name,const wchar *NameW=NULL,bool OpenShared=false,bool Update=false);
|
||||
void TOpen(const char *Name,const wchar *NameW=NULL);
|
||||
bool WOpen(const char *Name,const wchar *NameW=NULL);
|
||||
bool Create(const char *Name,const wchar *NameW=NULL);
|
||||
void TCreate(const char *Name,const wchar *NameW=NULL);
|
||||
bool WCreate(const char *Name,const wchar *NameW=NULL);
|
||||
bool Close();
|
||||
void Flush();
|
||||
bool Delete();
|
||||
bool Rename(const char *NewName);
|
||||
void Write(const void *Data,int Size);
|
||||
int Read(void *Data,int Size);
|
||||
int DirectRead(void *Data,int Size);
|
||||
void Seek(Int64 Offset,int Method);
|
||||
bool RawSeek(Int64 Offset,int Method);
|
||||
Int64 Tell();
|
||||
void Prealloc(Int64 Size);
|
||||
byte GetByte();
|
||||
void PutByte(byte Byte);
|
||||
bool Truncate();
|
||||
void SetOpenFileTime(RarTime *ftm,RarTime *ftc=NULL,RarTime *fta=NULL);
|
||||
void SetCloseFileTime(RarTime *ftm,RarTime *fta=NULL);
|
||||
static void SetCloseFileTimeByName(const char *Name,RarTime *ftm,RarTime *fta);
|
||||
void SetOpenFileStat(RarTime *ftm,RarTime *ftc,RarTime *fta);
|
||||
void SetCloseFileStat(RarTime *ftm,RarTime *fta,uint FileAttr);
|
||||
void GetOpenFileTime(RarTime *ft);
|
||||
bool IsOpened() {return(hFile!=BAD_HANDLE);};
|
||||
Int64 FileLength();
|
||||
void SetHandleType(FILE_HANDLETYPE Type);
|
||||
FILE_HANDLETYPE GetHandleType() {return(HandleType);};
|
||||
bool IsDevice();
|
||||
void fprintf(const char *fmt,...);
|
||||
static bool RemoveCreated();
|
||||
FileHandle GetHandle() {return(hFile);};
|
||||
void SetIgnoreReadErrors(bool Mode) {IgnoreReadErrors=Mode;};
|
||||
char *GetName() {return(FileName);}
|
||||
long Copy(File &Dest,Int64 Length=INT64ERR);
|
||||
void SetAllowDelete(bool Allow) {AllowDelete=Allow;}
|
||||
void SetExceptions(bool Allow) {AllowExceptions=Allow;}
|
||||
#ifdef _WIN_32
|
||||
void RemoveSequentialFlag() {NoSequentialRead=true;}
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
39
7zip/Compress/Rar29/Original/filefn.hpp
Executable file
39
7zip/Compress/Rar29/Original/filefn.hpp
Executable file
@@ -0,0 +1,39 @@
|
||||
#ifndef _RAR_FILEFN_
|
||||
#define _RAR_FILEFN_
|
||||
|
||||
enum MKDIR_CODE {MKDIR_SUCCESS,MKDIR_ERROR,MKDIR_BADPATH};
|
||||
|
||||
MKDIR_CODE MakeDir(const char *Name,const wchar *NameW,uint Attr);
|
||||
void CreatePath(const char *Path,const wchar *PathW,bool SkipLastName);
|
||||
void SetDirTime(const char *Name,RarTime *ftm,RarTime *ftc,RarTime *fta);
|
||||
bool IsRemovable(const char *Name);
|
||||
Int64 GetFreeDisk(const char *Name);
|
||||
bool FileExist(const char *Name,const wchar *NameW=NULL);
|
||||
bool WildFileExist(const char *Name,const wchar *NameW=NULL);
|
||||
bool IsDir(uint Attr);
|
||||
bool IsUnreadable(uint Attr);
|
||||
bool IsLabel(uint Attr);
|
||||
bool IsLink(uint Attr);
|
||||
void SetSFXMode(const char *FileName);
|
||||
void EraseDiskContents(const char *FileName);
|
||||
bool IsDeleteAllowed(uint FileAttr);
|
||||
void PrepareToDelete(const char *Name,const wchar *NameW=NULL);
|
||||
uint GetFileAttr(const char *Name,const wchar *NameW=NULL);
|
||||
bool SetFileAttr(const char *Name,const wchar *NameW,uint Attr);
|
||||
void ConvertNameToFull(const char *Src,char *Dest);
|
||||
void ConvertNameToFull(const wchar *Src,wchar *Dest);
|
||||
char* MkTemp(char *Name);
|
||||
|
||||
|
||||
uint CalcFileCRC(File *SrcFile,Int64 Size=INT64ERR);
|
||||
bool RenameFile(const char *SrcName,const wchar *SrcNameW,const char *DestName,const wchar *DestNameW);
|
||||
bool DelFile(const char *Name);
|
||||
bool DelFile(const char *Name,const wchar *NameW);
|
||||
bool DelDir(const char *Name);
|
||||
bool DelDir(const char *Name,const wchar *NameW);
|
||||
|
||||
#if defined(_WIN_32) && !defined(_WIN_CE)
|
||||
bool SetFileCompression(char *Name,wchar *NameW,bool State);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
8
7zip/Compress/Rar29/Original/filestr.hpp
Executable file
8
7zip/Compress/Rar29/Original/filestr.hpp
Executable file
@@ -0,0 +1,8 @@
|
||||
#ifndef _RAR_FILESTR_
|
||||
#define _RAR_FILESTR_
|
||||
|
||||
bool ReadTextFile(char *Name,StringList *List,bool Config,
|
||||
bool AbortOnError=false,bool ConvertToAnsi=false,
|
||||
bool Unquote=false,bool SkipComments=false);
|
||||
|
||||
#endif
|
||||
48
7zip/Compress/Rar29/Original/find.hpp
Executable file
48
7zip/Compress/Rar29/Original/find.hpp
Executable file
@@ -0,0 +1,48 @@
|
||||
#ifndef _RAR_FINDDATA_
|
||||
#define _RAR_FINDDATA_
|
||||
|
||||
struct FindData
|
||||
{
|
||||
char Name[NM];
|
||||
wchar NameW[NM];
|
||||
Int64 Size;
|
||||
uint FileAttr;
|
||||
uint FileTime;
|
||||
bool IsDir;
|
||||
RarTime mtime;
|
||||
RarTime ctime;
|
||||
RarTime atime;
|
||||
#ifdef _WIN_32
|
||||
char ShortName[NM];
|
||||
FILETIME ftCreationTime;
|
||||
FILETIME ftLastAccessTime;
|
||||
FILETIME ftLastWriteTime;
|
||||
#endif
|
||||
bool Error;
|
||||
};
|
||||
|
||||
class FindFile
|
||||
{
|
||||
private:
|
||||
#ifdef _WIN_32
|
||||
static HANDLE Win32Find(HANDLE hFind,const char *Mask,const wchar *MaskW,struct FindData *fd);
|
||||
#endif
|
||||
|
||||
char FindMask[NM];
|
||||
wchar FindMaskW[NM];
|
||||
int FirstCall;
|
||||
#ifdef _WIN_32
|
||||
HANDLE hFind;
|
||||
#else
|
||||
DIR *dirp;
|
||||
#endif
|
||||
public:
|
||||
FindFile();
|
||||
~FindFile();
|
||||
void SetMask(const char *FindMask);
|
||||
void SetMaskW(const wchar *FindMaskW);
|
||||
bool Next(struct FindData *fd,bool GetSymLink=false);
|
||||
static bool FastFind(const char *FindMask,const wchar *FindMaskW,struct FindData *fd,bool GetSymLink=false);
|
||||
};
|
||||
|
||||
#endif
|
||||
24
7zip/Compress/Rar29/Original/getbits.cpp
Executable file
24
7zip/Compress/Rar29/Original/getbits.cpp
Executable file
@@ -0,0 +1,24 @@
|
||||
#include "rar.hpp"
|
||||
|
||||
BitInput::BitInput()
|
||||
{
|
||||
InBuf=new byte[MAX_SIZE];
|
||||
}
|
||||
|
||||
|
||||
BitInput::~BitInput()
|
||||
{
|
||||
delete[] InBuf;
|
||||
}
|
||||
|
||||
|
||||
void BitInput::faddbits(int Bits)
|
||||
{
|
||||
addbits(Bits);
|
||||
}
|
||||
|
||||
|
||||
unsigned int BitInput::fgetbits()
|
||||
{
|
||||
return(getbits());
|
||||
}
|
||||
37
7zip/Compress/Rar29/Original/getbits.hpp
Executable file
37
7zip/Compress/Rar29/Original/getbits.hpp
Executable file
@@ -0,0 +1,37 @@
|
||||
#ifndef _RAR_GETBITS_
|
||||
#define _RAR_GETBITS_
|
||||
|
||||
class BitInput
|
||||
{
|
||||
public:
|
||||
enum BufferSize {MAX_SIZE=0x8000};
|
||||
protected:
|
||||
int InAddr,InBit;
|
||||
public:
|
||||
BitInput();
|
||||
~BitInput();
|
||||
|
||||
byte *InBuf;
|
||||
|
||||
void InitBitInput()
|
||||
{
|
||||
InAddr=InBit=0;
|
||||
}
|
||||
void addbits(int Bits)
|
||||
{
|
||||
Bits+=InBit;
|
||||
InAddr+=Bits>>3;
|
||||
InBit=Bits&7;
|
||||
}
|
||||
unsigned int getbits()
|
||||
{
|
||||
unsigned int BitField=(uint)InBuf[InAddr] << 16;
|
||||
BitField|=(uint)InBuf[InAddr+1] << 8;
|
||||
BitField|=(uint)InBuf[InAddr+2];
|
||||
BitField >>= (8-InBit);
|
||||
return(BitField & 0xffff);
|
||||
}
|
||||
void faddbits(int Bits);
|
||||
unsigned int fgetbits();
|
||||
};
|
||||
#endif
|
||||
14
7zip/Compress/Rar29/Original/global.hpp
Executable file
14
7zip/Compress/Rar29/Original/global.hpp
Executable file
@@ -0,0 +1,14 @@
|
||||
#ifndef _RAR_GLOBAL_
|
||||
#define _RAR_GLOBAL_
|
||||
|
||||
#ifdef INCLUDEGLOBAL
|
||||
#define EXTVAR
|
||||
#else
|
||||
#define EXTVAR extern
|
||||
#endif
|
||||
|
||||
EXTVAR ErrorHandler ErrHandler;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
304
7zip/Compress/Rar29/Original/headers.hpp
Executable file
304
7zip/Compress/Rar29/Original/headers.hpp
Executable file
@@ -0,0 +1,304 @@
|
||||
#ifndef _RAR_HEADERS_
|
||||
#define _RAR_HEADERS_
|
||||
|
||||
#define SIZEOF_MARKHEAD 7
|
||||
#define SIZEOF_OLDMHD 7
|
||||
#define SIZEOF_NEWMHD 13
|
||||
#define SIZEOF_OLDLHD 21
|
||||
#define SIZEOF_NEWLHD 32
|
||||
#define SIZEOF_SHORTBLOCKHEAD 7
|
||||
#define SIZEOF_LONGBLOCKHEAD 11
|
||||
#define SIZEOF_SUBBLOCKHEAD 14
|
||||
#define SIZEOF_COMMHEAD 13
|
||||
#define SIZEOF_PROTECTHEAD 26
|
||||
#define SIZEOF_AVHEAD 14
|
||||
#define SIZEOF_SIGNHEAD 15
|
||||
#define SIZEOF_UOHEAD 18
|
||||
#define SIZEOF_MACHEAD 22
|
||||
#define SIZEOF_EAHEAD 24
|
||||
#define SIZEOF_BEEAHEAD 24
|
||||
#define SIZEOF_STREAMHEAD 26
|
||||
|
||||
#define PACK_VER 29
|
||||
#define PACK_CRYPT_VER 29
|
||||
#define UNP_VER 29
|
||||
#define CRYPT_VER 29
|
||||
#define AV_VER 20
|
||||
#define PROTECT_VER 20
|
||||
|
||||
#define MHD_VOLUME 0x0001
|
||||
#define MHD_COMMENT 0x0002
|
||||
#define MHD_LOCK 0x0004
|
||||
#define MHD_SOLID 0x0008
|
||||
#define MHD_PACK_COMMENT 0x0010
|
||||
#define MHD_NEWNUMBERING 0x0010
|
||||
#define MHD_AV 0x0020
|
||||
#define MHD_PROTECT 0x0040
|
||||
#define MHD_PASSWORD 0x0080
|
||||
#define MHD_FIRSTVOLUME 0x0100
|
||||
|
||||
#define LHD_SPLIT_BEFORE 0x0001
|
||||
#define LHD_SPLIT_AFTER 0x0002
|
||||
#define LHD_PASSWORD 0x0004
|
||||
#define LHD_COMMENT 0x0008
|
||||
#define LHD_SOLID 0x0010
|
||||
|
||||
#define LHD_WINDOWMASK 0x00e0
|
||||
#define LHD_WINDOW64 0x0000
|
||||
#define LHD_WINDOW128 0x0020
|
||||
#define LHD_WINDOW256 0x0040
|
||||
#define LHD_WINDOW512 0x0060
|
||||
#define LHD_WINDOW1024 0x0080
|
||||
#define LHD_WINDOW2048 0x00a0
|
||||
#define LHD_WINDOW4096 0x00c0
|
||||
#define LHD_DIRECTORY 0x00e0
|
||||
|
||||
#define LHD_LARGE 0x0100
|
||||
#define LHD_UNICODE 0x0200
|
||||
#define LHD_SALT 0x0400
|
||||
#define LHD_VERSION 0x0800
|
||||
#define LHD_EXTTIME 0x1000
|
||||
#define LHD_EXTFLAGS 0x2000
|
||||
|
||||
#define SKIP_IF_UNKNOWN 0x4000
|
||||
#define LONG_BLOCK 0x8000
|
||||
|
||||
#define EARC_NEXT_VOLUME 0x0001
|
||||
#define EARC_DATACRC 0x0002
|
||||
#define EARC_REVSPACE 0x0004
|
||||
#define EARC_VOLNUMBER 0x0008
|
||||
|
||||
enum HEADER_TYPE {
|
||||
MARK_HEAD=0x72,MAIN_HEAD=0x73,FILE_HEAD=0x74,COMM_HEAD=0x75,AV_HEAD=0x76,
|
||||
SUB_HEAD=0x77,PROTECT_HEAD=0x78,SIGN_HEAD=0x79,NEWSUB_HEAD=0x7a,
|
||||
ENDARC_HEAD=0x7b
|
||||
};
|
||||
|
||||
enum { EA_HEAD=0x100,UO_HEAD=0x101,MAC_HEAD=0x102,BEEA_HEAD=0x103,
|
||||
NTACL_HEAD=0x104,STREAM_HEAD=0x105 };
|
||||
|
||||
enum HOST_SYSTEM {
|
||||
HOST_MSDOS=0,HOST_OS2=1,HOST_WIN32=2,HOST_UNIX=3,HOST_MACOS=4,
|
||||
HOST_BEOS=5,HOST_MAX
|
||||
};
|
||||
|
||||
#define SUBHEAD_TYPE_CMT "CMT"
|
||||
#define SUBHEAD_TYPE_ACL "ACL"
|
||||
#define SUBHEAD_TYPE_STREAM "STM"
|
||||
#define SUBHEAD_TYPE_UOWNER "UOW"
|
||||
#define SUBHEAD_TYPE_AV "AV"
|
||||
#define SUBHEAD_TYPE_RR "RR"
|
||||
#define SUBHEAD_TYPE_OS2EA "EA2"
|
||||
#define SUBHEAD_TYPE_BEOSEA "EABE"
|
||||
|
||||
/* new file inherits a subblock when updating a host file */
|
||||
#define SUBHEAD_FLAGS_INHERITED 0x80000000
|
||||
|
||||
#define SUBHEAD_FLAGS_CMT_UNICODE 0x00000001
|
||||
|
||||
struct OldMainHeader
|
||||
{
|
||||
byte Mark[4];
|
||||
ushort HeadSize;
|
||||
byte Flags;
|
||||
};
|
||||
|
||||
|
||||
struct OldFileHeader
|
||||
{
|
||||
uint PackSize;
|
||||
uint UnpSize;
|
||||
ushort FileCRC;
|
||||
ushort HeadSize;
|
||||
uint FileTime;
|
||||
byte FileAttr;
|
||||
byte Flags;
|
||||
byte UnpVer;
|
||||
byte NameSize;
|
||||
byte Method;
|
||||
};
|
||||
|
||||
|
||||
struct MarkHeader
|
||||
{
|
||||
byte Mark[7];
|
||||
};
|
||||
|
||||
|
||||
struct BaseBlock
|
||||
{
|
||||
ushort HeadCRC;
|
||||
HEADER_TYPE HeadType;//byte
|
||||
ushort Flags;
|
||||
ushort HeadSize;
|
||||
|
||||
bool IsSubBlock()
|
||||
{
|
||||
if (HeadType==SUB_HEAD)
|
||||
return(true);
|
||||
if (HeadType==NEWSUB_HEAD && (Flags & LHD_SOLID)!=0)
|
||||
return(true);
|
||||
return(false);
|
||||
}
|
||||
};
|
||||
|
||||
struct BlockHeader:BaseBlock
|
||||
{
|
||||
union {
|
||||
uint DataSize;
|
||||
uint PackSize;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
struct MainHeader:BlockHeader
|
||||
{
|
||||
ushort HighPosAV;
|
||||
uint PosAV;
|
||||
};
|
||||
|
||||
|
||||
#define SALT_SIZE 8
|
||||
|
||||
struct FileHeader:BlockHeader
|
||||
{
|
||||
uint UnpSize;
|
||||
byte HostOS;
|
||||
uint FileCRC;
|
||||
uint FileTime;
|
||||
byte UnpVer;
|
||||
byte Method;
|
||||
ushort NameSize;
|
||||
union {
|
||||
uint FileAttr;
|
||||
uint SubFlags;
|
||||
};
|
||||
/* optional */
|
||||
uint HighPackSize;
|
||||
uint HighUnpSize;
|
||||
/* names */
|
||||
char FileName[NM];
|
||||
wchar FileNameW[NM];
|
||||
/* optional */
|
||||
Array<byte> SubData;
|
||||
byte Salt[SALT_SIZE];
|
||||
|
||||
RarTime mtime;
|
||||
RarTime ctime;
|
||||
RarTime atime;
|
||||
RarTime arctime;
|
||||
/* dummy */
|
||||
Int64 FullPackSize;
|
||||
Int64 FullUnpSize;
|
||||
|
||||
void Clear(int SubDataSize)
|
||||
{
|
||||
SubData.Alloc(SubDataSize);
|
||||
Flags=LONG_BLOCK;
|
||||
SubFlags=0;
|
||||
}
|
||||
|
||||
bool CmpName(const char *Name)
|
||||
{
|
||||
return(strcmp(FileName,Name)==0);
|
||||
}
|
||||
|
||||
FileHeader& operator = (FileHeader &hd)
|
||||
{
|
||||
SubData.Reset();
|
||||
memcpy(this,&hd,sizeof(*this));
|
||||
SubData.CleanData();
|
||||
SubData=hd.SubData;
|
||||
return(*this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct EndArcHeader:BaseBlock
|
||||
{
|
||||
uint ArcDataCRC;
|
||||
ushort VolNumber;
|
||||
};
|
||||
|
||||
|
||||
struct SubBlockHeader:BlockHeader
|
||||
{
|
||||
ushort SubType;
|
||||
byte Level;
|
||||
};
|
||||
|
||||
|
||||
struct CommentHeader:BaseBlock
|
||||
{
|
||||
ushort UnpSize;
|
||||
byte UnpVer;
|
||||
byte Method;
|
||||
ushort CommCRC;
|
||||
};
|
||||
|
||||
|
||||
struct ProtectHeader:BlockHeader
|
||||
{
|
||||
byte Version;
|
||||
ushort RecSectors;
|
||||
uint TotalBlocks;
|
||||
byte Mark[8];
|
||||
};
|
||||
|
||||
|
||||
struct AVHeader:BaseBlock
|
||||
{
|
||||
byte UnpVer;
|
||||
byte Method;
|
||||
byte AVVer;
|
||||
uint AVInfoCRC;
|
||||
};
|
||||
|
||||
|
||||
struct SignHeader:BaseBlock
|
||||
{
|
||||
uint CreationTime;
|
||||
ushort ArcNameSize;
|
||||
ushort UserNameSize;
|
||||
};
|
||||
|
||||
|
||||
struct UnixOwnersHeader:SubBlockHeader
|
||||
{
|
||||
ushort OwnerNameSize;
|
||||
ushort GroupNameSize;
|
||||
/* dummy */
|
||||
char OwnerName[NM];
|
||||
char GroupName[NM];
|
||||
};
|
||||
|
||||
|
||||
struct EAHeader:SubBlockHeader
|
||||
{
|
||||
uint UnpSize;
|
||||
byte UnpVer;
|
||||
byte Method;
|
||||
uint EACRC;
|
||||
};
|
||||
|
||||
|
||||
struct StreamHeader:SubBlockHeader
|
||||
{
|
||||
uint UnpSize;
|
||||
byte UnpVer;
|
||||
byte Method;
|
||||
uint StreamCRC;
|
||||
ushort StreamNameSize;
|
||||
/* dummy */
|
||||
byte StreamName[NM];
|
||||
};
|
||||
|
||||
|
||||
struct MacFInfoHeader:SubBlockHeader
|
||||
{
|
||||
uint fileType;
|
||||
uint fileCreator;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
274
7zip/Compress/Rar29/Original/int64.cpp
Executable file
274
7zip/Compress/Rar29/Original/int64.cpp
Executable file
@@ -0,0 +1,274 @@
|
||||
#include "rar.hpp"
|
||||
|
||||
#ifndef NATIVE_INT64
|
||||
|
||||
Int64::Int64()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Int64::Int64(uint n)
|
||||
{
|
||||
HighPart=0;
|
||||
LowPart=n;
|
||||
}
|
||||
|
||||
|
||||
Int64::Int64(uint HighPart,uint LowPart)
|
||||
{
|
||||
Int64::HighPart=HighPart;
|
||||
Int64::LowPart=LowPart;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Int64 Int64::operator = (Int64 n)
|
||||
{
|
||||
HighPart=n.HighPart;
|
||||
LowPart=n.LowPart;
|
||||
return(*this);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
Int64 Int64::operator << (int n)
|
||||
{
|
||||
Int64 res=*this;
|
||||
while (n--)
|
||||
{
|
||||
res.HighPart<<=1;
|
||||
if (res.LowPart & 0x80000000)
|
||||
res.HighPart|=1;
|
||||
res.LowPart<<=1;
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
|
||||
|
||||
Int64 Int64::operator >> (int n)
|
||||
{
|
||||
Int64 res=*this;
|
||||
while (n--)
|
||||
{
|
||||
res.LowPart>>=1;
|
||||
if (res.HighPart & 1)
|
||||
res.LowPart|=0x80000000;
|
||||
res.HighPart>>=1;
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
|
||||
|
||||
Int64 operator / (Int64 n1,Int64 n2)
|
||||
{
|
||||
if (n1.HighPart==0 && n2.HighPart==0)
|
||||
return(Int64(0,n1.LowPart/n2.LowPart));
|
||||
int ShiftCount=0;
|
||||
while (n1>n2)
|
||||
{
|
||||
n2=n2<<1;
|
||||
if (++ShiftCount>64)
|
||||
return(0);
|
||||
}
|
||||
Int64 res=0;
|
||||
while (ShiftCount-- >= 0)
|
||||
{
|
||||
res=res<<1;
|
||||
if (n1>=n2)
|
||||
{
|
||||
n1-=n2;
|
||||
++res;
|
||||
}
|
||||
n2=n2>>1;
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
|
||||
|
||||
Int64 operator * (Int64 n1,Int64 n2)
|
||||
{
|
||||
if (n1<0x10000 && n2<0x10000)
|
||||
return(Int64(0,n1.LowPart*n2.LowPart));
|
||||
Int64 res=0;
|
||||
for (int I=0;I<64;I++)
|
||||
{
|
||||
if (n2.LowPart & 1)
|
||||
res+=n1;
|
||||
n1=n1<<1;
|
||||
n2=n2>>1;
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
|
||||
|
||||
Int64 operator % (Int64 n1,Int64 n2)
|
||||
{
|
||||
if (n1.HighPart==0 && n2.HighPart==0)
|
||||
return(Int64(0,n1.LowPart%n2.LowPart));
|
||||
return(n1-n1/n2*n2);
|
||||
}
|
||||
|
||||
|
||||
Int64 operator + (Int64 n1,Int64 n2)
|
||||
{
|
||||
n1.LowPart+=n2.LowPart;
|
||||
if (n1.LowPart<n2.LowPart)
|
||||
n1.HighPart++;
|
||||
n1.HighPart+=n2.HighPart;
|
||||
return(n1);
|
||||
}
|
||||
|
||||
|
||||
Int64 operator - (Int64 n1,Int64 n2)
|
||||
{
|
||||
if (n1.LowPart<n2.LowPart)
|
||||
n1.HighPart--;
|
||||
n1.LowPart-=n2.LowPart;
|
||||
n1.HighPart-=n2.HighPart;
|
||||
return(n1);
|
||||
}
|
||||
|
||||
|
||||
Int64 operator += (Int64 &n1,Int64 n2)
|
||||
{
|
||||
n1=n1+n2;
|
||||
return(n1);
|
||||
}
|
||||
|
||||
|
||||
Int64 operator -= (Int64 &n1,Int64 n2)
|
||||
{
|
||||
n1=n1-n2;
|
||||
return(n1);
|
||||
}
|
||||
|
||||
|
||||
Int64 operator *= (Int64 &n1,Int64 n2)
|
||||
{
|
||||
n1=n1*n2;
|
||||
return(n1);
|
||||
}
|
||||
|
||||
|
||||
Int64 operator /= (Int64 &n1,Int64 n2)
|
||||
{
|
||||
n1=n1/n2;
|
||||
return(n1);
|
||||
}
|
||||
|
||||
|
||||
Int64 operator | (Int64 n1,Int64 n2)
|
||||
{
|
||||
n1.LowPart|=n2.LowPart;
|
||||
n1.HighPart|=n2.HighPart;
|
||||
return(n1);
|
||||
}
|
||||
|
||||
|
||||
Int64 operator & (Int64 n1,Int64 n2)
|
||||
{
|
||||
n1.LowPart&=n2.LowPart;
|
||||
n1.HighPart&=n2.HighPart;
|
||||
return(n1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
inline void operator -= (Int64 &n1,unsigned int n2)
|
||||
{
|
||||
if (n1.LowPart<n2)
|
||||
n1.HighPart--;
|
||||
n1.LowPart-=n2;
|
||||
}
|
||||
|
||||
|
||||
inline void operator ++ (Int64 &n)
|
||||
{
|
||||
if (++n.LowPart == 0)
|
||||
++n.HighPart;
|
||||
}
|
||||
|
||||
|
||||
inline void operator -- (Int64 &n)
|
||||
{
|
||||
if (n.LowPart-- == 0)
|
||||
n.HighPart--;
|
||||
}
|
||||
*/
|
||||
|
||||
bool operator == (Int64 n1,Int64 n2)
|
||||
{
|
||||
return(n1.LowPart==n2.LowPart && n1.HighPart==n2.HighPart);
|
||||
}
|
||||
|
||||
|
||||
bool operator > (Int64 n1,Int64 n2)
|
||||
{
|
||||
return((int)n1.HighPart>(int)n2.HighPart || n1.HighPart==n2.HighPart && n1.LowPart>n2.LowPart);
|
||||
}
|
||||
|
||||
|
||||
bool operator < (Int64 n1,Int64 n2)
|
||||
{
|
||||
return((int)n1.HighPart<(int)n2.HighPart || n1.HighPart==n2.HighPart && n1.LowPart<n2.LowPart);
|
||||
}
|
||||
|
||||
|
||||
bool operator != (Int64 n1,Int64 n2)
|
||||
{
|
||||
return(n1.LowPart!=n2.LowPart || n1.HighPart!=n2.HighPart);
|
||||
}
|
||||
|
||||
|
||||
bool operator >= (Int64 n1,Int64 n2)
|
||||
{
|
||||
return(n1>n2 || n1==n2);
|
||||
}
|
||||
|
||||
|
||||
bool operator <= (Int64 n1,Int64 n2)
|
||||
{
|
||||
return(n1<n2 || n1==n2);
|
||||
}
|
||||
|
||||
|
||||
void Int64::Set(uint HighPart,uint LowPart)
|
||||
{
|
||||
Int64::HighPart=HighPart;
|
||||
Int64::LowPart=LowPart;
|
||||
}
|
||||
#endif
|
||||
|
||||
void itoa(Int64 n,char *Str)
|
||||
{
|
||||
if (n<=0xffffffff)
|
||||
{
|
||||
sprintf(Str,"%u",int64to32(n));
|
||||
return;
|
||||
}
|
||||
|
||||
char NumStr[50];
|
||||
int Pos=0;
|
||||
|
||||
do
|
||||
{
|
||||
NumStr[Pos++]=int64to32(n%10)+'0';
|
||||
n=n/10;
|
||||
} while (n!=0);
|
||||
|
||||
for (int I=0;I<Pos;I++)
|
||||
Str[I]=NumStr[Pos-I-1];
|
||||
Str[Pos]=0;
|
||||
}
|
||||
|
||||
|
||||
Int64 atoil(char *Str)
|
||||
{
|
||||
Int64 n=0;
|
||||
while (*Str>='0' && *Str<='9')
|
||||
{
|
||||
n=n*10+*Str-'0';
|
||||
Str++;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
86
7zip/Compress/Rar29/Original/int64.hpp
Executable file
86
7zip/Compress/Rar29/Original/int64.hpp
Executable file
@@ -0,0 +1,86 @@
|
||||
#ifndef _RAR_INT64_
|
||||
#define _RAR_INT64_
|
||||
|
||||
#if defined(__BORLANDC__) || defined(_MSC_VER)
|
||||
#define NATIVE_INT64
|
||||
typedef __int64 Int64;
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__HP_aCC)
|
||||
#define NATIVE_INT64
|
||||
typedef long long Int64;
|
||||
#endif
|
||||
|
||||
#ifdef NATIVE_INT64
|
||||
|
||||
#define int64to32(x) ((uint)(x))
|
||||
#define int32to64(high,low) ((((Int64)(high))<<32)+(low))
|
||||
#define is64plus(x) (x>=0)
|
||||
|
||||
#else
|
||||
|
||||
class Int64
|
||||
{
|
||||
public:
|
||||
Int64();
|
||||
Int64(uint n);
|
||||
Int64(uint HighPart,uint LowPart);
|
||||
|
||||
// Int64 operator = (Int64 n);
|
||||
Int64 operator << (int n);
|
||||
Int64 operator >> (int n);
|
||||
|
||||
friend Int64 operator / (Int64 n1,Int64 n2);
|
||||
friend Int64 operator * (Int64 n1,Int64 n2);
|
||||
friend Int64 operator % (Int64 n1,Int64 n2);
|
||||
friend Int64 operator + (Int64 n1,Int64 n2);
|
||||
friend Int64 operator - (Int64 n1,Int64 n2);
|
||||
friend Int64 operator += (Int64 &n1,Int64 n2);
|
||||
friend Int64 operator -= (Int64 &n1,Int64 n2);
|
||||
friend Int64 operator *= (Int64 &n1,Int64 n2);
|
||||
friend Int64 operator /= (Int64 &n1,Int64 n2);
|
||||
friend Int64 operator | (Int64 n1,Int64 n2);
|
||||
friend Int64 operator & (Int64 n1,Int64 n2);
|
||||
inline friend void operator -= (Int64 &n1,unsigned int n2)
|
||||
{
|
||||
if (n1.LowPart<n2)
|
||||
n1.HighPart--;
|
||||
n1.LowPart-=n2;
|
||||
}
|
||||
inline friend void operator ++ (Int64 &n)
|
||||
{
|
||||
if (++n.LowPart == 0)
|
||||
++n.HighPart;
|
||||
}
|
||||
inline friend void operator -- (Int64 &n)
|
||||
{
|
||||
if (n.LowPart-- == 0)
|
||||
n.HighPart--;
|
||||
}
|
||||
friend bool operator == (Int64 n1,Int64 n2);
|
||||
friend bool operator > (Int64 n1,Int64 n2);
|
||||
friend bool operator < (Int64 n1,Int64 n2);
|
||||
friend bool operator != (Int64 n1,Int64 n2);
|
||||
friend bool operator >= (Int64 n1,Int64 n2);
|
||||
friend bool operator <= (Int64 n1,Int64 n2);
|
||||
|
||||
void Set(uint HighPart,uint LowPart);
|
||||
uint GetLowPart() {return(LowPart);}
|
||||
|
||||
uint LowPart;
|
||||
uint HighPart;
|
||||
};
|
||||
|
||||
inline uint int64to32(Int64 n) {return(n.GetLowPart());}
|
||||
#define int32to64(high,low) (Int64((high),(low)))
|
||||
#define is64plus(x) ((int)(x).HighPart>=0)
|
||||
|
||||
#endif
|
||||
|
||||
#define INT64ERR int32to64(0x80000000,0)
|
||||
#define INT64MAX int32to64(0x7fffffff,0)
|
||||
|
||||
void itoa(Int64 n,char *Str);
|
||||
Int64 atoil(char *Str);
|
||||
|
||||
#endif
|
||||
6
7zip/Compress/Rar29/Original/isnt.hpp
Executable file
6
7zip/Compress/Rar29/Original/isnt.hpp
Executable file
@@ -0,0 +1,6 @@
|
||||
#ifndef _RAR_ISNT_
|
||||
#define _RAR_ISNT_
|
||||
|
||||
int WinNT();
|
||||
|
||||
#endif
|
||||
6
7zip/Compress/Rar29/Original/list.hpp
Executable file
6
7zip/Compress/Rar29/Original/list.hpp
Executable file
@@ -0,0 +1,6 @@
|
||||
#ifndef _RAR_LIST_
|
||||
#define _RAR_LIST_
|
||||
|
||||
void ListArchive(CommandData *Cmd);
|
||||
|
||||
#endif
|
||||
340
7zip/Compress/Rar29/Original/loclang.hpp
Executable file
340
7zip/Compress/Rar29/Original/loclang.hpp
Executable file
@@ -0,0 +1,340 @@
|
||||
#define MYesNo "_Yes_No"
|
||||
#define MYesNoAll "_Yes_No_All"
|
||||
#define MYesNoAllRenQ "_Yes_No_All_nEver_Rename_Quit"
|
||||
#define MContinueQuit "_Continue_Quit"
|
||||
#define MRetryAbort "_Retry_Abort"
|
||||
#define MCopyright "\nRAR %s Copyright (c) 1993-%d Alexander Roshal %d %s %d"
|
||||
#define MRegTo "\nRegistered to %s\n"
|
||||
#define MShare "\nShareware version Type RAR -? for help\n"
|
||||
#define MUCopyright "\nUNRAR %s freeware Copyright (c) 1993-%d Alexander Roshal\n"
|
||||
#define MBeta "beta"
|
||||
#define MMonthJan "Jan"
|
||||
#define MMonthFeb "Feb"
|
||||
#define MMonthMar "Mar"
|
||||
#define MMonthApr "Apr"
|
||||
#define MMonthMay "May"
|
||||
#define MMonthJun "Jun"
|
||||
#define MMonthJul "Jul"
|
||||
#define MMonthAug "Aug"
|
||||
#define MMonthSep "Sep"
|
||||
#define MMonthOct "Oct"
|
||||
#define MMonthNov "Nov"
|
||||
#define MMonthDec "Dec"
|
||||
#define MRARTitle1 "\nUsage: rar <command> -<switch 1> -<switch N> <archive> <files...>"
|
||||
#define MUNRARTitle1 "\nUsage: unrar <command> -<switch 1> -<switch N> <archive> <files...>"
|
||||
#define MRARTitle2 "\n <@listfiles...> <path_to_extract\\>"
|
||||
#define MCHelpCmd "\n\n<Commands>"
|
||||
#define MCHelpCmdA "\n a Add files to archive"
|
||||
#define MCHelpCmdC "\n c Add archive comment"
|
||||
#define MCHelpCmdCF "\n cf Add files comment"
|
||||
#define MCHelpCmdCW "\n cw Write archive comment to file"
|
||||
#define MCHelpCmdD "\n d Delete files from archive"
|
||||
#define MCHelpCmdE "\n e Extract files to current directory"
|
||||
#define MCHelpCmdF "\n f Freshen files in archive"
|
||||
#define MCHelpCmdI "\n i[par]=<str> Find string in archives"
|
||||
#define MCHelpCmdK "\n k Lock archive"
|
||||
#define MCHelpCmdL "\n l[t,b] List archive [technical, bare]"
|
||||
#define MCHelpCmdM "\n m[f] Move to archive [files only]"
|
||||
#define MCHelpCmdP "\n p Print file to stdout"
|
||||
#define MCHelpCmdR "\n r Repair archive"
|
||||
#define MCHelpCmdRC "\n rc Reconstruct missing volumes"
|
||||
#define MCHelpCmdRN "\n rn Rename archived files"
|
||||
#define MCHelpCmdRR "\n rr[N] Add data recovery record"
|
||||
#define MCHelpCmdRV "\n rv[N] Create recovery volumes"
|
||||
#define MCHelpCmdS "\n s[name|-] Convert archive to or from SFX"
|
||||
#define MCHelpCmdT "\n t Test archive files"
|
||||
#define MCHelpCmdU "\n u Update files in archive"
|
||||
#define MCHelpCmdV "\n v[t,b] Verbosely list archive [technical,bare]"
|
||||
#define MCHelpCmdX "\n x Extract files with full path"
|
||||
#define MCHelpSw "\n\n<Switches>"
|
||||
#define MCHelpSwm "\n - Stop switches scanning"
|
||||
#define MCHelpSwAC "\n ac Clear Archive attribute after compression or extraction"
|
||||
#define MCHelpSwAD "\n ad Append archive name to destination path"
|
||||
#define MCHelpSwAG "\n ag[format] Generate archive name using the current date"
|
||||
#define MCHelpSwAO "\n ao Add files with Archive attribute set"
|
||||
#define MCHelpSwAP "\n ap<path> Set path inside archive"
|
||||
#define MCHelpSwAS "\n as Synchronize archive contents"
|
||||
#define MCHelpSwAV "\n av Put authenticity verification (registered versions only)"
|
||||
#define MCHelpSwAVm "\n av- Disable authenticity verification check"
|
||||
#define MCHelpSwCm "\n c- Disable comments show"
|
||||
#define MCHelpSwCFGm "\n cfg- Disable read configuration"
|
||||
#define MCHelpSwCL "\n cl Convert names to lower case"
|
||||
#define MCHelpSwCU "\n cu Convert names to upper case"
|
||||
#define MCHelpSwDF "\n df Delete files after archiving"
|
||||
#define MCHelpSwDH "\n dh Open shared files"
|
||||
#define MCHelpSwDS "\n ds Disable name sort for solid archive"
|
||||
#define MCHelpSwEa "\n e[+]<attr> Set file exclude and include attributes"
|
||||
#define MCHelpSwED "\n ed Do not add empty directories"
|
||||
#define MCHelpSwEE "\n ee Do not save and extract extended attributes"
|
||||
#define MCHelpSwEN "\n en Do not put 'end of archive' block"
|
||||
#define MCHelpSwEP "\n ep Exclude paths from names"
|
||||
#define MCHelpSwEP1 "\n ep1 Exclude base directory from names"
|
||||
#define MCHelpSwEP2 "\n ep2 Expand paths to full"
|
||||
#define MCHelpSwEP3 "\n ep3 Expand paths to full including the drive letter"
|
||||
#define MCHelpSwF "\n f Freshen files"
|
||||
#define MCHelpSwHP "\n hp[password] Encrypt both file data and headers"
|
||||
#define MCHelpSwIDP "\n id[c,d,p,q] Disable messages"
|
||||
#define MCHelpSwIEML "\n ieml[addr] Send archive by email"
|
||||
#define MCHelpSwIERR "\n ierr Send all messages to stderr"
|
||||
#define MCHelpSwILOG "\n ilog[name] Log errors to file (registered versions only)"
|
||||
#define MCHelpSwINUL "\n inul Disable all messages"
|
||||
#define MCHelpSwIOFF "\n ioff Turn PC off after completing an operation"
|
||||
#define MCHelpSwISND "\n isnd Enable sound"
|
||||
#define MCHelpSwK "\n k Lock archive"
|
||||
#define MCHelpSwKB "\n kb Keep broken extracted files"
|
||||
#define MCHelpSwMn "\n m<0..5> Set compression level (0-store...3-default...5-maximal)"
|
||||
#define MCHelpSwMC "\n mc<par> Set advanced compression parameters"
|
||||
#define MCHelpSwMD "\n md<size> Dictionary size in KB (64,128,256,512,1024,2048,4096 or A-G)"
|
||||
#define MCHelpSwMS "\n ms[ext;ext] Specify file types to store"
|
||||
#define MCHelpSwN "\n n<file> Include only specified file"
|
||||
#define MCHelpSwNa "\n n@ Read file names to include from stdin"
|
||||
#define MCHelpSwNal "\n n@<list> Include files in specified list file"
|
||||
#define MCHelpSwOp "\n o+ Overwrite existing files"
|
||||
#define MCHelpSwOm "\n o- Do not overwrite existing files"
|
||||
#define MCHelpSwOC "\n oc Set NTFS Compressed attribute"
|
||||
#define MCHelpSwOL "\n ol Save symbolic links as the link instead of the file"
|
||||
#define MCHelpSwOS "\n os Save NTFS streams"
|
||||
#define MCHelpSwOW "\n ow Save or restore file owner and group"
|
||||
#define MCHelpSwP "\n p[password] Set password"
|
||||
#define MCHelpSwPm "\n p- Do not query password"
|
||||
#define MCHelpSwR "\n r Recurse subdirectories"
|
||||
#define MCHelpSwR0 "\n r0 Recurse subdirectories for wildcard names only"
|
||||
#define MCHelpSwRI "\n ri<P>[:<S>] Set priority (0-default,1-min..15-max) and sleep time in ms"
|
||||
#define MCHelpSwRR "\n rr[N] Add data recovery record"
|
||||
#define MCHelpSwRV "\n rv[N] Create recovery volumes"
|
||||
#define MCHelpSwS "\n s[<N>,v[-],e] Create solid archive"
|
||||
#define MCHelpSwSm "\n s- Disable solid archiving"
|
||||
#define MCHelpSwSFX "\n sfx[name] Create SFX archive"
|
||||
#define MCHelpSwSI "\n si[name] Read data from standard input (stdin)"
|
||||
#define MCHelpSwT "\n t Test files after archiving"
|
||||
#define MCHelpSwTK "\n tk Keep original archive time"
|
||||
#define MCHelpSwTL "\n tl Set archive time to latest file"
|
||||
#define MCHelpSwTN "\n tn<time> Process files newer than <time>"
|
||||
#define MCHelpSwTO "\n to<time> Process files older than <time>"
|
||||
#define MCHelpSwTA "\n ta<date> Process files modified after <date> in YYYYMMDDHHMMSS format"
|
||||
#define MCHelpSwTB "\n tb<date> Process files modified before <date> in YYYYMMDDHHMMSS format"
|
||||
#define MCHelpSwTS "\n ts<m,c,a>[N] Save or restore file time (modification, creation, access)"
|
||||
#define MCHelpSwU "\n u Update files"
|
||||
#define MCHelpSwV "\n v Create volumes with size autodetection or list all volumes"
|
||||
#define MCHelpSwVUnr "\n v List all volumes"
|
||||
#define MCHelpSwVn "\n v<size>[k,b] Create volumes with size=<size>*1000 [*1024, *1]"
|
||||
#define MCHelpSwVD "\n vd Erase disk contents before creating volume"
|
||||
#define MCHelpSwVER "\n ver[n] File version control"
|
||||
#define MCHelpSwVN "\n vn Use the old style volume naming scheme"
|
||||
#define MCHelpSwVP "\n vp Pause before each volume"
|
||||
#define MCHelpSwW "\n w<path> Assign work directory"
|
||||
#define MCHelpSwX "\n x<file> Exclude specified file"
|
||||
#define MCHelpSwXa "\n x@ Read file names to exclude from stdin"
|
||||
#define MCHelpSwXal "\n x@<list> Exclude files in specified list file"
|
||||
#define MCHelpSwY "\n y Assume Yes on all queries"
|
||||
#define MCHelpSwZ "\n z<file> Read archive comment from file"
|
||||
#define MBadArc "\nERROR: Bad archive %s\n"
|
||||
#define MAskPsw "Enter password (will not be echoed)"
|
||||
#define MAskPswEcho "Enter password"
|
||||
#define MReAskPsw "\nReenter password: "
|
||||
#define MFor " for "
|
||||
#define MNotMatchPsw "\nERROR: Passwords do not match\n"
|
||||
#define MErrWrite "Write error in the file %s"
|
||||
#define MErrRead "Read error in the file %s"
|
||||
#define MErrSeek "Seek error in the file %s"
|
||||
#define MErrFClose "Cannot close the file %s"
|
||||
#define MErrOutMem "Not enough memory"
|
||||
#define MErrBrokenArc "Corrupt archive - use 'Repair' command"
|
||||
#define MProgAborted "Program aborted"
|
||||
#define MErrRename "\nCannot rename %s to %s"
|
||||
#define MAbsNextVol "\nCannot find volume %s"
|
||||
#define MBreak "\nUser break\n"
|
||||
#define MAskCreatVol "\nCreate next volume ?"
|
||||
#define MAskNextDisk "\nDisk full. Insert next"
|
||||
#define MCreatVol "\n\nCreating %sarchive %s\n"
|
||||
#define MAskNextVol "\nInsert disk with %s"
|
||||
#define MTestVol "\n\nTesting archive %s\n"
|
||||
#define MExtrVol "\n\nExtracting from %s\n"
|
||||
#define MConverting "\nConverting %s"
|
||||
#define MCvtToSFX "\nConvert archives to SFX"
|
||||
#define MCvtFromSFX "\nRemoving SFX module"
|
||||
#define MNotSFX "\n%s is not SFX archive"
|
||||
#define MNotRAR "\n%s is not RAR archive"
|
||||
#define MNotFirstVol "\n%s is not the first volume"
|
||||
#define MCvtOldFormat "\n%s - cannot convert to SFX archive with old format"
|
||||
#define MCannotCreate "\nCannot create %s"
|
||||
#define MCannotOpen "\nCannot open %s"
|
||||
#define MUnknownMeth "\nUnknown method in %s"
|
||||
#define MVerRequired "\nYou need RAR %d.%d to unpack it"
|
||||
#define MOk " OK"
|
||||
#define MDone "\nDone"
|
||||
#define MLockingArc "\nLocking archive"
|
||||
#define MNotMdfOld "\n\nERROR: Cannot modify old format archive"
|
||||
#define MNotMdfLock "\n\nERROR: Locked archive"
|
||||
#define MNotMdfVol "\n\nERROR: Cannot modify volume"
|
||||
#define MVerifyAV "\nVerifying authenticity information ... "
|
||||
#define MFailedAV " Failed\n"
|
||||
#define MStrAV1 "\n\nArchive %s"
|
||||
#define MStrAV2 "\ncreated at %s"
|
||||
#define MStrAV3 "\nby %s\n"
|
||||
#define MLogFailedAV "Invalid authenticity information"
|
||||
#define MAddingAV "\nAdding authenticity verification "
|
||||
#define MAVOldStyle "\n\nOld style authenticity information"
|
||||
#define MPackAskReg "\nEvaluation copy. Please register.\n"
|
||||
#define MCreateArchive "\nCreating %sarchive %s\n"
|
||||
#define MUpdateArchive "\nUpdating %sarchive %s\n"
|
||||
#define MAddSolid "solid "
|
||||
#define MAddFile "\nAdding %-58s "
|
||||
#define MUpdFile "\nUpdating %-58s "
|
||||
#define MAddPoints "\n... %-58s "
|
||||
#define MCannotUpdPswSolid "\nERROR: Cannot update solid archives with password\n"
|
||||
#define MMoveDelFiles "\n\nDeleting files %s..."
|
||||
#define MMoveDelDirs "and directories"
|
||||
#define MMoveDelFile "\nDeleting %-30s"
|
||||
#define MMoveDeleted " deleted"
|
||||
#define MMoveNotDeleted " NOT DELETED"
|
||||
#define MClearAttrib "\n\nClearing attributes..."
|
||||
#define MMoveDelDir "\nDeleting directory %-30s"
|
||||
#define MWarErrFOpen "\nWARNING: Cannot open %d %s"
|
||||
#define MErrOpenFiles "files"
|
||||
#define MErrOpenFile "file"
|
||||
#define MAddNoFiles "\nWARNING: No files"
|
||||
#define MMdfEncrSol "\n%s: encrypted"
|
||||
#define MCannotMdfEncrSol "\nCannot modify solid archive containing encrypted files"
|
||||
#define MAddAnalyze "\nAnalyzing archived files: "
|
||||
#define MRepacking "\nRepacking archived files: "
|
||||
#define MCRCFailed "\n%-20s - CRC failed"
|
||||
#define MExtrTest "\n\nTesting archive %s\n"
|
||||
#define MExtracting "\n\nExtracting from %s\n"
|
||||
#define MUseCurPsw "\n%s - use current password ?"
|
||||
#define MCreatDir "\nCreating %-56s"
|
||||
#define MExtrSkipFile "\nSkipping %-56s"
|
||||
#define MExtrTestFile "\nTesting %-56s"
|
||||
#define MExtrFile "\nExtracting %-56s"
|
||||
#define MExtrPoints "\n... %-56s"
|
||||
#define MExtrErrMkDir "\nCannot create directory %s"
|
||||
#define MExtrPrinting "\n------ Printing %s\n\n"
|
||||
#define MEncrBadCRC "\nEncrypted file: CRC failed in %s (password incorrect ?)"
|
||||
#define MExtrNoFiles "\nNo files to extract"
|
||||
#define MExtrAllOk "\nAll OK"
|
||||
#define MExtrTotalErr "\nTotal errors: %ld"
|
||||
#define MFileExists "\n\n%s already exists. Overwrite it ?"
|
||||
#define MAskOverwrite "\nOverwrite %s ?"
|
||||
#define MAskNewName "\nEnter new name: "
|
||||
#define MLogMainHead "\nThe archive header is corrupt"
|
||||
#define MLogFileHead "\n%s - the file header is corrupt"
|
||||
#define MLogCommHead "\nThe comment header is corrupt\n"
|
||||
#define MLogProtectHead "The data recovery header is corrupt"
|
||||
#define MReadStdinCmt "\nReading comment from stdin\n"
|
||||
#define MReadCommFrom "\nReading comment from %s"
|
||||
#define MDelComment "\nDeleting comment from %s"
|
||||
#define MAddComment "\nAdding comment to %s"
|
||||
#define MFCommAdd "\nAdding file comments"
|
||||
#define MAskFComm "\n\nReading comment for %s : %s from stdin\n"
|
||||
#define MLogCommBrk "\nThe archive comment is corrupt"
|
||||
#define MCommAskCont "\nPress 'Enter' to continue or 'Q' to quit:"
|
||||
#define MLogBrokFCmt "\nThe file comment is corrupt"
|
||||
#define MAbsDestName "\nDestination file name required"
|
||||
#define MWriteCommTo "\nWrite comment to %s"
|
||||
#define MCommNotPres "\nComment is not present"
|
||||
#define MDelFrom "\nDeleting from %s"
|
||||
#define MDeleting "\nDeleting %s"
|
||||
#define MEraseArc "\nErasing empty archive %s"
|
||||
#define MNoDelFiles "\nNo files to delete"
|
||||
#define MLogTitle "\n\n-------- %2d %s %d, archive %s\n"
|
||||
#define MPathTooLong "\nERROR: Path too long\n"
|
||||
#define MListSolid "Solid "
|
||||
#define MListSFX "SFX "
|
||||
#define MListVol1 "volume"
|
||||
#define MListVol2 "Volume"
|
||||
#define MListArc1 "archive"
|
||||
#define MListArc2 "Archive"
|
||||
#define MListRecRec "\nRecovery record is present\n"
|
||||
#define MListLock "\nLock is present\n"
|
||||
#define MListPathComm "\nPathname/Comment\n "
|
||||
#define MListName "\n Name "
|
||||
#define MListTitle " Size Packed Ratio Date Time Attr CRC Meth Ver\n"
|
||||
#define MListTechTitle " Host OS Solid Old\n"
|
||||
#define MListEAHead "\n OS/2 extended attributes"
|
||||
#define MListUOHead "\n Unix Owner/Group data: %-14s %-14s"
|
||||
#define MListBeEAHead "\n BeOS extended attributes"
|
||||
#define MListNTACLHead "\n NTFS security data"
|
||||
#define MListStrmHead "\n NTFS stream: %s"
|
||||
#define MListUnkHead "\n Unknown subheader type: 0x%04x"
|
||||
#define MFileComment "\nComment: "
|
||||
#define MYes "Yes"
|
||||
#define MNo "No"
|
||||
#define MListNoFiles " 0 files\n"
|
||||
#define MRprReconstr "\nReconstructing %s"
|
||||
#define MRprBuild "\nBuilding %s"
|
||||
#define MRprOldFormat "\nCannot repair archive with old format"
|
||||
#define MRprFind "\nFound %s"
|
||||
#define MRprAskIsSol "\nThe archive header is corrupt. Mark archive as solid ?"
|
||||
#define MRprNoFiles "\nNo files found"
|
||||
#define MRprSuspEntry "\n\nSuspicious entry %s"
|
||||
#define MRprDir "\nDirectory"
|
||||
#define MRprSuspSize "\nSize %ld Packed %ld"
|
||||
#define MRprSuspAdd "\nAdd it to archive ?"
|
||||
#define MLogUnexpEOF "\nUnexpected end of archive"
|
||||
#define MRepAskReconst "\nReconstruct archive structure ?"
|
||||
#define MRecScanning "\nScanning..."
|
||||
#define MRecRNotFound "\nData recovery record not found"
|
||||
#define MRecRFound "\nData recovery record found"
|
||||
#define MRecSecDamage "\nSector %ld (offsets %lX...%lX) damaged"
|
||||
#define MRecCorrected " - data recovered"
|
||||
#define MRecFailed " - cannot recover data"
|
||||
#define MAddRecRec "\nAdding data recovery record"
|
||||
#define MEraseForVolume "\n\nErasing contents of drive %c:\n"
|
||||
#define MGetOwnersError "\nWARNING: Cannot get %s owner and group\n"
|
||||
#define MErrGetOwnerID "\nWARNING: Cannot get owner %s ID\n"
|
||||
#define MErrGetGroupID "\nWARNING: Cannot get group %s ID\n"
|
||||
#define MOwnersBroken "\nERROR: %s group and owner data are corrupt\n"
|
||||
#define MSetOwnersError "\nWARNING: Cannot set %s owner and group\n"
|
||||
#define MErrLnkRead "\nWARNING: Cannot read symbolic link %s"
|
||||
#define MErrCreateLnk "\nWARNING: Cannot create link %s"
|
||||
#define MSymLinkExists "\nWARNING: Symbolic link %s already exists"
|
||||
#define MAskRetryCreate "\nCannot create %s. Retry ?"
|
||||
#define MListMACHead1 "\n MacOS file type: %c%c%c%c ; "
|
||||
#define MListMACHead2 "file creator: %c%c%c%c\n"
|
||||
#define MDataBadCRC "\n%-20s : packed data CRC failed in volume %s"
|
||||
#define MFileRO "\n%s is read-only"
|
||||
#define MACLGetError "\nWARNING: Cannot get %s security data\n"
|
||||
#define MACLSetError "\nWARNING: Cannot set %s security data\n"
|
||||
#define MACLBroken "\nERROR: %s security data are corrupt\n"
|
||||
#define MACLUnknown "\nWARNING: Unknown format of %s security data\n"
|
||||
#define MStreamBroken "\nERROR: %s stream data are corrupt\n"
|
||||
#define MStreamUnknown "\nWARNING: Unknown format of %s stream data\n"
|
||||
#define MInvalidName "\nERROR: Invalid file name %s"
|
||||
#define MEABroken "\nERROR: %s extended attributes are corrupt\n"
|
||||
#define MEAUnknHeader "\nWARNING: %s - unknown format of extended attributes\n"
|
||||
#define MCannotSetEA "\nWARNING: cannot set extended attributes to %s\n"
|
||||
#define MCannotGetEA "\nERROR: Cannot get extended attributes of %s\n"
|
||||
#define MShowEA " (+EA)"
|
||||
#define MSkipEA "\n...skipping extended attributes"
|
||||
#define MProcessArc "\n\nProcessing archive %s"
|
||||
#define MSyncScanError "\nFile search errors, cannot synchronize archive"
|
||||
#define MCorrectingName "\nWARNING: Attempting to correct the invalid file name"
|
||||
#define MUnpCannotMerge "\nWARNING: You need to start extraction from a previous volume to unpack %s"
|
||||
#define MUnknownOption "\nERROR: Unknown option: %s"
|
||||
#define MSubHeadCorrupt "\nERROR: Corrupt data header found, ignored"
|
||||
#define MSubHeadUnknown "\nWARNING: Unknown data header format, ignored"
|
||||
#define MSubHeadDataCRC "\nERROR: Corrupt %s data block"
|
||||
#define MSubHeadType "\nData header type: %s"
|
||||
#define MScanError "\nCannot read contents of %s"
|
||||
#define MNotVolume "\n%s is not volume"
|
||||
#define MRecVolDiffSets "\nERROR: %s and %s belong to different sets"
|
||||
#define MRecVolMissing "\n%d volumes missing"
|
||||
#define MRecVolFound "\n%d recovery volumes found"
|
||||
#define MRecVolAllExist "\nNothing to reconstruct"
|
||||
#define MRecVolCannotFix "\nReconstruction impossible"
|
||||
#define MReconstructing "\nReconstructing..."
|
||||
#define MCreating "\nCreating %s"
|
||||
#define MRenaming "\nRenaming %s to %s"
|
||||
#define MNTFSRequired "\nWrite error: only NTFS file system supports files larger than 4 GB"
|
||||
#define MErrChangeAttr "\nWARNING: Cannot change attributes of %s"
|
||||
#define MWrongSFXVer "\nERROR: default SFX module does not support RAR %d.%d archives"
|
||||
#define MCannotEncName "\nCannot encrypt archive already contained encrypted files"
|
||||
#define MCannotEmail "\nCannot email the file %s"
|
||||
#define MCopyrightS "\nRAR SFX archive"
|
||||
#define MSHelpCmd "\n\n<Commands>"
|
||||
#define MSHelpCmdE "\n -x Extract from archive (default)"
|
||||
#define MSHelpCmdT "\n -t Test archive files"
|
||||
#define MSHelpCmdV "\n -v Verbosely list contents of archive"
|
||||
#define MMaxPathLimit "\nTotal path and file name length must not exceed %d characters"
|
||||
#define MRecVolLimit "\nTotal number of usual and recovery volumes must not exceed 255"
|
||||
#define MVolumeNumber "volume %d"
|
||||
18
7zip/Compress/Rar29/Original/log.hpp
Executable file
18
7zip/Compress/Rar29/Original/log.hpp
Executable file
@@ -0,0 +1,18 @@
|
||||
#ifndef _RAR_LOG_
|
||||
#define _RAR_LOG_
|
||||
|
||||
void InitLogOptions(char *LogName);
|
||||
|
||||
#ifndef SILENT
|
||||
void Log(const char *ArcName,const char *Format,...);
|
||||
#endif
|
||||
|
||||
#ifdef SILENT
|
||||
#ifdef __GNUC__
|
||||
#define Log(args...)
|
||||
#else
|
||||
inline void Log(const char *a,const char *b,const char *c=NULL,const char *d=NULL) {}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
16
7zip/Compress/Rar29/Original/match.hpp
Executable file
16
7zip/Compress/Rar29/Original/match.hpp
Executable file
@@ -0,0 +1,16 @@
|
||||
#ifndef _RAR_MATCH_
|
||||
#define _RAR_MATCH_
|
||||
|
||||
enum {MATCH_NAMES,MATCH_PATH,MATCH_EXACTPATH,MATCH_SUBPATH,MATCH_WILDSUBPATH};
|
||||
|
||||
#define MATCH_MODEMASK 0x0000ffff
|
||||
|
||||
bool CmpName(char *Wildcard,char *Name,int CmpPath);
|
||||
bool CmpName(wchar *Wildcard,wchar *Name,int CmpPath);
|
||||
|
||||
int stricompc(const char *Str1,const char *Str2);
|
||||
int stricompcw(const wchar *Str1,const wchar *Str2);
|
||||
int strnicompc(const char *Str1,const char *Str2,int N);
|
||||
int strnicompcw(const wchar *Str1,const wchar *Str2,int N);
|
||||
|
||||
#endif
|
||||
600
7zip/Compress/Rar29/Original/model.cpp
Executable file
600
7zip/Compress/Rar29/Original/model.cpp
Executable file
@@ -0,0 +1,600 @@
|
||||
/****************************************************************************
|
||||
* This file is part of PPMd project *
|
||||
* Written and distributed to public domain by Dmitry Shkarin 1997, *
|
||||
* 1999-2000 *
|
||||
* Contents: model description and encoding/decoding routines *
|
||||
****************************************************************************/
|
||||
|
||||
inline PPM_CONTEXT* PPM_CONTEXT::createChild(ModelPPM *Model,STATE* pStats,
|
||||
STATE& FirstState)
|
||||
{
|
||||
PPM_CONTEXT* pc = (PPM_CONTEXT*) Model->SubAlloc.AllocContext();
|
||||
if ( pc )
|
||||
{
|
||||
pc->NumStats=1;
|
||||
pc->OneState=FirstState;
|
||||
pc->Suffix=this;
|
||||
pStats->Successor=pc;
|
||||
}
|
||||
return pc;
|
||||
}
|
||||
|
||||
|
||||
ModelPPM::ModelPPM()
|
||||
{
|
||||
MinContext=NULL;
|
||||
MaxContext=NULL;
|
||||
MedContext=NULL;
|
||||
}
|
||||
|
||||
|
||||
void ModelPPM::RestartModelRare()
|
||||
{
|
||||
int i, k, m;
|
||||
memset(CharMask,0,sizeof(CharMask));
|
||||
SubAlloc.InitSubAllocator();
|
||||
InitRL=-(MaxOrder < 12 ? MaxOrder:12)-1;
|
||||
MinContext = MaxContext = (PPM_CONTEXT*) SubAlloc.AllocContext();
|
||||
MinContext->Suffix=NULL;
|
||||
OrderFall=MaxOrder;
|
||||
MinContext->U.SummFreq=(MinContext->NumStats=256)+1;
|
||||
FoundState=MinContext->U.Stats=(STATE*)SubAlloc.AllocUnits(256/2);
|
||||
for (RunLength=InitRL, PrevSuccess=i=0;i < 256;i++)
|
||||
{
|
||||
MinContext->U.Stats[i].Symbol=i;
|
||||
MinContext->U.Stats[i].Freq=1;
|
||||
MinContext->U.Stats[i].Successor=NULL;
|
||||
}
|
||||
|
||||
static const ushort InitBinEsc[]={
|
||||
0x3CDD,0x1F3F,0x59BF,0x48F3,0x64A1,0x5ABC,0x6632,0x6051
|
||||
};
|
||||
|
||||
for (i=0;i < 128;i++)
|
||||
for (k=0;k < 8;k++)
|
||||
for (m=0;m < 64;m += 8)
|
||||
BinSumm[i][k+m]=BIN_SCALE-InitBinEsc[k]/(i+2);
|
||||
for (i=0;i < 25;i++)
|
||||
for (k=0;k < 16;k++)
|
||||
SEE2Cont[i][k].init(5*i+10);
|
||||
}
|
||||
|
||||
|
||||
void ModelPPM::StartModelRare(int MaxOrder)
|
||||
{
|
||||
int i, k, m ,Step;
|
||||
EscCount=1;
|
||||
/*
|
||||
if (MaxOrder < 2)
|
||||
{
|
||||
memset(CharMask,0,sizeof(CharMask));
|
||||
OrderFall=ModelPPM::MaxOrder;
|
||||
MinContext=MaxContext;
|
||||
while (MinContext->Suffix != NULL)
|
||||
{
|
||||
MinContext=MinContext->Suffix;
|
||||
OrderFall--;
|
||||
}
|
||||
FoundState=MinContext->U.Stats;
|
||||
MinContext=MaxContext;
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
ModelPPM::MaxOrder=MaxOrder;
|
||||
RestartModelRare();
|
||||
NS2BSIndx[0]=2*0;
|
||||
NS2BSIndx[1]=2*1;
|
||||
memset(NS2BSIndx+2,2*2,9);
|
||||
memset(NS2BSIndx+11,2*3,256-11);
|
||||
for (i=0;i < 3;i++)
|
||||
NS2Indx[i]=i;
|
||||
for (m=i, k=Step=1;i < 256;i++)
|
||||
{
|
||||
NS2Indx[i]=m;
|
||||
if ( !--k )
|
||||
{
|
||||
k = ++Step;
|
||||
m++;
|
||||
}
|
||||
}
|
||||
memset(HB2Flag,0,0x40);
|
||||
memset(HB2Flag+0x40,0x08,0x100-0x40);
|
||||
DummySEE2Cont.Shift=PERIOD_BITS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PPM_CONTEXT::rescale(ModelPPM *Model)
|
||||
{
|
||||
int OldNS=NumStats, i=NumStats-1, Adder, EscFreq;
|
||||
STATE* p1, * p;
|
||||
for (p=Model->FoundState;p != U.Stats;p--)
|
||||
_PPMD_SWAP(p[0],p[-1]);
|
||||
U.Stats->Freq += 4;
|
||||
U.SummFreq += 4;
|
||||
EscFreq=U.SummFreq-p->Freq;
|
||||
Adder=(Model->OrderFall != 0);
|
||||
U.SummFreq = (p->Freq=(p->Freq+Adder) >> 1);
|
||||
do
|
||||
{
|
||||
EscFreq -= (++p)->Freq;
|
||||
U.SummFreq += (p->Freq=(p->Freq+Adder) >> 1);
|
||||
if (p[0].Freq > p[-1].Freq)
|
||||
{
|
||||
STATE tmp=*(p1=p);
|
||||
do
|
||||
{
|
||||
p1[0]=p1[-1];
|
||||
} while (--p1 != U.Stats && tmp.Freq > p1[-1].Freq);
|
||||
*p1=tmp;
|
||||
}
|
||||
} while ( --i );
|
||||
if (p->Freq == 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
i++;
|
||||
} while ((--p)->Freq == 0);
|
||||
EscFreq += i;
|
||||
if ((NumStats -= i) == 1)
|
||||
{
|
||||
STATE tmp=*U.Stats;
|
||||
do
|
||||
{
|
||||
tmp.Freq-=(tmp.Freq >> 1);
|
||||
EscFreq>>=1;
|
||||
} while (EscFreq > 1);
|
||||
Model->SubAlloc.FreeUnits(U.Stats,(OldNS+1) >> 1);
|
||||
*(Model->FoundState=&OneState)=tmp; return;
|
||||
}
|
||||
}
|
||||
U.SummFreq += (EscFreq -= (EscFreq >> 1));
|
||||
int n0=(OldNS+1) >> 1, n1=(NumStats+1) >> 1;
|
||||
if (n0 != n1)
|
||||
U.Stats = (STATE*) Model->SubAlloc.ShrinkUnits(U.Stats,n0,n1);
|
||||
Model->FoundState=U.Stats;
|
||||
}
|
||||
|
||||
|
||||
inline PPM_CONTEXT* ModelPPM::CreateSuccessors(bool Skip,STATE* p1)
|
||||
{
|
||||
#ifdef __ICL
|
||||
static
|
||||
#endif
|
||||
STATE UpState;
|
||||
PPM_CONTEXT* pc=MinContext, * UpBranch=FoundState->Successor;
|
||||
STATE * p, * ps[MAX_O], ** pps=ps;
|
||||
if ( !Skip )
|
||||
{
|
||||
*pps++ = FoundState;
|
||||
if ( !pc->Suffix )
|
||||
goto NO_LOOP;
|
||||
}
|
||||
if ( p1 )
|
||||
{
|
||||
p=p1;
|
||||
pc=pc->Suffix;
|
||||
goto LOOP_ENTRY;
|
||||
}
|
||||
do
|
||||
{
|
||||
pc=pc->Suffix;
|
||||
if (pc->NumStats != 1)
|
||||
{
|
||||
if ((p=pc->U.Stats)->Symbol != FoundState->Symbol)
|
||||
do
|
||||
{
|
||||
p++;
|
||||
} while (p->Symbol != FoundState->Symbol);
|
||||
}
|
||||
else
|
||||
p=&(pc->OneState);
|
||||
LOOP_ENTRY:
|
||||
if (p->Successor != UpBranch)
|
||||
{
|
||||
pc=p->Successor;
|
||||
break;
|
||||
}
|
||||
*pps++ = p;
|
||||
} while ( pc->Suffix );
|
||||
NO_LOOP:
|
||||
if (pps == ps)
|
||||
return pc;
|
||||
UpState.Symbol=*(byte*) UpBranch;
|
||||
UpState.Successor=(PPM_CONTEXT*) (((byte*) UpBranch)+1);
|
||||
if (pc->NumStats != 1)
|
||||
{
|
||||
if ((byte*) pc <= SubAlloc.pText)
|
||||
return(NULL);
|
||||
if ((p=pc->U.Stats)->Symbol != UpState.Symbol)
|
||||
do
|
||||
{
|
||||
p++;
|
||||
} while (p->Symbol != UpState.Symbol);
|
||||
uint cf=p->Freq-1;
|
||||
uint s0=pc->U.SummFreq-pc->NumStats-cf;
|
||||
UpState.Freq=1+((2*cf <= s0)?(5*cf > s0):((2*cf+3*s0-1)/(2*s0)));
|
||||
}
|
||||
else
|
||||
UpState.Freq=pc->OneState.Freq;
|
||||
do
|
||||
{
|
||||
pc = pc->createChild(this,*--pps,UpState);
|
||||
if ( !pc )
|
||||
return NULL;
|
||||
} while (pps != ps);
|
||||
return pc;
|
||||
}
|
||||
|
||||
|
||||
inline void ModelPPM::UpdateModel()
|
||||
{
|
||||
STATE fs = *FoundState, *p = NULL;
|
||||
PPM_CONTEXT *pc, *Successor;
|
||||
uint ns1, ns, cf, sf, s0;
|
||||
if (fs.Freq < MAX_FREQ/4 && (pc=MinContext->Suffix) != NULL)
|
||||
{
|
||||
if (pc->NumStats != 1)
|
||||
{
|
||||
if ((p=pc->U.Stats)->Symbol != fs.Symbol)
|
||||
{
|
||||
do
|
||||
{
|
||||
p++;
|
||||
} while (p->Symbol != fs.Symbol);
|
||||
if (p[0].Freq >= p[-1].Freq)
|
||||
{
|
||||
_PPMD_SWAP(p[0],p[-1]);
|
||||
p--;
|
||||
}
|
||||
}
|
||||
if (p->Freq < MAX_FREQ-9)
|
||||
{
|
||||
p->Freq += 2;
|
||||
pc->U.SummFreq += 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p=&(pc->OneState);
|
||||
p->Freq += (p->Freq < 32);
|
||||
}
|
||||
}
|
||||
if ( !OrderFall )
|
||||
{
|
||||
MinContext=MaxContext=FoundState->Successor=CreateSuccessors(TRUE,p);
|
||||
if ( !MinContext )
|
||||
goto RESTART_MODEL;
|
||||
return;
|
||||
}
|
||||
*SubAlloc.pText++ = fs.Symbol;
|
||||
Successor = (PPM_CONTEXT*) SubAlloc.pText;
|
||||
if (SubAlloc.pText >= SubAlloc.FakeUnitsStart)
|
||||
goto RESTART_MODEL;
|
||||
if ( fs.Successor )
|
||||
{
|
||||
if ((byte*) fs.Successor <= SubAlloc.pText &&
|
||||
(fs.Successor=CreateSuccessors(FALSE,p)) == NULL)
|
||||
goto RESTART_MODEL;
|
||||
if ( !--OrderFall )
|
||||
{
|
||||
Successor=fs.Successor;
|
||||
SubAlloc.pText -= (MaxContext != MinContext);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FoundState->Successor=Successor;
|
||||
fs.Successor=MinContext;
|
||||
}
|
||||
s0=MinContext->U.SummFreq-(ns=MinContext->NumStats)-(fs.Freq-1);
|
||||
for (pc=MaxContext;pc != MinContext;pc=pc->Suffix)
|
||||
{
|
||||
if ((ns1=pc->NumStats) != 1)
|
||||
{
|
||||
if ((ns1 & 1) == 0)
|
||||
{
|
||||
pc->U.Stats=(STATE*) SubAlloc.ExpandUnits(pc->U.Stats,ns1 >> 1);
|
||||
if ( !pc->U.Stats )
|
||||
goto RESTART_MODEL;
|
||||
}
|
||||
pc->U.SummFreq += (2*ns1 < ns)+2*((4*ns1 <= ns) & (pc->U.SummFreq <= 8*ns1));
|
||||
}
|
||||
else
|
||||
{
|
||||
p=(STATE*) SubAlloc.AllocUnits(1);
|
||||
if ( !p )
|
||||
goto RESTART_MODEL;
|
||||
*p=pc->OneState;
|
||||
pc->U.Stats=p;
|
||||
if (p->Freq < MAX_FREQ/4-1)
|
||||
p->Freq += p->Freq;
|
||||
else
|
||||
p->Freq = MAX_FREQ-4;
|
||||
pc->U.SummFreq=p->Freq+InitEsc+(ns > 3);
|
||||
}
|
||||
cf=2*fs.Freq*(pc->U.SummFreq+6);
|
||||
sf=s0+pc->U.SummFreq;
|
||||
if (cf < 6*sf)
|
||||
{
|
||||
cf=1+(cf > sf)+(cf >= 4*sf);
|
||||
pc->U.SummFreq += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
cf=4+(cf >= 9*sf)+(cf >= 12*sf)+(cf >= 15*sf);
|
||||
pc->U.SummFreq += cf;
|
||||
}
|
||||
p=pc->U.Stats+ns1;
|
||||
p->Successor=Successor;
|
||||
p->Symbol = fs.Symbol;
|
||||
p->Freq = cf;
|
||||
pc->NumStats=++ns1;
|
||||
}
|
||||
MaxContext=MinContext=fs.Successor;
|
||||
return;
|
||||
RESTART_MODEL:
|
||||
RestartModelRare();
|
||||
EscCount=0;
|
||||
}
|
||||
|
||||
|
||||
// Tabulated escapes for exponential symbol distribution
|
||||
static const byte ExpEscape[16]={ 25,14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };
|
||||
#define GET_MEAN(SUMM,SHIFT,ROUND) ((SUMM+(1 << (SHIFT-ROUND))) >> (SHIFT))
|
||||
|
||||
|
||||
|
||||
inline void PPM_CONTEXT::decodeBinSymbol(ModelPPM *Model)
|
||||
{
|
||||
STATE& rs=OneState;
|
||||
Model->HiBitsFlag=Model->HB2Flag[Model->FoundState->Symbol];
|
||||
ushort& bs=Model->BinSumm[rs.Freq-1][Model->PrevSuccess+
|
||||
Model->NS2BSIndx[Suffix->NumStats-1]+
|
||||
Model->HiBitsFlag+2*Model->HB2Flag[rs.Symbol]+
|
||||
((Model->RunLength >> 26) & 0x20)];
|
||||
if (Model->Coder.GetCurrentShiftCount(TOT_BITS) < bs)
|
||||
{
|
||||
Model->FoundState=&rs;
|
||||
rs.Freq += (rs.Freq < 128);
|
||||
Model->Coder.SubRange.LowCount=0;
|
||||
Model->Coder.SubRange.HighCount=bs;
|
||||
bs = SHORT16(bs+INTERVAL-GET_MEAN(bs,PERIOD_BITS,2));
|
||||
Model->PrevSuccess=1;
|
||||
Model->RunLength++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Model->Coder.SubRange.LowCount=bs;
|
||||
bs = SHORT16(bs-GET_MEAN(bs,PERIOD_BITS,2));
|
||||
Model->Coder.SubRange.HighCount=BIN_SCALE;
|
||||
Model->InitEsc=ExpEscape[bs >> 10];
|
||||
Model->NumMasked=1;
|
||||
Model->CharMask[rs.Symbol]=Model->EscCount;
|
||||
Model->PrevSuccess=0;
|
||||
Model->FoundState=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void PPM_CONTEXT::update1(ModelPPM *Model,STATE* p)
|
||||
{
|
||||
(Model->FoundState=p)->Freq += 4;
|
||||
U.SummFreq += 4;
|
||||
if (p[0].Freq > p[-1].Freq)
|
||||
{
|
||||
_PPMD_SWAP(p[0],p[-1]);
|
||||
Model->FoundState=--p;
|
||||
if (p->Freq > MAX_FREQ)
|
||||
rescale(Model);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline bool PPM_CONTEXT::decodeSymbol1(ModelPPM *Model)
|
||||
{
|
||||
Model->Coder.SubRange.scale=U.SummFreq;
|
||||
STATE* p=U.Stats;
|
||||
int i, HiCnt;
|
||||
int count=Model->Coder.GetCurrentCount();
|
||||
if (count>=Model->Coder.SubRange.scale)
|
||||
return(false);
|
||||
if (count < (HiCnt=p->Freq))
|
||||
{
|
||||
Model->PrevSuccess=(2*(Model->Coder.SubRange.HighCount=HiCnt) > Model->Coder.SubRange.scale);
|
||||
Model->RunLength += Model->PrevSuccess;
|
||||
(Model->FoundState=p)->Freq=(HiCnt += 4);
|
||||
U.SummFreq += 4;
|
||||
if (HiCnt > MAX_FREQ)
|
||||
rescale(Model);
|
||||
Model->Coder.SubRange.LowCount=0;
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
if (Model->FoundState==NULL)
|
||||
return(false);
|
||||
Model->PrevSuccess=0;
|
||||
i=NumStats-1;
|
||||
while ((HiCnt += (++p)->Freq) <= count)
|
||||
if (--i == 0)
|
||||
{
|
||||
Model->HiBitsFlag=Model->HB2Flag[Model->FoundState->Symbol];
|
||||
Model->Coder.SubRange.LowCount=HiCnt;
|
||||
Model->CharMask[p->Symbol]=Model->EscCount;
|
||||
i=(Model->NumMasked=NumStats)-1;
|
||||
Model->FoundState=NULL;
|
||||
do
|
||||
{
|
||||
Model->CharMask[(--p)->Symbol]=Model->EscCount;
|
||||
} while ( --i );
|
||||
Model->Coder.SubRange.HighCount=Model->Coder.SubRange.scale;
|
||||
return(true);
|
||||
}
|
||||
Model->Coder.SubRange.LowCount=(Model->Coder.SubRange.HighCount=HiCnt)-p->Freq;
|
||||
update1(Model,p);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
inline void PPM_CONTEXT::update2(ModelPPM *Model,STATE* p)
|
||||
{
|
||||
(Model->FoundState=p)->Freq += 4;
|
||||
U.SummFreq += 4;
|
||||
if (p->Freq > MAX_FREQ)
|
||||
rescale(Model);
|
||||
Model->EscCount++;
|
||||
Model->RunLength=Model->InitRL;
|
||||
}
|
||||
|
||||
|
||||
inline SEE2_CONTEXT* PPM_CONTEXT::makeEscFreq2(ModelPPM *Model,int Diff)
|
||||
{
|
||||
SEE2_CONTEXT* psee2c;
|
||||
if (NumStats != 256)
|
||||
{
|
||||
psee2c=Model->SEE2Cont[Model->NS2Indx[Diff-1]]+
|
||||
(Diff < Suffix->NumStats-NumStats)+
|
||||
2*(U.SummFreq < 11*NumStats)+4*(Model->NumMasked > Diff)+
|
||||
Model->HiBitsFlag;
|
||||
Model->Coder.SubRange.scale=psee2c->getMean();
|
||||
}
|
||||
else
|
||||
{
|
||||
psee2c=&Model->DummySEE2Cont;
|
||||
Model->Coder.SubRange.scale=1;
|
||||
}
|
||||
return psee2c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline bool PPM_CONTEXT::decodeSymbol2(ModelPPM *Model)
|
||||
{
|
||||
int count, HiCnt, i=NumStats-Model->NumMasked;
|
||||
SEE2_CONTEXT* psee2c=makeEscFreq2(Model,i);
|
||||
STATE* ps[256], ** pps=ps, * p=U.Stats-1;
|
||||
HiCnt=0;
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
p++;
|
||||
} while (Model->CharMask[p->Symbol] == Model->EscCount);
|
||||
HiCnt += p->Freq;
|
||||
*pps++ = p;
|
||||
} while ( --i );
|
||||
Model->Coder.SubRange.scale += HiCnt;
|
||||
count=Model->Coder.GetCurrentCount();
|
||||
if (count>=Model->Coder.SubRange.scale)
|
||||
return(false);
|
||||
p=*(pps=ps);
|
||||
if (count < HiCnt)
|
||||
{
|
||||
HiCnt=0;
|
||||
while ((HiCnt += p->Freq) <= count)
|
||||
p=*++pps;
|
||||
Model->Coder.SubRange.LowCount = (Model->Coder.SubRange.HighCount=HiCnt)-p->Freq;
|
||||
psee2c->update();
|
||||
update2(Model,p);
|
||||
}
|
||||
else
|
||||
{
|
||||
Model->Coder.SubRange.LowCount=HiCnt;
|
||||
Model->Coder.SubRange.HighCount=Model->Coder.SubRange.scale;
|
||||
i=NumStats-Model->NumMasked;
|
||||
pps--;
|
||||
do
|
||||
{
|
||||
Model->CharMask[(*++pps)->Symbol]=Model->EscCount;
|
||||
} while ( --i );
|
||||
psee2c->Summ += Model->Coder.SubRange.scale;
|
||||
Model->NumMasked = NumStats;
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
inline void ModelPPM::ClearMask()
|
||||
{
|
||||
EscCount=1;
|
||||
memset(CharMask,0,sizeof(CharMask));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool ModelPPM::DecodeInit(Unpack *UnpackRead,int &EscChar)
|
||||
{
|
||||
int MaxOrder=UnpackRead->GetChar();
|
||||
|
||||
// Igor Pavlov
|
||||
bool Reset = ((MaxOrder & 0x20) != 0);
|
||||
|
||||
int MaxMB;
|
||||
if (Reset)
|
||||
MaxMB=UnpackRead->GetChar();
|
||||
else
|
||||
if (SubAlloc.GetAllocatedMemory()==0)
|
||||
return(false);
|
||||
if (MaxOrder & 0x40)
|
||||
EscChar=UnpackRead->GetChar();
|
||||
Coder.InitDecoder(UnpackRead);
|
||||
if (Reset)
|
||||
{
|
||||
MaxOrder=(MaxOrder & 0x1f)+1;
|
||||
if (MaxOrder>16)
|
||||
MaxOrder=16+(MaxOrder-16)*3;
|
||||
if (MaxOrder==1)
|
||||
{
|
||||
SubAlloc.StopSubAllocator();
|
||||
return(false);
|
||||
}
|
||||
SubAlloc.StartSubAllocator(MaxMB+1);
|
||||
StartModelRare(MaxOrder);
|
||||
}
|
||||
return(MinContext!=NULL);
|
||||
}
|
||||
|
||||
|
||||
int ModelPPM::DecodeChar()
|
||||
{
|
||||
if ((byte*)MinContext <= SubAlloc.pText || (byte*)MinContext>SubAlloc.HeapEnd)
|
||||
return(-1);
|
||||
if (MinContext->NumStats != 1)
|
||||
{
|
||||
if (!MinContext->decodeSymbol1(this))
|
||||
return(-1);
|
||||
}
|
||||
else
|
||||
MinContext->decodeBinSymbol(this);
|
||||
Coder.Decode();
|
||||
while ( !FoundState )
|
||||
{
|
||||
ARI_DEC_NORMALIZE(Coder.code,Coder.low,Coder.range,Coder.UnpackRead);
|
||||
do
|
||||
{
|
||||
OrderFall++;
|
||||
MinContext=MinContext->Suffix;
|
||||
if ((byte*)MinContext <= SubAlloc.pText || (byte*)MinContext>SubAlloc.HeapEnd)
|
||||
return(-1);
|
||||
} while (MinContext->NumStats == NumMasked);
|
||||
if (!MinContext->decodeSymbol2(this))
|
||||
return(-1);
|
||||
Coder.Decode();
|
||||
}
|
||||
int Symbol=FoundState->Symbol;
|
||||
if (!OrderFall && (byte*) FoundState->Successor > SubAlloc.pText)
|
||||
MinContext=MaxContext=FoundState->Successor;
|
||||
else
|
||||
{
|
||||
UpdateModel();
|
||||
if (EscCount == 0)
|
||||
ClearMask();
|
||||
}
|
||||
ARI_DEC_NORMALIZE(Coder.code,Coder.low,Coder.range,Coder.UnpackRead);
|
||||
return(Symbol);
|
||||
}
|
||||
126
7zip/Compress/Rar29/Original/model.hpp
Executable file
126
7zip/Compress/Rar29/Original/model.hpp
Executable file
@@ -0,0 +1,126 @@
|
||||
#ifndef _RAR_PPMMODEL_
|
||||
#define _RAR_PPMMODEL_
|
||||
|
||||
#include "coder.hpp"
|
||||
#include "suballoc.hpp"
|
||||
|
||||
const int MAX_O=64; /* maximum allowed model order */
|
||||
|
||||
const int INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS,
|
||||
INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124;
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
struct SEE2_CONTEXT
|
||||
{ // SEE-contexts for PPM-contexts with masked symbols
|
||||
ushort Summ;
|
||||
byte Shift, Count;
|
||||
void init(int InitVal)
|
||||
{
|
||||
Summ=InitVal << (Shift=PERIOD_BITS-4);
|
||||
Count=4;
|
||||
}
|
||||
uint getMean()
|
||||
{
|
||||
uint RetVal=SHORT16(Summ) >> Shift;
|
||||
Summ -= RetVal;
|
||||
return RetVal+(RetVal == 0);
|
||||
}
|
||||
void update()
|
||||
{
|
||||
if (Shift < PERIOD_BITS && --Count == 0)
|
||||
{
|
||||
Summ += Summ;
|
||||
Count=3 << Shift++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class ModelPPM;
|
||||
struct PPM_CONTEXT;
|
||||
|
||||
struct STATE
|
||||
{
|
||||
byte Symbol;
|
||||
byte Freq;
|
||||
PPM_CONTEXT* Successor;
|
||||
};
|
||||
|
||||
struct FreqData
|
||||
{
|
||||
ushort SummFreq;
|
||||
STATE _PACK_ATTR * Stats;
|
||||
};
|
||||
|
||||
struct PPM_CONTEXT
|
||||
{
|
||||
ushort NumStats;
|
||||
union
|
||||
{
|
||||
FreqData U;
|
||||
STATE OneState;
|
||||
};
|
||||
|
||||
PPM_CONTEXT* Suffix;
|
||||
inline void encodeBinSymbol(ModelPPM *Model,int symbol); // MaxOrder:
|
||||
inline void encodeSymbol1(ModelPPM *Model,int symbol); // ABCD context
|
||||
inline void encodeSymbol2(ModelPPM *Model,int symbol); // BCD suffix
|
||||
inline void decodeBinSymbol(ModelPPM *Model); // BCDE successor
|
||||
inline bool decodeSymbol1(ModelPPM *Model); // other orders:
|
||||
inline bool decodeSymbol2(ModelPPM *Model); // BCD context
|
||||
inline void update1(ModelPPM *Model,STATE* p); // CD suffix
|
||||
inline void update2(ModelPPM *Model,STATE* p); // BCDE successor
|
||||
void rescale(ModelPPM *Model);
|
||||
inline PPM_CONTEXT* createChild(ModelPPM *Model,STATE* pStats,STATE& FirstState);
|
||||
inline SEE2_CONTEXT* makeEscFreq2(ModelPPM *Model,int Diff);
|
||||
};
|
||||
#ifdef _AIX
|
||||
#pragma pack(pop)
|
||||
#else
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
const uint UNIT_SIZE=sizeof(PPM_CONTEXT);
|
||||
const uint FIXED_UNIT_SIZE=12;
|
||||
|
||||
/*
|
||||
inline PPM_CONTEXT::PPM_CONTEXT(STATE* pStats,PPM_CONTEXT* ShorterContext):
|
||||
NumStats(1), Suffix(ShorterContext) { pStats->Successor=this; }
|
||||
inline PPM_CONTEXT::PPM_CONTEXT(): NumStats(0) {}
|
||||
*/
|
||||
|
||||
template <class T>
|
||||
inline void _PPMD_SWAP(T& t1,T& t2) { T tmp=t1; t1=t2; t2=tmp; }
|
||||
|
||||
|
||||
class ModelPPM
|
||||
{
|
||||
private:
|
||||
friend struct PPM_CONTEXT;
|
||||
|
||||
_PACK_ATTR SEE2_CONTEXT SEE2Cont[25][16], DummySEE2Cont;
|
||||
|
||||
struct PPM_CONTEXT *MinContext, *MedContext, *MaxContext;
|
||||
STATE* FoundState; // found next state transition
|
||||
int NumMasked, InitEsc, OrderFall, MaxOrder, RunLength, InitRL;
|
||||
byte CharMask[256], NS2Indx[256], NS2BSIndx[256], HB2Flag[256];
|
||||
byte EscCount, PrevSuccess, HiBitsFlag;
|
||||
ushort BinSumm[128][64]; // binary SEE-contexts
|
||||
|
||||
RangeCoder Coder;
|
||||
SubAllocator SubAlloc;
|
||||
|
||||
void RestartModelRare();
|
||||
void StartModelRare(int MaxOrder);
|
||||
inline PPM_CONTEXT* CreateSuccessors(bool Skip,STATE* p1);
|
||||
|
||||
inline void UpdateModel();
|
||||
inline void ClearMask();
|
||||
public:
|
||||
ModelPPM();
|
||||
bool DecodeInit(Unpack *UnpackRead,int &EscChar);
|
||||
int DecodeChar();
|
||||
};
|
||||
|
||||
#endif
|
||||
129
7zip/Compress/Rar29/Original/options.hpp
Executable file
129
7zip/Compress/Rar29/Original/options.hpp
Executable file
@@ -0,0 +1,129 @@
|
||||
#ifndef _RAR_OPTIONS_
|
||||
#define _RAR_OPTIONS_
|
||||
|
||||
#define DEFAULT_RECOVERY -1
|
||||
|
||||
#define DEFAULT_RECVOLUMES -10
|
||||
|
||||
enum PathExclMode {
|
||||
EXCL_NONE,EXCL_BASEPATH,EXCL_SKIPWHOLEPATH,EXCL_SAVEFULLPATH,
|
||||
EXCL_SKIPABSPATH,EXCL_ABSPATH
|
||||
};
|
||||
enum {SOLID_NONE=0,SOLID_NORMAL=1,SOLID_COUNT=2,SOLID_FILEEXT=4,
|
||||
SOLID_VOLUME_DEPENDENT=8,SOLID_VOLUME_INDEPENDENT=16};
|
||||
enum {ARCTIME_NONE,ARCTIME_KEEP,ARCTIME_LATEST};
|
||||
enum EXTTIME_MODE {
|
||||
EXTTIME_NONE,EXTTIME_1S,EXTTIME_HIGH1,EXTTIME_HIGH2,EXTTIME_HIGH3
|
||||
};
|
||||
enum {NAMES_ORIGINALCASE,NAMES_UPPERCASE,NAMES_LOWERCASE};
|
||||
enum MESSAGE_TYPE {MSG_STDOUT,MSG_STDERR,MSG_ERRONLY,MSG_NULL};
|
||||
enum OVERWRITE_MODE { OVERWRITE_ASK,OVERWRITE_ALL,OVERWRITE_NONE};
|
||||
|
||||
#define MAX_FILTERS 16
|
||||
enum FilterState {FILTER_DEFAULT=0,FILTER_AUTO,FILTER_FORCE,FILTER_DISABLE};
|
||||
|
||||
|
||||
struct FilterMode
|
||||
{
|
||||
FilterState State;
|
||||
int Param1;
|
||||
int Param2;
|
||||
};
|
||||
|
||||
|
||||
class RAROptions
|
||||
{
|
||||
public:
|
||||
RAROptions();
|
||||
~RAROptions();
|
||||
void Init();
|
||||
|
||||
uint ExclFileAttr;
|
||||
uint InclFileAttr;
|
||||
bool InclAttrSet;
|
||||
uint WinSize;
|
||||
char TempPath[NM];
|
||||
char SFXModule[NM];
|
||||
char ExtrPath[NM];
|
||||
wchar ExtrPathW[NM];
|
||||
char CommentFile[NM];
|
||||
char ArcPath[NM];
|
||||
char Password[MAXPASSWORD];
|
||||
bool EncryptHeaders;
|
||||
char LogName[NM];
|
||||
MESSAGE_TYPE MsgStream;
|
||||
bool Sound;
|
||||
OVERWRITE_MODE Overwrite;
|
||||
int Method;
|
||||
int Recovery;
|
||||
int RecVolNumber;
|
||||
bool DisablePercentage;
|
||||
bool DisableCopyright;
|
||||
bool DisableDone;
|
||||
int Solid;
|
||||
int SolidCount;
|
||||
bool ClearArc;
|
||||
bool AddArcOnly;
|
||||
bool AV;
|
||||
bool DisableComment;
|
||||
bool FreshFiles;
|
||||
bool UpdateFiles;
|
||||
PathExclMode ExclPath;
|
||||
int Recurse;
|
||||
Int64 VolSize;
|
||||
Array<Int64> NextVolSizes;
|
||||
int CurVolNum;
|
||||
bool AllYes;
|
||||
bool DisableViewAV;
|
||||
bool DisableSortSolid;
|
||||
int ArcTime;
|
||||
int ConvertNames;
|
||||
bool ProcessOwners;
|
||||
bool SaveLinks;
|
||||
int Priority;
|
||||
int SleepTime;
|
||||
bool KeepBroken;
|
||||
bool EraseDisk;
|
||||
bool OpenShared;
|
||||
bool ExclEmptyDir;
|
||||
bool DeleteFiles;
|
||||
bool SyncFiles;
|
||||
bool GenerateArcName;
|
||||
char GenerateMask[80];
|
||||
bool ProcessEA;
|
||||
bool SaveStreams;
|
||||
bool SetCompressedAttr;
|
||||
uint FileTimeOlder;
|
||||
uint FileTimeNewer;
|
||||
RarTime FileTimeBefore;
|
||||
RarTime FileTimeAfter;
|
||||
bool OldNumbering;
|
||||
bool Lock;
|
||||
bool Test;
|
||||
bool VolumePause;
|
||||
FilterMode FilterModes[MAX_FILTERS];
|
||||
char EmailTo[NM];
|
||||
int VersionControl;
|
||||
bool NoEndBlock;
|
||||
bool AppendArcNameToPath;
|
||||
bool Shutdown;
|
||||
EXTTIME_MODE xmtime;
|
||||
EXTTIME_MODE xctime;
|
||||
EXTTIME_MODE xatime;
|
||||
EXTTIME_MODE xarctime;
|
||||
char CompressStdin[NM];
|
||||
|
||||
|
||||
|
||||
#ifdef RARDLL
|
||||
char DllDestName[NM];
|
||||
wchar DllDestNameW[NM];
|
||||
int DllOpMode;
|
||||
int DllError;
|
||||
LONG UserData;
|
||||
UNRARCALLBACK Callback;
|
||||
CHANGEVOLPROC ChangeVolProc;
|
||||
PROCESSDATAPROC ProcessDataProc;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
235
7zip/Compress/Rar29/Original/os.hpp
Executable file
235
7zip/Compress/Rar29/Original/os.hpp
Executable file
@@ -0,0 +1,235 @@
|
||||
#ifndef _RAR_OS_
|
||||
#define _RAR_OS_
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#ifdef __EMX__
|
||||
#define INCL_BASE
|
||||
#endif
|
||||
|
||||
#if defined(_WIN_32) || defined(_EMX)
|
||||
#define ENABLE_BAD_ALLOC
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_WIN_32) || defined(_EMX)
|
||||
|
||||
#define LITTLE_ENDIAN
|
||||
#define NM 1024
|
||||
|
||||
#ifdef _WIN_32
|
||||
|
||||
// Igor Pavlov
|
||||
#ifndef STRICT
|
||||
#define STRICT
|
||||
#endif
|
||||
|
||||
#undef WINVER
|
||||
#undef _WIN32_WINNT
|
||||
#define WINVER 0x0400
|
||||
#define _WIN32_WINNT 0x0300
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <windows.h>
|
||||
#include <prsht.h>
|
||||
|
||||
#ifndef _WIN_CE
|
||||
#include <winioctl.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _WIN_CE
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dos.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_EMX) && !defined(_MSC_VER) && !defined(_WIN_CE)
|
||||
#define ENABLE_MKTEMP
|
||||
#include <dir.h>
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#define for if (0) ; else for
|
||||
#ifndef _WIN_CE
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#ifndef _WIN_CE
|
||||
#include <share.h>
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_BAD_ALLOC) && !defined(_WIN_CE)
|
||||
#include <new.h>
|
||||
#endif
|
||||
|
||||
#ifdef _EMX
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <errno.h>
|
||||
#ifdef _DJGPP
|
||||
#include <utime.h>
|
||||
#else
|
||||
#include <os2.h>
|
||||
#include <sys/utime.h>
|
||||
#include <emx/syscalls.h>
|
||||
#endif
|
||||
#else
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#include <exception>
|
||||
#else
|
||||
#include <except.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#ifndef _WIN_CE
|
||||
#include <fcntl.h>
|
||||
#include <dos.h>
|
||||
#include <io.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef _WIN_32
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
*/
|
||||
|
||||
#define ENABLE_ACCESS
|
||||
|
||||
#define DefConfigName "rar.ini"
|
||||
#define DefLogName "rar.log"
|
||||
|
||||
|
||||
#define PATHDIVIDER "\\"
|
||||
#define PATHDIVIDERW L"\\"
|
||||
#define CPATHDIVIDER '\\'
|
||||
#define MASKALL "*"
|
||||
#define MASKALLW L"*"
|
||||
|
||||
#define READBINARY "rb"
|
||||
#define READTEXT "rt"
|
||||
#define UPDATEBINARY "r+b"
|
||||
#define CREATEBINARY "w+b"
|
||||
#define APPENDTEXT "at"
|
||||
|
||||
#if defined(_WIN_32)
|
||||
#ifdef _MSC_VER
|
||||
#define _stdfunction __cdecl
|
||||
#else
|
||||
#define _stdfunction _USERENTRY
|
||||
#endif
|
||||
#else
|
||||
#define _stdfunction
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _UNIX
|
||||
|
||||
#define NM 1024
|
||||
|
||||
#ifdef _BEOS
|
||||
#include <be/kernel/fs_info.h>
|
||||
#include <be/kernel/fs_attr.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/file.h>
|
||||
#if defined(__QNXNTO__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined(__APPLE__)
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#else
|
||||
#endif
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include <utime.h>
|
||||
#include <locale.h>
|
||||
|
||||
#ifdef S_IFLNK
|
||||
#define SAVE_LINKS
|
||||
#endif
|
||||
|
||||
#define ENABLE_ACCESS
|
||||
|
||||
#define DefConfigName ".rarrc"
|
||||
#define DefLogName ".rarlog"
|
||||
|
||||
|
||||
#define PATHDIVIDER "/"
|
||||
#define PATHDIVIDERW L"/"
|
||||
#define CPATHDIVIDER '/'
|
||||
#define MASKALL "*"
|
||||
#define MASKALLW L"*"
|
||||
|
||||
#define READBINARY "r"
|
||||
#define READTEXT "r"
|
||||
#define UPDATEBINARY "r+"
|
||||
#define CREATEBINARY "w+"
|
||||
#define APPENDTEXT "a"
|
||||
|
||||
#define _stdfunction
|
||||
|
||||
#ifdef _APPLE
|
||||
#ifndef BIG_ENDIAN
|
||||
#define BIG_ENDIAN
|
||||
#endif
|
||||
#ifdef LITTLE_ENDIAN
|
||||
#undef LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__sparc) || defined(sparc) || defined(__hpux)
|
||||
#ifndef BIG_ENDIAN
|
||||
#define BIG_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
typedef const char* MSGID;
|
||||
|
||||
#define safebuf static
|
||||
|
||||
#if defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
|
||||
#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
|
||||
#undef LITTLE_ENDIAN
|
||||
#elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
|
||||
#undef BIG_ENDIAN
|
||||
#else
|
||||
#error "Both LITTLE_ENDIAN and BIG_ENDIAN are defined. Undef something one"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(BIG_ENDIAN) && !defined(_WIN_CE) && defined(_WIN_32)
|
||||
#define ALLOW_NOT_ALIGNED_INT
|
||||
#endif
|
||||
|
||||
#endif // _RAR_OS_
|
||||
44
7zip/Compress/Rar29/Original/pathfn.hpp
Executable file
44
7zip/Compress/Rar29/Original/pathfn.hpp
Executable file
@@ -0,0 +1,44 @@
|
||||
#ifndef _RAR_PATHFN_
|
||||
#define _RAR_PATHFN_
|
||||
|
||||
char* PointToName(const char *Path);
|
||||
wchar* PointToName(const wchar *Path);
|
||||
char* PointToLastChar(const char *Path);
|
||||
char* ConvertPath(const char *SrcPath,char *DestPath);
|
||||
wchar* ConvertPath(const wchar *SrcPath,wchar *DestPath);
|
||||
void SetExt(char *Name,const char *NewExt);
|
||||
void SetExt(wchar *Name,const wchar *NewExt);
|
||||
void SetSFXExt(char *SFXName);
|
||||
void SetSFXExt(wchar *SFXName);
|
||||
char *GetExt(const char *Name);
|
||||
wchar *GetExt(const wchar *Name);
|
||||
bool CmpExt(const char *Name,const char *Ext);
|
||||
bool IsWildcard(const char *Str,const wchar *StrW=NULL);
|
||||
bool IsPathDiv(int Ch);
|
||||
bool IsDriveDiv(int Ch);
|
||||
int GetPathDisk(const char *Path);
|
||||
void AddEndSlash(char *Path);
|
||||
void AddEndSlash(wchar *Path);
|
||||
void GetFilePath(const char *FullName,char *Path);
|
||||
void GetFilePath(const wchar *FullName,wchar *Path);
|
||||
void RemoveNameFromPath(char *Path);
|
||||
void RemoveNameFromPath(wchar *Path);
|
||||
bool EnumConfigPaths(char *Path,int Number);
|
||||
void GetConfigName(const char *Name,char *FullName,bool CheckExist);
|
||||
char* GetVolNumPart(char *ArcName);
|
||||
void NextVolumeName(char *ArcName,bool OldNumbering);
|
||||
bool IsNameUsable(const char *Name);
|
||||
void MakeNameUsable(char *Name,bool Extended);
|
||||
char* UnixSlashToDos(char *SrcName,char *DestName=NULL,uint MaxLength=NM);
|
||||
char* DosSlashToUnix(char *SrcName,char *DestName=NULL,uint MaxLength=NM);
|
||||
bool IsFullPath(const char *Path);
|
||||
bool IsDiskLetter(const char *Path);
|
||||
void GetPathRoot(const char *Path,char *Root);
|
||||
int ParseVersionFileName(char *Name,wchar *NameW,bool Truncate);
|
||||
char* VolNameToFirstName(const char *VolName,char *FirstName,bool NewNumbering);
|
||||
wchar* GetWideName(const char *Name,const wchar *NameW,wchar *DestW);
|
||||
|
||||
|
||||
inline char* GetOutputName(const char *Name) {return((char *)Name);};
|
||||
|
||||
#endif
|
||||
80
7zip/Compress/Rar29/Original/rar.hpp
Executable file
80
7zip/Compress/Rar29/Original/rar.hpp
Executable file
@@ -0,0 +1,80 @@
|
||||
#ifndef _RAR_RARCOMMON_
|
||||
#define _RAR_RARCOMMON_
|
||||
|
||||
#include "raros.hpp"
|
||||
#include "os.hpp"
|
||||
|
||||
|
||||
#ifdef RARDLL
|
||||
#include "dll.hpp"
|
||||
#endif
|
||||
|
||||
#ifndef _WIN_CE
|
||||
#include "version.hpp"
|
||||
#endif
|
||||
#include "rartypes.hpp"
|
||||
#include "rardefs.hpp"
|
||||
#include "rarlang.hpp"
|
||||
#include "int64.hpp"
|
||||
#include "unicode.hpp"
|
||||
#include "errhnd.hpp"
|
||||
#include "array.hpp"
|
||||
#include "timefn.hpp"
|
||||
#include "headers.hpp"
|
||||
#include "rarfn.hpp"
|
||||
#include "pathfn.hpp"
|
||||
#include "strfn.hpp"
|
||||
#include "strlist.hpp"
|
||||
#include "file.hpp"
|
||||
#include "sha1.hpp"
|
||||
#include "crc.hpp"
|
||||
#include "rijndael.hpp"
|
||||
#include "crypt.hpp"
|
||||
#include "filefn.hpp"
|
||||
#include "filestr.hpp"
|
||||
#include "find.hpp"
|
||||
#include "scantree.hpp"
|
||||
#include "savepos.hpp"
|
||||
#include "getbits.hpp"
|
||||
#include "rdwrfn.hpp"
|
||||
#include "options.hpp"
|
||||
#include "archive.hpp"
|
||||
#include "match.hpp"
|
||||
#include "cmddata.hpp"
|
||||
#include "filcreat.hpp"
|
||||
#include "consio.hpp"
|
||||
#include "system.hpp"
|
||||
#include "isnt.hpp"
|
||||
#include "log.hpp"
|
||||
#include "rawread.hpp"
|
||||
#include "encname.hpp"
|
||||
#include "resource.hpp"
|
||||
#include "compress.hpp"
|
||||
|
||||
|
||||
#include "rarvm.hpp"
|
||||
#include "model.hpp"
|
||||
|
||||
|
||||
#include "unpack.hpp"
|
||||
|
||||
|
||||
#include "extinfo.hpp"
|
||||
#include "extract.hpp"
|
||||
|
||||
|
||||
|
||||
#include "list.hpp"
|
||||
|
||||
|
||||
|
||||
#include "rs.hpp"
|
||||
#include "recvol.hpp"
|
||||
#include "volume.hpp"
|
||||
#include "smallfn.hpp"
|
||||
#include "ulinks.hpp"
|
||||
|
||||
#include "global.hpp"
|
||||
|
||||
|
||||
#endif
|
||||
21
7zip/Compress/Rar29/Original/rardefs.hpp
Executable file
21
7zip/Compress/Rar29/Original/rardefs.hpp
Executable file
@@ -0,0 +1,21 @@
|
||||
#ifndef _RAR_DEFS_
|
||||
#define _RAR_DEFS_
|
||||
|
||||
#define Min(x,y) (((x)<(y)) ? (x):(y))
|
||||
#define Max(x,y) (((x)>(y)) ? (x):(y))
|
||||
|
||||
#define MAXPASSWORD 128
|
||||
|
||||
#define DefSFXName "default.sfx"
|
||||
#define DefSortListName "rarfiles.lst"
|
||||
|
||||
#ifndef FA_RDONLY
|
||||
#define FA_RDONLY 0x01
|
||||
#define FA_HIDDEN 0x02
|
||||
#define FA_SYSTEM 0x04
|
||||
#define FA_LABEL 0x08
|
||||
#define FA_DIREC 0x10
|
||||
#define FA_ARCH 0x20
|
||||
#endif
|
||||
|
||||
#endif
|
||||
7
7zip/Compress/Rar29/Original/rarfn.hpp
Executable file
7
7zip/Compress/Rar29/Original/rarfn.hpp
Executable file
@@ -0,0 +1,7 @@
|
||||
#ifndef _RAR_FN_
|
||||
#define _RAR_FN_
|
||||
|
||||
void RARInitData();
|
||||
|
||||
|
||||
#endif
|
||||
10
7zip/Compress/Rar29/Original/rarlang.hpp
Executable file
10
7zip/Compress/Rar29/Original/rarlang.hpp
Executable file
@@ -0,0 +1,10 @@
|
||||
#ifndef _RAR_LANG_
|
||||
#define _RAR_LANG_
|
||||
|
||||
#ifdef USE_RC
|
||||
#include "rarres.hpp"
|
||||
#else
|
||||
#include "loclang.hpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
41
7zip/Compress/Rar29/Original/raros.hpp
Executable file
41
7zip/Compress/Rar29/Original/raros.hpp
Executable file
@@ -0,0 +1,41 @@
|
||||
#ifndef _RAR_RAROS_
|
||||
#define _RAR_RAROS_
|
||||
|
||||
#ifdef __EMX__
|
||||
#define _EMX
|
||||
#endif
|
||||
|
||||
#ifdef __DJGPP__
|
||||
#define _DJGPP
|
||||
#define _EMX
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__) || defined(_WIN32)
|
||||
#define _WIN_32
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
#define _WIN_32
|
||||
#define _WIN_CE
|
||||
#ifdef WM_FILECHANGEINFO
|
||||
#define PC2002
|
||||
#else
|
||||
#undef PC2002
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __BEOS__
|
||||
#define _UNIX
|
||||
#define _BEOS
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define _UNIX
|
||||
#define _APPLE
|
||||
#endif
|
||||
|
||||
#if !defined(_EMX) && !defined(_WIN_32) && !defined(_BEOS) && !defined(_APPLE)
|
||||
#define _UNIX
|
||||
#endif
|
||||
|
||||
#endif
|
||||
21
7zip/Compress/Rar29/Original/rartypes.hpp
Executable file
21
7zip/Compress/Rar29/Original/rartypes.hpp
Executable file
@@ -0,0 +1,21 @@
|
||||
#ifndef _RAR_TYPES_
|
||||
#define _RAR_TYPES_
|
||||
|
||||
typedef unsigned char byte; //8 bits
|
||||
typedef unsigned short ushort; //preferably 16 bits, but can be more
|
||||
typedef unsigned int uint; //32 bits or more
|
||||
|
||||
typedef unsigned int uint32; //32 bits exactly
|
||||
typedef int sint32; //signed 32 bits exactly
|
||||
#define PRESENT_INT32
|
||||
|
||||
#if defined(_WIN_32) || defined(__GNUC__) || defined(__sgi) || defined(_AIX) || defined(__sun) || defined(__hpux)
|
||||
typedef wchar_t wchar;
|
||||
#else
|
||||
typedef ushort wchar;
|
||||
#endif
|
||||
|
||||
#define SHORT16(x) (sizeof(ushort)==2 ? (ushort)(x):((x)&0xffff))
|
||||
#define UINT32(x) (sizeof(uint32)==4 ? (uint32)(x):((x)&0xffffffff))
|
||||
|
||||
#endif
|
||||
1050
7zip/Compress/Rar29/Original/rarvm.cpp
Executable file
1050
7zip/Compress/Rar29/Original/rarvm.cpp
Executable file
File diff suppressed because it is too large
Load Diff
110
7zip/Compress/Rar29/Original/rarvm.hpp
Executable file
110
7zip/Compress/Rar29/Original/rarvm.hpp
Executable file
@@ -0,0 +1,110 @@
|
||||
#ifndef _RAR_VM_
|
||||
#define _RAR_VM_
|
||||
|
||||
#define VM_STANDARDFILTERS
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
#define VM_OPTIMIZE
|
||||
#endif
|
||||
|
||||
|
||||
#define VM_MEMSIZE 0x40000
|
||||
#define VM_MEMMASK (VM_MEMSIZE-1)
|
||||
#define VM_GLOBALMEMADDR 0x3C000
|
||||
#define VM_GLOBALMEMSIZE 0x2000
|
||||
#define VM_FIXEDGLOBALSIZE 64
|
||||
|
||||
enum VM_Commands
|
||||
{
|
||||
VM_MOV, VM_CMP, VM_ADD, VM_SUB, VM_JZ, VM_JNZ, VM_INC, VM_DEC,
|
||||
VM_JMP, VM_XOR, VM_AND, VM_OR, VM_TEST, VM_JS, VM_JNS, VM_JB,
|
||||
VM_JBE, VM_JA, VM_JAE, VM_PUSH, VM_POP, VM_CALL, VM_RET, VM_NOT,
|
||||
VM_SHL, VM_SHR, VM_SAR, VM_NEG, VM_PUSHA,VM_POPA, VM_PUSHF,VM_POPF,
|
||||
VM_MOVZX,VM_MOVSX,VM_XCHG, VM_MUL, VM_DIV, VM_ADC, VM_SBB, VM_PRINT,
|
||||
|
||||
#ifdef VM_OPTIMIZE
|
||||
VM_MOVB, VM_MOVD, VM_CMPB, VM_CMPD,
|
||||
|
||||
VM_ADDB, VM_ADDD, VM_SUBB, VM_SUBD, VM_INCB, VM_INCD, VM_DECB, VM_DECD,
|
||||
VM_NEGB, VM_NEGD,
|
||||
#endif
|
||||
|
||||
VM_STANDARD
|
||||
};
|
||||
|
||||
enum VM_StandardFilters {
|
||||
VMSF_NONE, VMSF_E8, VMSF_E8E9, VMSF_ITANIUM, VMSF_RGB, VMSF_AUDIO,
|
||||
VMSF_DELTA, VMSF_UPCASE
|
||||
};
|
||||
|
||||
enum VM_Flags {VM_FC=1,VM_FZ=2,VM_FS=0x80000000};
|
||||
|
||||
enum VM_OpType {VM_OPREG,VM_OPINT,VM_OPREGMEM,VM_OPNONE};
|
||||
|
||||
struct VM_PreparedOperand
|
||||
{
|
||||
VM_OpType Type;
|
||||
uint Data;
|
||||
uint Base;
|
||||
uint *Addr;
|
||||
};
|
||||
|
||||
struct VM_PreparedCommand
|
||||
{
|
||||
VM_Commands OpCode;
|
||||
bool ByteMode;
|
||||
VM_PreparedOperand Op1,Op2;
|
||||
};
|
||||
|
||||
|
||||
struct VM_PreparedProgram
|
||||
{
|
||||
VM_PreparedProgram() {AltCmd=NULL;}
|
||||
|
||||
Array<VM_PreparedCommand> Cmd;
|
||||
VM_PreparedCommand *AltCmd;
|
||||
int CmdCount;
|
||||
|
||||
Array<byte> GlobalData;
|
||||
Array<byte> StaticData;
|
||||
uint InitR[7];
|
||||
|
||||
byte *FilteredData;
|
||||
unsigned int FilteredDataSize;
|
||||
};
|
||||
|
||||
class RarVM:private BitInput
|
||||
{
|
||||
private:
|
||||
inline uint GetValue(bool ByteMode,uint *Addr);
|
||||
inline void SetValue(bool ByteMode,uint *Addr,uint Value);
|
||||
inline uint* GetOperand(VM_PreparedOperand *CmdOp);
|
||||
void PrintState(uint IP);
|
||||
void DecodeArg(VM_PreparedOperand &Op,bool ByteMode);
|
||||
#ifdef VM_OPTIMIZE
|
||||
void Optimize(VM_PreparedProgram *Prg);
|
||||
#endif
|
||||
bool ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize);
|
||||
#ifdef VM_STANDARDFILTERS
|
||||
VM_StandardFilters IsStandardFilter(byte *Code,int CodeSize);
|
||||
void ExecuteStandardFilter(VM_StandardFilters FilterType);
|
||||
unsigned int FilterItanium_GetBits(byte *Data,int BitPos,int BitCount);
|
||||
void FilterItanium_SetBits(byte *Data,unsigned int BitField,int BitPos,
|
||||
int BitCount);
|
||||
#endif
|
||||
|
||||
byte *Mem;
|
||||
uint R[8];
|
||||
uint Flags;
|
||||
public:
|
||||
RarVM();
|
||||
~RarVM();
|
||||
void Init();
|
||||
void Prepare(byte *Code,int CodeSize,VM_PreparedProgram *Prg);
|
||||
void Execute(VM_PreparedProgram *Prg);
|
||||
void SetValue(uint *Addr,uint Value);
|
||||
void SetMemory(unsigned int Pos,byte *Data,unsigned int DataSize);
|
||||
static uint ReadData(BitInput &Inp);
|
||||
};
|
||||
|
||||
#endif
|
||||
53
7zip/Compress/Rar29/Original/rarvmtbl.cpp
Executable file
53
7zip/Compress/Rar29/Original/rarvmtbl.cpp
Executable file
@@ -0,0 +1,53 @@
|
||||
#define VMCF_OP0 0
|
||||
#define VMCF_OP1 1
|
||||
#define VMCF_OP2 2
|
||||
#define VMCF_OPMASK 3
|
||||
#define VMCF_BYTEMODE 4
|
||||
#define VMCF_JUMP 8
|
||||
#define VMCF_PROC 16
|
||||
#define VMCF_USEFLAGS 32
|
||||
#define VMCF_CHFLAGS 64
|
||||
|
||||
static byte VM_CmdFlags[]=
|
||||
{
|
||||
/* VM_MOV */ VMCF_OP2 | VMCF_BYTEMODE ,
|
||||
/* VM_CMP */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_ADD */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_SUB */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_JZ */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
|
||||
/* VM_JNZ */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
|
||||
/* VM_INC */ VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_DEC */ VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_JMP */ VMCF_OP1 | VMCF_JUMP ,
|
||||
/* VM_XOR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_AND */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_OR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_TEST */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_JS */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
|
||||
/* VM_JNS */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
|
||||
/* VM_JB */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
|
||||
/* VM_JBE */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
|
||||
/* VM_JA */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
|
||||
/* VM_JAE */ VMCF_OP1 | VMCF_JUMP | VMCF_USEFLAGS ,
|
||||
/* VM_PUSH */ VMCF_OP1 ,
|
||||
/* VM_POP */ VMCF_OP1 ,
|
||||
/* VM_CALL */ VMCF_OP1 | VMCF_PROC ,
|
||||
/* VM_RET */ VMCF_OP0 | VMCF_PROC ,
|
||||
/* VM_NOT */ VMCF_OP1 | VMCF_BYTEMODE ,
|
||||
/* VM_SHL */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_SHR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_SAR */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_NEG */ VMCF_OP1 | VMCF_BYTEMODE | VMCF_CHFLAGS ,
|
||||
/* VM_PUSHA */ VMCF_OP0 ,
|
||||
/* VM_POPA */ VMCF_OP0 ,
|
||||
/* VM_PUSHF */ VMCF_OP0 | VMCF_USEFLAGS ,
|
||||
/* VM_POPF */ VMCF_OP0 | VMCF_CHFLAGS ,
|
||||
/* VM_MOVZX */ VMCF_OP2 ,
|
||||
/* VM_MOVSX */ VMCF_OP2 ,
|
||||
/* VM_XCHG */ VMCF_OP2 | VMCF_BYTEMODE ,
|
||||
/* VM_MUL */ VMCF_OP2 | VMCF_BYTEMODE ,
|
||||
/* VM_DIV */ VMCF_OP2 | VMCF_BYTEMODE ,
|
||||
/* VM_ADC */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_USEFLAGS | VMCF_CHFLAGS ,
|
||||
/* VM_SBB */ VMCF_OP2 | VMCF_BYTEMODE | VMCF_USEFLAGS | VMCF_CHFLAGS ,
|
||||
/* VM_PRINT */ VMCF_OP0
|
||||
};
|
||||
32
7zip/Compress/Rar29/Original/rawread.hpp
Executable file
32
7zip/Compress/Rar29/Original/rawread.hpp
Executable file
@@ -0,0 +1,32 @@
|
||||
#ifndef _RAR_RAWREAD_
|
||||
#define _RAR_RAWREAD_
|
||||
|
||||
class RawRead
|
||||
{
|
||||
private:
|
||||
Array<byte> Data;
|
||||
File *SrcFile;
|
||||
int DataSize;
|
||||
int ReadPos;
|
||||
#ifndef SHELL_EXT
|
||||
CryptData *Crypt;
|
||||
#endif
|
||||
public:
|
||||
RawRead(File *SrcFile);
|
||||
void Read(int Size);
|
||||
void Read(byte *SrcData,int Size);
|
||||
void Get(byte &Field);
|
||||
void Get(ushort &Field);
|
||||
void Get(uint &Field);
|
||||
void Get8(Int64 &Field);
|
||||
void Get(byte *Field,int Size);
|
||||
void Get(wchar *Field,int Size);
|
||||
uint GetCRC(bool ProcessedOnly);
|
||||
int Size() {return DataSize;}
|
||||
int PaddedSize() {return Data.Size()-DataSize;}
|
||||
#ifndef SHELL_EXT
|
||||
void SetCrypt(CryptData *Crypt) {RawRead::Crypt=Crypt;}
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
306
7zip/Compress/Rar29/Original/rdwrfn.cpp
Executable file
306
7zip/Compress/Rar29/Original/rdwrfn.cpp
Executable file
@@ -0,0 +1,306 @@
|
||||
#include "rar.hpp"
|
||||
|
||||
// Igor Pavlov
|
||||
#include "../../../Common/StreamUtils.h"
|
||||
|
||||
ComprDataIO::ComprDataIO()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
void ComprDataIO::Init()
|
||||
{
|
||||
UnpackFromMemory=false;
|
||||
UnpackToMemory=false;
|
||||
UnpPackedSize=0;
|
||||
ShowProgress=true;
|
||||
TestMode=false;
|
||||
SkipUnpCRC=false;
|
||||
PackVolume=false;
|
||||
UnpVolume=false;
|
||||
NextVolumeMissing=false;
|
||||
SrcFile=NULL;
|
||||
DestFile=NULL;
|
||||
UnpWrSize=0;
|
||||
Command=NULL;
|
||||
Encryption=0;
|
||||
Decryption=0;
|
||||
TotalPackRead=0;
|
||||
CurPackRead=CurPackWrite=CurUnpRead=CurUnpWrite=0;
|
||||
PackFileCRC=UnpFileCRC=PackedCRC=0xffffffff;
|
||||
LastPercent=-1;
|
||||
// Igor Pavlov
|
||||
/*
|
||||
SubHead=NULL;
|
||||
SubHeadPos=NULL;
|
||||
*/
|
||||
CurrentCommand=0;
|
||||
ProcessedArcSize=TotalArcSize=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int ComprDataIO::UnpRead(byte *Addr,uint Count)
|
||||
{
|
||||
int RetCode=0,TotalRead=0;
|
||||
byte *ReadAddr;
|
||||
ReadAddr=Addr;
|
||||
while (Count > 0)
|
||||
{
|
||||
Archive *SrcArc=(Archive *)SrcFile;
|
||||
|
||||
uint ReadSize=(Count>UnpPackedSize) ? int64to32(UnpPackedSize):Count;
|
||||
if (UnpackFromMemory)
|
||||
{
|
||||
memcpy(Addr,UnpackFromMemoryAddr,UnpackFromMemorySize);
|
||||
RetCode=UnpackFromMemorySize;
|
||||
UnpackFromMemorySize=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Igor Pavlov
|
||||
if (!SrcFile)
|
||||
// if (!SrcFile->IsOpened())
|
||||
return(-1);
|
||||
|
||||
// Igor Pavlov
|
||||
UInt32 processedSize;
|
||||
HRESULT result = ReadStream(SrcFile, ReadAddr, ReadSize, &processedSize);
|
||||
RetCode = processedSize;
|
||||
|
||||
// Igor Pavlov
|
||||
/*
|
||||
FileHeader *hd=SubHead!=NULL ? SubHead:&SrcArc->NewLhd;
|
||||
if (hd->Flags & LHD_SPLIT_AFTER)
|
||||
PackedCRC=CRC(PackedCRC,ReadAddr,ReadSize);
|
||||
*/
|
||||
}
|
||||
CurUnpRead+=RetCode;
|
||||
ReadAddr+=RetCode;
|
||||
TotalRead+=RetCode;
|
||||
Count-=RetCode;
|
||||
UnpPackedSize-=RetCode;
|
||||
if (UnpPackedSize == 0 && UnpVolume)
|
||||
{
|
||||
#ifndef NOVOLUME
|
||||
if (!MergeArchive(*SrcArc,this,true,CurrentCommand))
|
||||
#endif
|
||||
{
|
||||
NextVolumeMissing=true;
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
// Igor Pavlov
|
||||
/*
|
||||
Archive *SrcArc=(Archive *)SrcFile;
|
||||
if (SrcArc!=NULL)
|
||||
ShowUnpRead(SrcArc->CurBlockPos+CurUnpRead,UnpArcSize);
|
||||
*/
|
||||
if (RetCode!=-1)
|
||||
{
|
||||
RetCode=TotalRead;
|
||||
#ifndef NOCRYPT
|
||||
if (Decryption)
|
||||
#ifndef SFX_MODULE
|
||||
if (Decryption<20)
|
||||
Decrypt.Crypt(Addr,RetCode,(Decryption==15) ? NEW_CRYPT : OLD_DECODE);
|
||||
else
|
||||
if (Decryption==20)
|
||||
for (uint I=0;I<RetCode;I+=16)
|
||||
Decrypt.DecryptBlock20(&Addr[I]);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
int CryptSize=(RetCode & 0xf)==0 ? RetCode:((RetCode & ~0xf)+16);
|
||||
Decrypt.DecryptBlock(Addr,CryptSize);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Wait();
|
||||
return(RetCode);
|
||||
}
|
||||
|
||||
|
||||
void ComprDataIO::UnpWrite(byte *Addr,uint Count)
|
||||
{
|
||||
#ifdef RARDLL
|
||||
RAROptions *Cmd=((Archive *)SrcFile)->GetRAROptions();
|
||||
if (Cmd->DllOpMode!=RAR_SKIP)
|
||||
{
|
||||
if (Cmd->Callback!=NULL &&
|
||||
Cmd->Callback(UCM_PROCESSDATA,Cmd->UserData,(LONG)Addr,Count)==-1)
|
||||
ErrHandler.Exit(USER_BREAK);
|
||||
if (Cmd->ProcessDataProc!=NULL)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
_EBX=_ESP;
|
||||
#endif
|
||||
int RetCode=Cmd->ProcessDataProc(Addr,Count);
|
||||
#ifdef _WIN_32
|
||||
_ESP=_EBX;
|
||||
#endif
|
||||
if (RetCode==0)
|
||||
ErrHandler.Exit(USER_BREAK);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
UnpWrAddr=Addr;
|
||||
UnpWrSize=Count;
|
||||
if (UnpackToMemory)
|
||||
{
|
||||
if (Count <= UnpackToMemorySize)
|
||||
{
|
||||
memcpy(UnpackToMemoryAddr,Addr,Count);
|
||||
UnpackToMemoryAddr+=Count;
|
||||
UnpackToMemorySize-=Count;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!TestMode)
|
||||
{
|
||||
// Igor Pavlov
|
||||
// DestFile->Write(Addr,Count);
|
||||
WriteStream(DestFile, Addr,Count, 0);
|
||||
}
|
||||
CurUnpWrite+=Count;
|
||||
// Igor Pavlov
|
||||
/*
|
||||
if (!SkipUnpCRC)
|
||||
#ifndef SFX_MODULE
|
||||
if (((Archive *)SrcFile)->OldFormat)
|
||||
UnpFileCRC=OldCRC((ushort)UnpFileCRC,Addr,Count);
|
||||
else
|
||||
#endif
|
||||
UnpFileCRC=CRC(UnpFileCRC,Addr,Count);
|
||||
*/
|
||||
ShowUnpWrite();
|
||||
Wait();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ComprDataIO::ShowUnpRead(Int64 ArcPos,Int64 ArcSize)
|
||||
{
|
||||
if (ShowProgress && SrcFile!=NULL)
|
||||
{
|
||||
Archive *SrcArc=(Archive *)SrcFile;
|
||||
RAROptions *Cmd=SrcArc->GetRAROptions();
|
||||
if (TotalArcSize!=0)
|
||||
ArcSize=TotalArcSize;
|
||||
ArcPos+=ProcessedArcSize;
|
||||
if (!SrcArc->Volume)
|
||||
{
|
||||
int CurPercent=ToPercent(ArcPos,ArcSize);
|
||||
if (!Cmd->DisablePercentage && CurPercent!=LastPercent)
|
||||
{
|
||||
mprintf("\b\b\b\b%3d%%",CurPercent);
|
||||
LastPercent=CurPercent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ComprDataIO::ShowUnpWrite()
|
||||
{
|
||||
// Igor Pavlov
|
||||
if (Progress)
|
||||
{
|
||||
UInt64 unPackSize = CurUnpWrite;
|
||||
HRESULT result = Progress->SetRatioInfo(NULL, &unPackSize);
|
||||
if (result != S_OK)
|
||||
throw CExitCode(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Igor Pavlov
|
||||
/*
|
||||
void ComprDataIO::SetFiles(File *SrcFile,File *DestFile)
|
||||
{
|
||||
if (SrcFile!=NULL)
|
||||
ComprDataIO::SrcFile=SrcFile;
|
||||
if (DestFile!=NULL)
|
||||
ComprDataIO::DestFile=DestFile;
|
||||
LastPercent=-1;
|
||||
}
|
||||
*/
|
||||
|
||||
void ComprDataIO::GetUnpackedData(byte **Data,uint *Size)
|
||||
{
|
||||
*Data=UnpWrAddr;
|
||||
*Size=UnpWrSize;
|
||||
}
|
||||
|
||||
// Igor Pavlov
|
||||
/*
|
||||
void ComprDataIO::SetEncryption(int Method,char *Password,byte *Salt,bool Encrypt)
|
||||
{
|
||||
if (Encrypt)
|
||||
{
|
||||
Encryption=*Password ? Method:0;
|
||||
#ifndef NOCRYPT
|
||||
Crypt.SetCryptKeys(Password,Salt,Encrypt);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
Decryption=*Password ? Method:0;
|
||||
#ifndef NOCRYPT
|
||||
Decrypt.SetCryptKeys(Password,Salt,Encrypt,Method<29);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
void ComprDataIO::SetAV15Encryption()
|
||||
{
|
||||
Decryption=15;
|
||||
Decrypt.SetAV15Encryption();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
void ComprDataIO::SetCmt13Encryption()
|
||||
{
|
||||
Decryption=13;
|
||||
Decrypt.SetCmt13Encryption();
|
||||
}
|
||||
#endif
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
void ComprDataIO::SetUnpackToMemory(byte *Addr,uint Size)
|
||||
{
|
||||
UnpackToMemory=true;
|
||||
UnpackToMemoryAddr=Addr;
|
||||
UnpackToMemorySize=Size;
|
||||
}
|
||||
|
||||
// Igor Pavlov
|
||||
void ComprDataIO::SetFiles(ISequentialInStream *srcFile,
|
||||
ISequentialOutStream *destFile, ICompressProgressInfo *progress)
|
||||
{
|
||||
SrcFile = srcFile;
|
||||
DestFile = destFile;
|
||||
Progress = progress;
|
||||
LastPercent = -1;
|
||||
}
|
||||
|
||||
104
7zip/Compress/Rar29/Original/rdwrfn.hpp
Executable file
104
7zip/Compress/Rar29/Original/rdwrfn.hpp
Executable file
@@ -0,0 +1,104 @@
|
||||
#ifndef _RAR_DATAIO_
|
||||
#define _RAR_DATAIO_
|
||||
|
||||
// Igor Pavlov
|
||||
#include "../../../ICoder.h"
|
||||
|
||||
class CmdAdd;
|
||||
class Unpack;
|
||||
|
||||
// Igor Pavlov
|
||||
struct CExitCode
|
||||
{
|
||||
HRESULT Result;
|
||||
CExitCode(HRESULT result): Result(result) {};
|
||||
};
|
||||
|
||||
class ComprDataIO
|
||||
{
|
||||
private:
|
||||
void ShowUnpRead(Int64 ArcPos,Int64 ArcSize);
|
||||
void ShowUnpWrite();
|
||||
|
||||
|
||||
bool UnpackFromMemory;
|
||||
uint UnpackFromMemorySize;
|
||||
byte *UnpackFromMemoryAddr;
|
||||
|
||||
bool UnpackToMemory;
|
||||
uint UnpackToMemorySize;
|
||||
byte *UnpackToMemoryAddr;
|
||||
|
||||
uint UnpWrSize;
|
||||
byte *UnpWrAddr;
|
||||
|
||||
Int64 UnpPackedSize;
|
||||
|
||||
bool ShowProgress;
|
||||
bool TestMode;
|
||||
bool SkipUnpCRC;
|
||||
|
||||
// Igor Pavlov
|
||||
// File *SrcFile;
|
||||
// File *DestFile;
|
||||
ISequentialInStream *SrcFile;
|
||||
ISequentialOutStream *DestFile;
|
||||
ICompressProgressInfo *Progress;
|
||||
|
||||
CmdAdd *Command;
|
||||
|
||||
// Igor Pavlov
|
||||
/*
|
||||
FileHeader *SubHead;
|
||||
Int64 *SubHeadPos;
|
||||
*/
|
||||
|
||||
#ifndef NOCRYPT
|
||||
CryptData Crypt;
|
||||
CryptData Decrypt;
|
||||
#endif
|
||||
|
||||
|
||||
int LastPercent;
|
||||
|
||||
char CurrentCommand;
|
||||
|
||||
public:
|
||||
ComprDataIO();
|
||||
void Init();
|
||||
int UnpRead(byte *Addr,uint Count);
|
||||
void UnpWrite(byte *Addr,uint Count);
|
||||
void EnableShowProgress(bool Show) {ShowProgress=Show;}
|
||||
void GetUnpackedData(byte **Data,uint *Size);
|
||||
void SetPackedSizeToRead(Int64 Size) {UnpPackedSize=Size;}
|
||||
void SetTestMode(bool Mode) {TestMode=Mode;}
|
||||
void SetSkipUnpCRC(bool Skip) {SkipUnpCRC=Skip;}
|
||||
// Igor Pavlov
|
||||
// void SetFiles(File *SrcFile,File *DestFile);
|
||||
void SetFiles(ISequentialInStream *srcFile,
|
||||
ISequentialOutStream *destFile, ICompressProgressInfo *progress);
|
||||
|
||||
void SetCommand(CmdAdd *Cmd) {Command=Cmd;}
|
||||
// Igor Pavlov
|
||||
// void SetSubHeader(FileHeader *hd,Int64 *Pos) {SubHead=hd;SubHeadPos=Pos;}
|
||||
// void SetEncryption(int Method,char *Password,byte *Salt,bool Encrypt);
|
||||
// void SetAV15Encryption();
|
||||
// void SetCmt13Encryption();
|
||||
void SetUnpackToMemory(byte *Addr,uint Size);
|
||||
void SetCurrentCommand(char Cmd) {CurrentCommand=Cmd;}
|
||||
|
||||
bool PackVolume;
|
||||
bool UnpVolume;
|
||||
bool NextVolumeMissing;
|
||||
Int64 TotalPackRead;
|
||||
Int64 UnpArcSize;
|
||||
Int64 CurPackRead,CurPackWrite,CurUnpRead,CurUnpWrite;
|
||||
Int64 ProcessedArcSize,TotalArcSize;
|
||||
|
||||
uint PackFileCRC,UnpFileCRC,PackedCRC;
|
||||
|
||||
int Encryption;
|
||||
int Decryption;
|
||||
};
|
||||
|
||||
#endif
|
||||
16
7zip/Compress/Rar29/Original/recvol.hpp
Executable file
16
7zip/Compress/Rar29/Original/recvol.hpp
Executable file
@@ -0,0 +1,16 @@
|
||||
#ifndef _RAR_RECVOL_
|
||||
#define _RAR_RECVOL_
|
||||
|
||||
class RecVolumes
|
||||
{
|
||||
private:
|
||||
File *SrcFile[256];
|
||||
Array<byte> Buf;
|
||||
public:
|
||||
RecVolumes();
|
||||
~RecVolumes();
|
||||
void Make(RAROptions *Cmd,char *ArcName,wchar *ArcNameW);
|
||||
bool Restore(RAROptions *Cmd,const char *Name,const wchar *NameW,bool Silent);
|
||||
};
|
||||
|
||||
#endif
|
||||
12
7zip/Compress/Rar29/Original/resource.cpp
Executable file
12
7zip/Compress/Rar29/Original/resource.cpp
Executable file
@@ -0,0 +1,12 @@
|
||||
#include "rar.hpp"
|
||||
|
||||
|
||||
|
||||
#if !defined(SILENT) || !defined(RARDLL)
|
||||
const char *St(MSGID StringId)
|
||||
{
|
||||
return(StringId);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
14
7zip/Compress/Rar29/Original/resource.hpp
Executable file
14
7zip/Compress/Rar29/Original/resource.hpp
Executable file
@@ -0,0 +1,14 @@
|
||||
#ifndef _RAR_RESOURCE_
|
||||
#define _RAR_RESOURCE_
|
||||
|
||||
#if defined(SILENT) && defined(RARDLL)
|
||||
#define St(x) ("")
|
||||
#else
|
||||
const char *St(MSGID StringId);
|
||||
#endif
|
||||
|
||||
|
||||
inline const char *StT(MSGID StringId) {return(St(StringId));}
|
||||
|
||||
|
||||
#endif
|
||||
37
7zip/Compress/Rar29/Original/rijndael.hpp
Executable file
37
7zip/Compress/Rar29/Original/rijndael.hpp
Executable file
@@ -0,0 +1,37 @@
|
||||
#ifndef _RIJNDAEL_H_
|
||||
#define _RIJNDAEL_H_
|
||||
|
||||
/**************************************************************************
|
||||
* This code is based on Szymon Stefanek AES implementation: *
|
||||
* http://www.esat.kuleuven.ac.be/~rijmen/rijndael/rijndael-cpplib.tar.gz *
|
||||
* *
|
||||
* Dynamic tables generation is based on the Brian Gladman's work: *
|
||||
* http://fp.gladman.plus.com/cryptography_technology/rijndael *
|
||||
**************************************************************************/
|
||||
|
||||
#define _MAX_KEY_COLUMNS (256/32)
|
||||
#define _MAX_ROUNDS 14
|
||||
#define MAX_IV_SIZE 16
|
||||
|
||||
class Rijndael
|
||||
{
|
||||
public:
|
||||
enum Direction { Encrypt , Decrypt };
|
||||
private:
|
||||
void keySched(byte key[_MAX_KEY_COLUMNS][4]);
|
||||
void keyEncToDec();
|
||||
void encrypt(const byte a[16], byte b[16]);
|
||||
void decrypt(const byte a[16], byte b[16]);
|
||||
void GenerateTables();
|
||||
|
||||
Direction m_direction;
|
||||
byte m_initVector[MAX_IV_SIZE];
|
||||
byte m_expandedKey[_MAX_ROUNDS+1][4][4];
|
||||
public:
|
||||
Rijndael();
|
||||
void init(Direction dir,const byte *key,byte *initVector);
|
||||
int blockEncrypt(const byte *input, int inputLen, byte *outBuffer);
|
||||
int blockDecrypt(const byte *input, int inputLen, byte *outBuffer);
|
||||
};
|
||||
|
||||
#endif // _RIJNDAEL_H_
|
||||
32
7zip/Compress/Rar29/Original/rs.hpp
Executable file
32
7zip/Compress/Rar29/Original/rs.hpp
Executable file
@@ -0,0 +1,32 @@
|
||||
#ifndef _RAR_RS_
|
||||
#define _RAR_RS_
|
||||
|
||||
#define MAXPAR 255
|
||||
#define MAXPOL 512
|
||||
|
||||
class RSCoder
|
||||
{
|
||||
private:
|
||||
void gfInit();
|
||||
int gfMult(int a,int b);
|
||||
void pnInit();
|
||||
void pnMult(int *p1,int *p2,int *r);
|
||||
|
||||
int gfExp[MAXPOL];
|
||||
int gfLog[MAXPAR+1];
|
||||
|
||||
int GXPol[MAXPOL*2];
|
||||
|
||||
int ErrorLocs[MAXPAR+1],ErrCount;
|
||||
int Dn[MAXPAR+1];
|
||||
|
||||
int ParSize;
|
||||
int PolB[MAXPOL];
|
||||
bool FirstBlockDone;
|
||||
public:
|
||||
RSCoder(int ParSize);
|
||||
void Encode(byte *Data,int DataSize,byte *DestData);
|
||||
bool Decode(byte *Data,int DataSize,int *EraLoc,int EraSize);
|
||||
};
|
||||
|
||||
#endif
|
||||
15
7zip/Compress/Rar29/Original/savepos.hpp
Executable file
15
7zip/Compress/Rar29/Original/savepos.hpp
Executable file
@@ -0,0 +1,15 @@
|
||||
#ifndef _RAR_SAVEPOS_
|
||||
#define _RAR_SAVEPOS_
|
||||
|
||||
class SaveFilePos
|
||||
{
|
||||
private:
|
||||
File *SaveFile;
|
||||
Int64 SavePos;
|
||||
uint CloseCount;
|
||||
public:
|
||||
SaveFilePos(File &SaveFile);
|
||||
~SaveFilePos();
|
||||
};
|
||||
|
||||
#endif
|
||||
52
7zip/Compress/Rar29/Original/scantree.hpp
Executable file
52
7zip/Compress/Rar29/Original/scantree.hpp
Executable file
@@ -0,0 +1,52 @@
|
||||
#ifndef _RAR_SCANTREE_
|
||||
#define _RAR_SCANTREE_
|
||||
|
||||
enum { RECURSE_NONE=0,RECURSE_ALWAYS,RECURSE_WILDCARDS };
|
||||
enum { SCAN_SKIPDIRS=0,SCAN_GETDIRS,SCAN_GETDIRSTWICE,SCAN_GETCURDIRS };
|
||||
enum { SCAN_SUCCESS,SCAN_DONE,SCAN_ERROR,SCAN_NEXT };
|
||||
|
||||
#define MAXSCANDEPTH (NM/2)
|
||||
|
||||
class CommandData;
|
||||
|
||||
class ScanTree
|
||||
{
|
||||
private:
|
||||
bool PrepareMasks();
|
||||
int FindProc(FindData *FindData);
|
||||
|
||||
FindFile *FindStack[MAXSCANDEPTH];
|
||||
int Depth;
|
||||
|
||||
int SetAllMaskDepth;
|
||||
|
||||
StringList *FileMasks;
|
||||
int Recurse;
|
||||
bool GetLinks;
|
||||
int GetDirs;
|
||||
int Errors;
|
||||
|
||||
char CurMask[NM];
|
||||
wchar CurMaskW[NM];
|
||||
char OrigCurMask[NM];
|
||||
wchar OrigCurMaskW[NM];
|
||||
bool SearchAllInRoot;
|
||||
bool FastFindFile;
|
||||
int SpecPathLength;
|
||||
int SpecPathLengthW;
|
||||
|
||||
char ErrArcName[NM];
|
||||
|
||||
CommandData *Cmd;
|
||||
public:
|
||||
ScanTree(StringList *FileMasks,int Recurse,bool GetLinks,int GetDirs);
|
||||
~ScanTree();
|
||||
int GetNext(FindData *FindData);
|
||||
int GetSpecPathLength() {return(SpecPathLength);};
|
||||
int GetSpecPathLengthW() {return(SpecPathLengthW);};
|
||||
int GetErrors() {return(Errors);};
|
||||
void SetErrArcName(const char *Name) {strcpy(ErrArcName,Name);}
|
||||
void SetCommandData(CommandData *Cmd) {ScanTree::Cmd=Cmd;}
|
||||
};
|
||||
|
||||
#endif
|
||||
16
7zip/Compress/Rar29/Original/sha1.hpp
Executable file
16
7zip/Compress/Rar29/Original/sha1.hpp
Executable file
@@ -0,0 +1,16 @@
|
||||
#ifndef _RAR_SHA1_
|
||||
#define _RAR_SHA1_
|
||||
|
||||
#define HW 5
|
||||
|
||||
typedef struct {
|
||||
uint32 state[5];
|
||||
uint32 count[2];
|
||||
unsigned char buffer[64];
|
||||
} hash_context;
|
||||
|
||||
void hash_initial( hash_context * c );
|
||||
void hash_process( hash_context * c, unsigned char * data, unsigned len );
|
||||
void hash_final( hash_context * c, uint32[HW] );
|
||||
|
||||
#endif
|
||||
17
7zip/Compress/Rar29/Original/smallfn.cpp
Executable file
17
7zip/Compress/Rar29/Original/smallfn.cpp
Executable file
@@ -0,0 +1,17 @@
|
||||
#include "rar.hpp"
|
||||
|
||||
int ToPercent(Int64 N1,Int64 N2)
|
||||
{
|
||||
if (N2==0)
|
||||
return(0);
|
||||
if (N2<N1)
|
||||
return(100);
|
||||
return(int64to32(N1*100/N2));
|
||||
}
|
||||
|
||||
|
||||
void RARInitData()
|
||||
{
|
||||
InitCRC();
|
||||
ErrHandler.Clean();
|
||||
}
|
||||
7
7zip/Compress/Rar29/Original/smallfn.hpp
Executable file
7
7zip/Compress/Rar29/Original/smallfn.hpp
Executable file
@@ -0,0 +1,7 @@
|
||||
#ifndef _RAR_SMALLFN_
|
||||
#define _RAR_SMALLFN_
|
||||
|
||||
int ToPercent(Int64 N1,Int64 N2);
|
||||
void RARInitData();
|
||||
|
||||
#endif
|
||||
24
7zip/Compress/Rar29/Original/strfn.hpp
Executable file
24
7zip/Compress/Rar29/Original/strfn.hpp
Executable file
@@ -0,0 +1,24 @@
|
||||
#ifndef _RAR_STRFN_
|
||||
#define _RAR_STRFN_
|
||||
|
||||
const char *NullToEmpty(const char *Str);
|
||||
const wchar *NullToEmpty(const wchar *Str);
|
||||
char *IntNameToExt(const char *Name);
|
||||
void ExtToInt(const char *Src,char *Dest);
|
||||
void IntToExt(const char *Src,char *Dest);
|
||||
char* strlower(char *Str);
|
||||
char* strupper(char *Str);
|
||||
int stricomp(const char *Str1,const char *Str2);
|
||||
int strnicomp(const char *Str1,const char *Str2,int N);
|
||||
char* RemoveEOL(char *Str);
|
||||
char* RemoveLF(char *Str);
|
||||
unsigned int loctolower(byte ch);
|
||||
unsigned int loctoupper(byte ch);
|
||||
|
||||
|
||||
|
||||
bool LowAscii(const char *Str);
|
||||
bool LowAscii(const wchar *Str);
|
||||
|
||||
|
||||
#endif
|
||||
39
7zip/Compress/Rar29/Original/strlist.hpp
Executable file
39
7zip/Compress/Rar29/Original/strlist.hpp
Executable file
@@ -0,0 +1,39 @@
|
||||
#ifndef _RAR_STRLIST_
|
||||
#define _RAR_STRLIST_
|
||||
|
||||
class StringList
|
||||
{
|
||||
private:
|
||||
Array<char> StringData;
|
||||
unsigned int CurPos;
|
||||
|
||||
Array<wchar> StringDataW;
|
||||
unsigned int CurPosW;
|
||||
|
||||
Array<int> PosDataW;
|
||||
uint PosDataItem;
|
||||
|
||||
uint StringsCount;
|
||||
|
||||
uint SaveCurPos[16],SaveCurPosW[16],SavePosDataItem[16],SavePosNumber;
|
||||
public:
|
||||
StringList();
|
||||
~StringList();
|
||||
void Reset();
|
||||
unsigned int AddString(const char *Str);
|
||||
unsigned int AddString(const char *Str,const wchar *StrW);
|
||||
bool GetString(char *Str,int MaxLength);
|
||||
bool GetString(char *Str,wchar *StrW,int MaxLength);
|
||||
bool GetString(char *Str,wchar *StrW,int MaxLength,int StringNum);
|
||||
char* GetString();
|
||||
bool GetString(char **Str,wchar **StrW);
|
||||
char* GetString(unsigned int StringPos);
|
||||
void Rewind();
|
||||
unsigned int ItemsCount() {return(StringsCount);};
|
||||
int GetBufferSize();
|
||||
bool Search(char *Str,wchar *StrW,bool CaseSensitive);
|
||||
void SavePosition();
|
||||
void RestorePosition();
|
||||
};
|
||||
|
||||
#endif
|
||||
241
7zip/Compress/Rar29/Original/suballoc.cpp
Executable file
241
7zip/Compress/Rar29/Original/suballoc.cpp
Executable file
@@ -0,0 +1,241 @@
|
||||
/****************************************************************************
|
||||
* This file is part of PPMd project *
|
||||
* Written and distributed to public domain by Dmitry Shkarin 1997, *
|
||||
* 1999-2000 *
|
||||
* Contents: memory allocation routines *
|
||||
****************************************************************************/
|
||||
|
||||
SubAllocator::SubAllocator()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
|
||||
void SubAllocator::Clean()
|
||||
{
|
||||
SubAllocatorSize=0;
|
||||
}
|
||||
|
||||
|
||||
inline void SubAllocator::InsertNode(void* p,int indx)
|
||||
{
|
||||
((RAR_NODE*) p)->next=FreeList[indx].next;
|
||||
FreeList[indx].next=(RAR_NODE*) p;
|
||||
}
|
||||
|
||||
|
||||
inline void* SubAllocator::RemoveNode(int indx)
|
||||
{
|
||||
RAR_NODE* RetVal=FreeList[indx].next;
|
||||
FreeList[indx].next=RetVal->next;
|
||||
return RetVal;
|
||||
}
|
||||
|
||||
|
||||
inline uint SubAllocator::U2B(int NU)
|
||||
{
|
||||
return /*8*NU+4*NU*/UNIT_SIZE*NU;
|
||||
}
|
||||
|
||||
|
||||
inline void SubAllocator::SplitBlock(void* pv,int OldIndx,int NewIndx)
|
||||
{
|
||||
int i, UDiff=Indx2Units[OldIndx]-Indx2Units[NewIndx];
|
||||
byte* p=((byte*) pv)+U2B(Indx2Units[NewIndx]);
|
||||
if (Indx2Units[i=Units2Indx[UDiff-1]] != UDiff)
|
||||
{
|
||||
InsertNode(p,--i);
|
||||
p += U2B(i=Indx2Units[i]);
|
||||
UDiff -= i;
|
||||
}
|
||||
InsertNode(p,Units2Indx[UDiff-1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SubAllocator::StopSubAllocator()
|
||||
{
|
||||
if ( SubAllocatorSize )
|
||||
{
|
||||
SubAllocatorSize=0;
|
||||
rarfree(HeapStart);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SubAllocator::StartSubAllocator(int SASize)
|
||||
{
|
||||
uint t=SASize << 20;
|
||||
if (SubAllocatorSize == t)
|
||||
return TRUE;
|
||||
StopSubAllocator();
|
||||
uint AllocSize=t/FIXED_UNIT_SIZE*UNIT_SIZE+UNIT_SIZE;
|
||||
if ((HeapStart=(byte *)rarmalloc(AllocSize)) == NULL)
|
||||
{
|
||||
ErrHandler.MemoryError();
|
||||
return FALSE;
|
||||
}
|
||||
HeapEnd=HeapStart+AllocSize-UNIT_SIZE;
|
||||
SubAllocatorSize=t;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void SubAllocator::InitSubAllocator()
|
||||
{
|
||||
int i, k;
|
||||
memset(FreeList,0,sizeof(FreeList));
|
||||
pText=HeapStart;
|
||||
uint Size2=FIXED_UNIT_SIZE*(SubAllocatorSize/8/FIXED_UNIT_SIZE*7);
|
||||
uint RealSize2=Size2/FIXED_UNIT_SIZE*UNIT_SIZE;
|
||||
uint Size1=SubAllocatorSize-Size2;
|
||||
uint RealSize1=Size1/FIXED_UNIT_SIZE*UNIT_SIZE+Size1%FIXED_UNIT_SIZE;
|
||||
HiUnit=HeapStart+SubAllocatorSize;
|
||||
LoUnit=UnitsStart=HeapStart+RealSize1;
|
||||
FakeUnitsStart=HeapStart+Size1;
|
||||
HiUnit=LoUnit+RealSize2;
|
||||
for (i=0,k=1;i < N1 ;i++,k += 1)
|
||||
Indx2Units[i]=k;
|
||||
for (k++;i < N1+N2 ;i++,k += 2)
|
||||
Indx2Units[i]=k;
|
||||
for (k++;i < N1+N2+N3 ;i++,k += 3)
|
||||
Indx2Units[i]=k;
|
||||
for (k++;i < N1+N2+N3+N4;i++,k += 4)
|
||||
Indx2Units[i]=k;
|
||||
for (GlueCount=k=i=0;k < 128;k++)
|
||||
{
|
||||
i += (Indx2Units[i] < k+1);
|
||||
Units2Indx[k]=i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void SubAllocator::GlueFreeBlocks()
|
||||
{
|
||||
RAR_MEM_BLK s0, * p, * p1;
|
||||
int i, k, sz;
|
||||
if (LoUnit != HiUnit)
|
||||
*LoUnit=0;
|
||||
for (i=0, s0.next=s0.prev=&s0;i < N_INDEXES;i++)
|
||||
while ( FreeList[i].next )
|
||||
{
|
||||
p=(RAR_MEM_BLK*)RemoveNode(i);
|
||||
p->insertAt(&s0);
|
||||
p->Stamp=0xFFFF;
|
||||
p->NU=Indx2Units[i];
|
||||
}
|
||||
for (p=s0.next;p != &s0;p=p->next)
|
||||
while ((p1=p+p->NU)->Stamp == 0xFFFF && int(p->NU)+p1->NU < 0x10000)
|
||||
{
|
||||
p1->remove();
|
||||
p->NU += p1->NU;
|
||||
}
|
||||
while ((p=s0.next) != &s0)
|
||||
{
|
||||
for (p->remove(), sz=p->NU;sz > 128;sz -= 128, p += 128)
|
||||
InsertNode(p,N_INDEXES-1);
|
||||
if (Indx2Units[i=Units2Indx[sz-1]] != sz)
|
||||
{
|
||||
k=sz-Indx2Units[--i];
|
||||
InsertNode(p+(sz-k),k-1);
|
||||
}
|
||||
InsertNode(p,i);
|
||||
}
|
||||
}
|
||||
|
||||
void* SubAllocator::AllocUnitsRare(int indx)
|
||||
{
|
||||
if ( !GlueCount )
|
||||
{
|
||||
GlueCount = 255;
|
||||
GlueFreeBlocks();
|
||||
if ( FreeList[indx].next )
|
||||
return RemoveNode(indx);
|
||||
}
|
||||
int i=indx;
|
||||
do
|
||||
{
|
||||
if (++i == N_INDEXES)
|
||||
{
|
||||
GlueCount--;
|
||||
i=U2B(Indx2Units[indx]);
|
||||
int j=12*Indx2Units[indx];
|
||||
if (FakeUnitsStart-pText > j)
|
||||
{
|
||||
FakeUnitsStart-=j;
|
||||
UnitsStart -= i;
|
||||
return(UnitsStart);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
} while ( !FreeList[i].next );
|
||||
void* RetVal=RemoveNode(i);
|
||||
SplitBlock(RetVal,i,indx);
|
||||
return RetVal;
|
||||
}
|
||||
|
||||
|
||||
inline void* SubAllocator::AllocUnits(int NU)
|
||||
{
|
||||
int indx=Units2Indx[NU-1];
|
||||
if ( FreeList[indx].next )
|
||||
return RemoveNode(indx);
|
||||
void* RetVal=LoUnit;
|
||||
LoUnit += U2B(Indx2Units[indx]);
|
||||
if (LoUnit <= HiUnit)
|
||||
return RetVal;
|
||||
LoUnit -= U2B(Indx2Units[indx]);
|
||||
return AllocUnitsRare(indx);
|
||||
}
|
||||
|
||||
|
||||
void* SubAllocator::AllocContext()
|
||||
{
|
||||
if (HiUnit != LoUnit)
|
||||
return (HiUnit -= UNIT_SIZE);
|
||||
if ( FreeList->next )
|
||||
return RemoveNode(0);
|
||||
return AllocUnitsRare(0);
|
||||
}
|
||||
|
||||
|
||||
void* SubAllocator::ExpandUnits(void* OldPtr,int OldNU)
|
||||
{
|
||||
int i0=Units2Indx[OldNU-1], i1=Units2Indx[OldNU-1+1];
|
||||
if (i0 == i1)
|
||||
return OldPtr;
|
||||
void* ptr=AllocUnits(OldNU+1);
|
||||
if ( ptr )
|
||||
{
|
||||
memcpy(ptr,OldPtr,U2B(OldNU));
|
||||
InsertNode(OldPtr,i0);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
void* SubAllocator::ShrinkUnits(void* OldPtr,int OldNU,int NewNU)
|
||||
{
|
||||
int i0=Units2Indx[OldNU-1], i1=Units2Indx[NewNU-1];
|
||||
if (i0 == i1)
|
||||
return OldPtr;
|
||||
if ( FreeList[i1].next )
|
||||
{
|
||||
void* ptr=RemoveNode(i1);
|
||||
memcpy(ptr,OldPtr,U2B(NewNU));
|
||||
InsertNode(OldPtr,i0);
|
||||
return ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
SplitBlock(OldPtr,i0,i1);
|
||||
return OldPtr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SubAllocator::FreeUnits(void* ptr,int OldNU)
|
||||
{
|
||||
InsertNode(ptr,Units2Indx[OldNU-1]);
|
||||
}
|
||||
81
7zip/Compress/Rar29/Original/suballoc.hpp
Executable file
81
7zip/Compress/Rar29/Original/suballoc.hpp
Executable file
@@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
* This file is part of PPMd project *
|
||||
* Written and distributed to public domain by Dmitry Shkarin 1997, *
|
||||
* 1999-2000 *
|
||||
* Contents: interface to memory allocation routines *
|
||||
****************************************************************************/
|
||||
#if !defined(_SUBALLOC_H_)
|
||||
#define _SUBALLOC_H_
|
||||
|
||||
const int N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
|
||||
const int N_INDEXES=N1+N2+N3+N4;
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define _PACK_ATTR __attribute__ ((packed))
|
||||
#else
|
||||
#define _PACK_ATTR
|
||||
#endif /* defined(__GNUC__) */
|
||||
|
||||
#pragma pack(1)
|
||||
struct RAR_MEM_BLK
|
||||
{
|
||||
ushort Stamp, NU;
|
||||
RAR_MEM_BLK* next, * prev;
|
||||
void insertAt(RAR_MEM_BLK* p)
|
||||
{
|
||||
next=(prev=p)->next;
|
||||
p->next=next->prev=this;
|
||||
}
|
||||
void remove()
|
||||
{
|
||||
prev->next=next;
|
||||
next->prev=prev;
|
||||
}
|
||||
} _PACK_ATTR;
|
||||
|
||||
#ifdef _AIX
|
||||
#pragma pack(pop)
|
||||
#else
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
|
||||
struct RAR_NODE
|
||||
{
|
||||
RAR_NODE* next;
|
||||
};
|
||||
|
||||
class SubAllocator
|
||||
{
|
||||
private:
|
||||
inline void InsertNode(void* p,int indx);
|
||||
inline void* RemoveNode(int indx);
|
||||
inline uint U2B(int NU);
|
||||
inline void SplitBlock(void* pv,int OldIndx,int NewIndx);
|
||||
uint GetUsedMemory();
|
||||
inline void GlueFreeBlocks();
|
||||
void* AllocUnitsRare(int indx);
|
||||
|
||||
long SubAllocatorSize;
|
||||
byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount;
|
||||
byte *HeapStart,*LoUnit, *HiUnit;
|
||||
struct RAR_NODE FreeList[N_INDEXES];
|
||||
public:
|
||||
SubAllocator();
|
||||
~SubAllocator() {StopSubAllocator();}
|
||||
void Clean();
|
||||
bool StartSubAllocator(int SASize);
|
||||
void StopSubAllocator();
|
||||
void InitSubAllocator();
|
||||
inline void* AllocContext();
|
||||
inline void* AllocUnits(int NU);
|
||||
inline void* ExpandUnits(void* ptr,int OldNU);
|
||||
inline void* ShrinkUnits(void* ptr,int OldNU,int NewNU);
|
||||
inline void FreeUnits(void* ptr,int OldNU);
|
||||
long GetAllocatedMemory() {return(SubAllocatorSize);};
|
||||
|
||||
byte *pText, *UnitsStart,*HeapEnd,*FakeUnitsStart;
|
||||
};
|
||||
|
||||
|
||||
#endif /* !defined(_SUBALLOC_H_) */
|
||||
79
7zip/Compress/Rar29/Original/system.cpp
Executable file
79
7zip/Compress/Rar29/Original/system.cpp
Executable file
@@ -0,0 +1,79 @@
|
||||
#include "rar.hpp"
|
||||
|
||||
#ifndef _WIN_CE
|
||||
static int SleepTime=0;
|
||||
|
||||
void InitSystemOptions(int SleepTime)
|
||||
{
|
||||
::SleepTime=SleepTime;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(SFX_MODULE) && !defined(_WIN_CE)
|
||||
|
||||
#if defined(_WIN_32) && !defined(BELOW_NORMAL_PRIORITY_CLASS)
|
||||
#define BELOW_NORMAL_PRIORITY_CLASS 0x00004000
|
||||
#define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
|
||||
#endif
|
||||
|
||||
void SetPriority(int Priority)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
uint PriorityClass;
|
||||
int PriorityLevel;
|
||||
if (Priority<1 || Priority>15)
|
||||
return;
|
||||
|
||||
if (Priority==1)
|
||||
{
|
||||
PriorityClass=IDLE_PRIORITY_CLASS;
|
||||
PriorityLevel=THREAD_PRIORITY_IDLE;
|
||||
}
|
||||
else
|
||||
if (Priority<7)
|
||||
{
|
||||
PriorityClass=IDLE_PRIORITY_CLASS;
|
||||
PriorityLevel=Priority-4;
|
||||
}
|
||||
else
|
||||
if (Priority==7)
|
||||
{
|
||||
PriorityClass=BELOW_NORMAL_PRIORITY_CLASS;
|
||||
PriorityLevel=THREAD_PRIORITY_ABOVE_NORMAL;
|
||||
}
|
||||
else
|
||||
if (Priority<10)
|
||||
{
|
||||
PriorityClass=NORMAL_PRIORITY_CLASS;
|
||||
PriorityLevel=Priority-7;
|
||||
}
|
||||
else
|
||||
if (Priority==10)
|
||||
{
|
||||
PriorityClass=ABOVE_NORMAL_PRIORITY_CLASS;
|
||||
PriorityLevel=THREAD_PRIORITY_NORMAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
PriorityClass=HIGH_PRIORITY_CLASS;
|
||||
PriorityLevel=Priority-13;
|
||||
}
|
||||
SetPriorityClass(GetCurrentProcess(),PriorityClass);
|
||||
SetThreadPriority(GetCurrentThread(),PriorityLevel);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void Wait()
|
||||
{
|
||||
#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE)
|
||||
if (SleepTime!=0)
|
||||
Sleep(SleepTime);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
10
7zip/Compress/Rar29/Original/system.hpp
Executable file
10
7zip/Compress/Rar29/Original/system.hpp
Executable file
@@ -0,0 +1,10 @@
|
||||
#ifndef _RAR_SYSTEM_
|
||||
#define _RAR_SYSTEM_
|
||||
|
||||
void InitSystemOptions(int SleepTime);
|
||||
void SetPriority(int Priority);
|
||||
void Wait();
|
||||
bool EmailFile(char *FileName,char *MailTo);
|
||||
void Shutdown();
|
||||
|
||||
#endif
|
||||
57
7zip/Compress/Rar29/Original/timefn.hpp
Executable file
57
7zip/Compress/Rar29/Original/timefn.hpp
Executable file
@@ -0,0 +1,57 @@
|
||||
#ifndef _RAR_TIMEFN_
|
||||
#define _RAR_TIMEFN_
|
||||
|
||||
struct RarLocalTime
|
||||
{
|
||||
uint Year;
|
||||
uint Month;
|
||||
uint Day;
|
||||
uint Hour;
|
||||
uint Minute;
|
||||
uint Second;
|
||||
uint Reminder;
|
||||
uint wDay;
|
||||
uint yDay;
|
||||
};
|
||||
|
||||
|
||||
class RarTime
|
||||
{
|
||||
private:
|
||||
Int64 GetRaw();
|
||||
void SetRaw(Int64 RawTime);
|
||||
|
||||
RarLocalTime rlt;
|
||||
|
||||
Int64 Time;
|
||||
public:
|
||||
RarTime();
|
||||
#ifdef _WIN_32
|
||||
RarTime& operator =(FILETIME &ft);
|
||||
void GetWin32(FILETIME *ft);
|
||||
#endif
|
||||
#if defined(_UNIX) || defined(_EMX)
|
||||
RarTime& operator =(time_t ut);
|
||||
time_t GetUnix();
|
||||
#endif
|
||||
bool operator == (RarTime &rt);
|
||||
bool operator < (RarTime &rt);
|
||||
bool operator <= (RarTime &rt);
|
||||
bool operator > (RarTime &rt);
|
||||
bool operator >= (RarTime &rt);
|
||||
void GetLocal(RarLocalTime *lt) {*lt=rlt;}
|
||||
void SetLocal(RarLocalTime *lt) {rlt=*lt;}
|
||||
uint GetDos();
|
||||
void SetDos(uint DosTime);
|
||||
void GetText(char *DateStr,bool FullYear);
|
||||
void SetIsoText(char *TimeText);
|
||||
void SetAgeText(char *TimeText);
|
||||
void SetCurrentTime();
|
||||
void Reset() {rlt.Year=0;}
|
||||
bool IsSet() {return(rlt.Year!=0);}
|
||||
};
|
||||
|
||||
const char *GetMonthName(int Month);
|
||||
bool IsLeapYear(int Year);
|
||||
|
||||
#endif
|
||||
9
7zip/Compress/Rar29/Original/ulinks.hpp
Executable file
9
7zip/Compress/Rar29/Original/ulinks.hpp
Executable file
@@ -0,0 +1,9 @@
|
||||
#ifndef _RAR_ULINKS_
|
||||
#define _RAR_ULINKS_
|
||||
|
||||
void SaveLinkData(ComprDataIO &DataIO,Archive &TempArc,FileHeader &hd,
|
||||
char *Name);
|
||||
int ExtractLink(ComprDataIO &DataIO,Archive &Arc,char *DestName,
|
||||
uint &LinkCRC,bool Create);
|
||||
|
||||
#endif
|
||||
82
7zip/Compress/Rar29/Original/unicode.hpp
Executable file
82
7zip/Compress/Rar29/Original/unicode.hpp
Executable file
@@ -0,0 +1,82 @@
|
||||
#ifndef _RAR_UNICODE_
|
||||
#define _RAR_UNICODE_
|
||||
|
||||
#ifndef _EMX
|
||||
#define MBFUNCTIONS
|
||||
#endif
|
||||
|
||||
#if defined(MBFUNCTIONS) || defined(_WIN_32) || defined(_EMX) && !defined(_DJGPP)
|
||||
#define UNICODE_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifdef _WIN_32
|
||||
#define DBCS_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifdef _EMX
|
||||
int uni_init(int codepage);
|
||||
int uni_done();
|
||||
#endif
|
||||
|
||||
bool WideToChar(const wchar *Src,char *Dest,int DestSize=0x10000000);
|
||||
bool CharToWide(const char *Src,wchar *Dest,int DestSize=0x10000000);
|
||||
byte* WideToRaw(const wchar *Src,byte *Dest,int DestSize=0x10000000);
|
||||
wchar* RawToWide(const byte *Src,wchar *Dest,int DestSize=0x10000000);
|
||||
void WideToUtf(const wchar *Src,char *Dest,int DestSize);
|
||||
void UtfToWide(const char *Src,wchar *Dest,int DestSize);
|
||||
bool UnicodeEnabled();
|
||||
|
||||
int strlenw(const wchar *str);
|
||||
wchar* strcpyw(wchar *dest,const wchar *src);
|
||||
wchar* strncpyw(wchar *dest,const wchar *src,int n);
|
||||
wchar* strcatw(wchar *dest,const wchar *src);
|
||||
wchar* strncatw(wchar *dest,const wchar *src,int n);
|
||||
int strcmpw(const wchar *s1,const wchar *s2);
|
||||
int strncmpw(const wchar *s1,const wchar *s2,int n);
|
||||
int stricmpw(const wchar *s1,const wchar *s2);
|
||||
int strnicmpw(const wchar *s1,const wchar *s2,int n);
|
||||
wchar *strchrw(const wchar *s,int c);
|
||||
wchar* strrchrw(const wchar *s,int c);
|
||||
wchar* strpbrkw(const wchar *s1,const wchar *s2);
|
||||
wchar* strlowerw(wchar *Str);
|
||||
wchar* strupperw(wchar *Str);
|
||||
int toupperw(int ch);
|
||||
int atoiw(const wchar *s);
|
||||
|
||||
#ifdef DBCS_SUPPORTED
|
||||
class SupportDBCS
|
||||
{
|
||||
public:
|
||||
SupportDBCS();
|
||||
void Init();
|
||||
|
||||
char* charnext(const char *s);
|
||||
uint strlend(const char *s);
|
||||
char *strchrd(const char *s, int c);
|
||||
char *strrchrd(const char *s, int c);
|
||||
void copychrd(char *dest,const char *src);
|
||||
|
||||
bool IsLeadByte[256];
|
||||
bool DBCSMode;
|
||||
};
|
||||
|
||||
extern SupportDBCS gdbcs;
|
||||
|
||||
inline char* charnext(const char *s) {return (char *)(gdbcs.DBCSMode ? gdbcs.charnext(s):s+1);}
|
||||
inline uint strlend(const char *s) {return (uint)(gdbcs.DBCSMode ? gdbcs.strlend(s):strlen(s));}
|
||||
inline char* strchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strchrd(s,c):strchr(s,c));}
|
||||
inline char* strrchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strrchrd(s,c):strrchr(s,c));}
|
||||
inline void copychrd(char *dest,const char *src) {if (gdbcs.DBCSMode) gdbcs.copychrd(dest,src); else *dest=*src;}
|
||||
inline bool IsDBCSMode() {return(gdbcs.DBCSMode);}
|
||||
inline void InitDBCS() {gdbcs.Init();}
|
||||
|
||||
#else
|
||||
#define charnext(s) ((s)+1)
|
||||
#define strlend strlen
|
||||
#define strchrd strchr
|
||||
#define strrchrd strrchr
|
||||
#define IsDBCSMode() (true)
|
||||
inline void copychrd(char *dest,const char *src) {*dest=*src;}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
939
7zip/Compress/Rar29/Original/unpack.cpp
Executable file
939
7zip/Compress/Rar29/Original/unpack.cpp
Executable file
@@ -0,0 +1,939 @@
|
||||
#include "rar.hpp"
|
||||
|
||||
#include "coder.cpp"
|
||||
#include "suballoc.cpp"
|
||||
#include "model.cpp"
|
||||
#ifndef SFX_MODULE
|
||||
#include "unpack15.cpp"
|
||||
// Igor Pavlov
|
||||
// #include "unpack20.cpp"
|
||||
#endif
|
||||
|
||||
Unpack::Unpack(ComprDataIO *DataIO)
|
||||
{
|
||||
UnpIO=DataIO;
|
||||
Window=NULL;
|
||||
ExternalWindow=false;
|
||||
Suspended=false;
|
||||
UnpAllBuf=false;
|
||||
UnpSomeRead=false;
|
||||
}
|
||||
|
||||
|
||||
Unpack::~Unpack()
|
||||
{
|
||||
if (Window!=NULL && !ExternalWindow)
|
||||
delete[] Window;
|
||||
InitFilters();
|
||||
}
|
||||
|
||||
|
||||
void Unpack::Init(byte *Window)
|
||||
{
|
||||
if (Window==NULL)
|
||||
{
|
||||
Unpack::Window=new byte[MAXWINSIZE];
|
||||
#ifndef ALLOW_EXCEPTIONS
|
||||
if (Unpack::Window==NULL)
|
||||
ErrHandler.MemoryError();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
Unpack::Window=Window;
|
||||
ExternalWindow=true;
|
||||
}
|
||||
UnpInitData(false);
|
||||
}
|
||||
|
||||
|
||||
void Unpack::DoUnpack(int Method,bool Solid)
|
||||
{
|
||||
switch(Method)
|
||||
{
|
||||
#ifndef SFX_MODULE
|
||||
case 15:
|
||||
Unpack15(Solid);
|
||||
break;
|
||||
// Igor Pavlov
|
||||
/*
|
||||
case 20:
|
||||
case 26:
|
||||
Unpack20(Solid);
|
||||
break;
|
||||
*/
|
||||
#endif
|
||||
case 29:
|
||||
Unpack29(Solid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void Unpack::InsertOldDist(unsigned int Distance)
|
||||
{
|
||||
OldDist[3]=OldDist[2];
|
||||
OldDist[2]=OldDist[1];
|
||||
OldDist[1]=OldDist[0];
|
||||
OldDist[0]=Distance;
|
||||
}
|
||||
|
||||
|
||||
inline void Unpack::InsertLastMatch(unsigned int Length,unsigned int Distance)
|
||||
{
|
||||
LastDist=Distance;
|
||||
LastLength=Length;
|
||||
}
|
||||
|
||||
|
||||
void Unpack::CopyString(unsigned int Length,unsigned int Distance)
|
||||
{
|
||||
unsigned int DestPtr=UnpPtr-Distance;
|
||||
if (DestPtr<MAXWINSIZE-260 && UnpPtr<MAXWINSIZE-260)
|
||||
{
|
||||
Window[UnpPtr++]=Window[DestPtr++];
|
||||
while (--Length>0)
|
||||
Window[UnpPtr++]=Window[DestPtr++];
|
||||
}
|
||||
else
|
||||
while (Length--)
|
||||
{
|
||||
Window[UnpPtr]=Window[DestPtr++ & MAXWINMASK];
|
||||
UnpPtr=(UnpPtr+1) & MAXWINMASK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int Unpack::DecodeNumber(struct Decode *Dec)
|
||||
{
|
||||
unsigned int Bits;
|
||||
unsigned int BitField=getbits() & 0xfffe;
|
||||
if (BitField<Dec->DecodeLen[8])
|
||||
if (BitField<Dec->DecodeLen[4])
|
||||
if (BitField<Dec->DecodeLen[2])
|
||||
if (BitField<Dec->DecodeLen[1])
|
||||
Bits=1;
|
||||
else
|
||||
Bits=2;
|
||||
else
|
||||
if (BitField<Dec->DecodeLen[3])
|
||||
Bits=3;
|
||||
else
|
||||
Bits=4;
|
||||
else
|
||||
if (BitField<Dec->DecodeLen[6])
|
||||
if (BitField<Dec->DecodeLen[5])
|
||||
Bits=5;
|
||||
else
|
||||
Bits=6;
|
||||
else
|
||||
if (BitField<Dec->DecodeLen[7])
|
||||
Bits=7;
|
||||
else
|
||||
Bits=8;
|
||||
else
|
||||
if (BitField<Dec->DecodeLen[12])
|
||||
if (BitField<Dec->DecodeLen[10])
|
||||
if (BitField<Dec->DecodeLen[9])
|
||||
Bits=9;
|
||||
else
|
||||
Bits=10;
|
||||
else
|
||||
if (BitField<Dec->DecodeLen[11])
|
||||
Bits=11;
|
||||
else
|
||||
Bits=12;
|
||||
else
|
||||
if (BitField<Dec->DecodeLen[14])
|
||||
if (BitField<Dec->DecodeLen[13])
|
||||
Bits=13;
|
||||
else
|
||||
Bits=14;
|
||||
else
|
||||
Bits=15;
|
||||
|
||||
addbits(Bits);
|
||||
unsigned int N=Dec->DecodePos[Bits]+((BitField-Dec->DecodeLen[Bits-1])>>(16-Bits));
|
||||
if (N>=Dec->MaxNum)
|
||||
N=0;
|
||||
return(Dec->DecodeNum[N]);
|
||||
}
|
||||
|
||||
|
||||
void Unpack::Unpack29(bool Solid)
|
||||
{
|
||||
static unsigned char LDecode[]={0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224};
|
||||
static unsigned char LBits[]= {0,0,0,0,0,0,0,0,1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5};
|
||||
static int DDecode[DC];
|
||||
static byte DBits[DC];
|
||||
static int DBitLengthCounts[]= {4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,14,0,12};
|
||||
static unsigned char SDDecode[]={0,4,8,16,32,64,128,192};
|
||||
static unsigned char SDBits[]= {2,2,3, 4, 5, 6, 6, 6};
|
||||
unsigned int Bits;
|
||||
|
||||
if (DDecode[1]==0)
|
||||
{
|
||||
int Dist=0,BitLength=0,Slot=0;
|
||||
for (int I=0;I<sizeof(DBitLengthCounts)/sizeof(DBitLengthCounts[0]);I++,BitLength++)
|
||||
for (int J=0;J<DBitLengthCounts[I];J++,Slot++,Dist+=(1<<BitLength))
|
||||
{
|
||||
DDecode[Slot]=Dist;
|
||||
DBits[Slot]=BitLength;
|
||||
}
|
||||
}
|
||||
|
||||
FileExtracted=true;
|
||||
|
||||
if (!Suspended)
|
||||
{
|
||||
UnpInitData(Solid);
|
||||
if (!UnpReadBuf())
|
||||
return;
|
||||
if ((!Solid || !TablesRead) && !ReadTables())
|
||||
return;
|
||||
}
|
||||
|
||||
if (PPMError)
|
||||
return;
|
||||
|
||||
while (true)
|
||||
{
|
||||
UnpPtr&=MAXWINMASK;
|
||||
|
||||
if (InAddr>ReadBorder)
|
||||
{
|
||||
if (!UnpReadBuf())
|
||||
break;
|
||||
}
|
||||
if (((WrPtr-UnpPtr) & MAXWINMASK)<260 && WrPtr!=UnpPtr)
|
||||
{
|
||||
UnpWriteBuf();
|
||||
if (WrittenFileSize>DestUnpSize)
|
||||
return;
|
||||
if (Suspended)
|
||||
{
|
||||
FileExtracted=false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (UnpBlockType==BLOCK_PPM)
|
||||
{
|
||||
int Ch=PPM.DecodeChar();
|
||||
if (Ch==-1)
|
||||
{
|
||||
PPMError=true;
|
||||
break;
|
||||
}
|
||||
if (Ch==PPMEscChar)
|
||||
{
|
||||
int NextCh=PPM.DecodeChar();
|
||||
if (NextCh==0)
|
||||
{
|
||||
if (!ReadTables())
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (NextCh==2 || NextCh==-1)
|
||||
break;
|
||||
if (NextCh==3)
|
||||
{
|
||||
if (!ReadVMCodePPM())
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (NextCh==4)
|
||||
{
|
||||
unsigned int Distance=0,Length;
|
||||
bool Failed=false;
|
||||
for (int I=0;I<4 && !Failed;I++)
|
||||
{
|
||||
int Ch=PPM.DecodeChar();
|
||||
if (Ch==-1)
|
||||
Failed=true;
|
||||
else
|
||||
if (I==3)
|
||||
Length=(byte)Ch;
|
||||
else
|
||||
Distance=(Distance<<8)+(byte)Ch;
|
||||
}
|
||||
if (Failed)
|
||||
break;
|
||||
CopyString(Length+32,Distance+2);
|
||||
continue;
|
||||
}
|
||||
if (NextCh==5)
|
||||
{
|
||||
int Length=PPM.DecodeChar();
|
||||
if (Length==-1)
|
||||
break;
|
||||
CopyString(Length+4,1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Window[UnpPtr++]=Ch;
|
||||
continue;
|
||||
}
|
||||
|
||||
int Number=DecodeNumber((struct Decode *)&LD);
|
||||
if (Number<256)
|
||||
{
|
||||
Window[UnpPtr++]=(byte)Number;
|
||||
continue;
|
||||
}
|
||||
if (Number>=271)
|
||||
{
|
||||
int Length=LDecode[Number-=271]+3;
|
||||
if ((Bits=LBits[Number])>0)
|
||||
{
|
||||
Length+=getbits()>>(16-Bits);
|
||||
addbits(Bits);
|
||||
}
|
||||
|
||||
int DistNumber=DecodeNumber((struct Decode *)&DD);
|
||||
unsigned int Distance=DDecode[DistNumber]+1;
|
||||
if ((Bits=DBits[DistNumber])>0)
|
||||
{
|
||||
if (DistNumber>9)
|
||||
{
|
||||
if (Bits>4)
|
||||
{
|
||||
Distance+=((getbits()>>(20-Bits))<<4);
|
||||
addbits(Bits-4);
|
||||
}
|
||||
if (LowDistRepCount>0)
|
||||
{
|
||||
LowDistRepCount--;
|
||||
Distance+=PrevLowDist;
|
||||
}
|
||||
else
|
||||
{
|
||||
int LowDist=DecodeNumber((struct Decode *)&LDD);
|
||||
if (LowDist==16)
|
||||
{
|
||||
LowDistRepCount=LOW_DIST_REP_COUNT-1;
|
||||
Distance+=PrevLowDist;
|
||||
}
|
||||
else
|
||||
{
|
||||
Distance+=LowDist;
|
||||
PrevLowDist=LowDist;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Distance+=getbits()>>(16-Bits);
|
||||
addbits(Bits);
|
||||
}
|
||||
}
|
||||
|
||||
if (Distance>=0x2000)
|
||||
{
|
||||
Length++;
|
||||
if (Distance>=0x40000L)
|
||||
Length++;
|
||||
}
|
||||
|
||||
InsertOldDist(Distance);
|
||||
InsertLastMatch(Length,Distance);
|
||||
CopyString(Length,Distance);
|
||||
continue;
|
||||
}
|
||||
if (Number==256)
|
||||
{
|
||||
if (!ReadEndOfBlock())
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (Number==257)
|
||||
{
|
||||
if (!ReadVMCode())
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (Number==258)
|
||||
{
|
||||
if (LastLength!=0)
|
||||
CopyString(LastLength,LastDist);
|
||||
continue;
|
||||
}
|
||||
if (Number<263)
|
||||
{
|
||||
int DistNum=Number-259;
|
||||
unsigned int Distance=OldDist[DistNum];
|
||||
for (int I=DistNum;I>0;I--)
|
||||
OldDist[I]=OldDist[I-1];
|
||||
OldDist[0]=Distance;
|
||||
|
||||
int LengthNumber=DecodeNumber((struct Decode *)&RD);
|
||||
int Length=LDecode[LengthNumber]+2;
|
||||
if ((Bits=LBits[LengthNumber])>0)
|
||||
{
|
||||
Length+=getbits()>>(16-Bits);
|
||||
addbits(Bits);
|
||||
}
|
||||
InsertLastMatch(Length,Distance);
|
||||
CopyString(Length,Distance);
|
||||
continue;
|
||||
}
|
||||
if (Number<272)
|
||||
{
|
||||
unsigned int Distance=SDDecode[Number-=263]+1;
|
||||
if ((Bits=SDBits[Number])>0)
|
||||
{
|
||||
Distance+=getbits()>>(16-Bits);
|
||||
addbits(Bits);
|
||||
}
|
||||
InsertOldDist(Distance);
|
||||
InsertLastMatch(2,Distance);
|
||||
CopyString(2,Distance);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
UnpWriteBuf();
|
||||
}
|
||||
|
||||
|
||||
bool Unpack::ReadEndOfBlock()
|
||||
{
|
||||
unsigned int BitField=getbits();
|
||||
bool NewTable,NewFile=false;
|
||||
if (BitField & 0x8000)
|
||||
{
|
||||
NewTable=true;
|
||||
addbits(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewFile=true;
|
||||
|
||||
// Igor Pavlov
|
||||
NewTable = ((BitField & 0x4000) != 0);
|
||||
|
||||
addbits(2);
|
||||
}
|
||||
TablesRead=!NewTable;
|
||||
return !(NewFile || NewTable && !ReadTables());
|
||||
}
|
||||
|
||||
|
||||
bool Unpack::ReadVMCode()
|
||||
{
|
||||
unsigned int FirstByte=getbits()>>8;
|
||||
addbits(8);
|
||||
int Length=(FirstByte & 7)+1;
|
||||
if (Length==7)
|
||||
{
|
||||
Length=(getbits()>>8)+7;
|
||||
addbits(8);
|
||||
}
|
||||
else
|
||||
if (Length==8)
|
||||
{
|
||||
Length=getbits();
|
||||
addbits(16);
|
||||
}
|
||||
Array<byte> VMCode(Length);
|
||||
for (int I=0;I<Length;I++)
|
||||
{
|
||||
if (InAddr>=ReadTop-1 && !UnpReadBuf() && I<Length-1)
|
||||
return(false);
|
||||
VMCode[I]=getbits()>>8;
|
||||
addbits(8);
|
||||
}
|
||||
return(AddVMCode(FirstByte,&VMCode[0],Length));
|
||||
}
|
||||
|
||||
|
||||
bool Unpack::ReadVMCodePPM()
|
||||
{
|
||||
unsigned int FirstByte=PPM.DecodeChar();
|
||||
if ((int)FirstByte==-1)
|
||||
return(false);
|
||||
int Length=(FirstByte & 7)+1;
|
||||
if (Length==7)
|
||||
{
|
||||
int B1=PPM.DecodeChar();
|
||||
if (B1==-1)
|
||||
return(false);
|
||||
Length=B1+7;
|
||||
}
|
||||
else
|
||||
if (Length==8)
|
||||
{
|
||||
int B1=PPM.DecodeChar();
|
||||
if (B1==-1)
|
||||
return(false);
|
||||
int B2=PPM.DecodeChar();
|
||||
if (B2==-1)
|
||||
return(false);
|
||||
Length=B1*256+B2;
|
||||
}
|
||||
Array<byte> VMCode(Length);
|
||||
for (int I=0;I<Length;I++)
|
||||
{
|
||||
int Ch=PPM.DecodeChar();
|
||||
if (Ch==-1)
|
||||
return(false);
|
||||
VMCode[I]=Ch;
|
||||
}
|
||||
return(AddVMCode(FirstByte,&VMCode[0],Length));
|
||||
}
|
||||
|
||||
|
||||
bool Unpack::AddVMCode(unsigned int FirstByte,byte *Code,int CodeSize)
|
||||
{
|
||||
BitInput Inp;
|
||||
Inp.InitBitInput();
|
||||
memcpy(Inp.InBuf,Code,Min(BitInput::MAX_SIZE,CodeSize));
|
||||
VM.Init();
|
||||
|
||||
uint FiltPos;
|
||||
if (FirstByte & 0x80)
|
||||
{
|
||||
FiltPos=RarVM::ReadData(Inp);
|
||||
if (FiltPos==0)
|
||||
InitFilters();
|
||||
else
|
||||
FiltPos--;
|
||||
}
|
||||
else
|
||||
FiltPos=LastFilter;
|
||||
if (FiltPos>Filters.Size() || FiltPos>OldFilterLengths.Size())
|
||||
return(false);
|
||||
LastFilter=FiltPos;
|
||||
bool NewFilter=(FiltPos==Filters.Size());
|
||||
|
||||
UnpackFilter *Filter;
|
||||
if (NewFilter)
|
||||
{
|
||||
Filters.Add(1);
|
||||
Filters[Filters.Size()-1]=Filter=new UnpackFilter;
|
||||
OldFilterLengths.Add(1);
|
||||
Filter->ExecCount=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Filter=Filters[FiltPos];
|
||||
Filter->ExecCount++;
|
||||
}
|
||||
|
||||
UnpackFilter *StackFilter=new UnpackFilter;
|
||||
|
||||
int EmptyCount=0;
|
||||
for (int I=0;I<PrgStack.Size();I++)
|
||||
{
|
||||
PrgStack[I-EmptyCount]=PrgStack[I];
|
||||
if (PrgStack[I]==NULL)
|
||||
EmptyCount++;
|
||||
if (EmptyCount>0)
|
||||
PrgStack[I]=NULL;
|
||||
}
|
||||
if (EmptyCount==0)
|
||||
{
|
||||
PrgStack.Add(1);
|
||||
EmptyCount=1;
|
||||
}
|
||||
int StackPos=PrgStack.Size()-EmptyCount;
|
||||
PrgStack[StackPos]=StackFilter;
|
||||
StackFilter->ExecCount=Filter->ExecCount;
|
||||
|
||||
uint BlockStart=RarVM::ReadData(Inp);
|
||||
if (FirstByte & 0x40)
|
||||
BlockStart+=258;
|
||||
StackFilter->BlockStart=(BlockStart+UnpPtr)&MAXWINMASK;
|
||||
if (FirstByte & 0x20)
|
||||
StackFilter->BlockLength=RarVM::ReadData(Inp);
|
||||
else
|
||||
StackFilter->BlockLength=FiltPos<OldFilterLengths.Size() ? OldFilterLengths[FiltPos]:0;
|
||||
StackFilter->NextWindow=WrPtr!=UnpPtr && ((WrPtr-UnpPtr)&MAXWINMASK)<=BlockStart;
|
||||
|
||||
// DebugLog("\nNextWindow: UnpPtr=%08x WrPtr=%08x BlockStart=%08x",UnpPtr,WrPtr,BlockStart);
|
||||
|
||||
OldFilterLengths[FiltPos]=StackFilter->BlockLength;
|
||||
|
||||
memset(StackFilter->Prg.InitR,0,sizeof(StackFilter->Prg.InitR));
|
||||
StackFilter->Prg.InitR[3]=VM_GLOBALMEMADDR;
|
||||
StackFilter->Prg.InitR[4]=StackFilter->BlockLength;
|
||||
StackFilter->Prg.InitR[5]=StackFilter->ExecCount;
|
||||
if (FirstByte & 0x10)
|
||||
{
|
||||
unsigned int InitMask=Inp.fgetbits()>>9;
|
||||
Inp.faddbits(7);
|
||||
for (int I=0;I<7;I++)
|
||||
if (InitMask & (1<<I))
|
||||
StackFilter->Prg.InitR[I]=RarVM::ReadData(Inp);
|
||||
}
|
||||
if (NewFilter)
|
||||
{
|
||||
uint VMCodeSize=RarVM::ReadData(Inp);
|
||||
if (VMCodeSize>=0x10000 || VMCodeSize==0)
|
||||
return(false);
|
||||
Array<byte> VMCode(VMCodeSize);
|
||||
for (int I=0;I<VMCodeSize;I++)
|
||||
{
|
||||
VMCode[I]=Inp.fgetbits()>>8;
|
||||
Inp.faddbits(8);
|
||||
}
|
||||
VM.Prepare(&VMCode[0],VMCodeSize,&Filter->Prg);
|
||||
}
|
||||
StackFilter->Prg.AltCmd=&Filter->Prg.Cmd[0];
|
||||
StackFilter->Prg.CmdCount=Filter->Prg.CmdCount;
|
||||
|
||||
int StaticDataSize=Filter->Prg.StaticData.Size();
|
||||
if (StaticDataSize>0 && StaticDataSize<VM_GLOBALMEMSIZE)
|
||||
{
|
||||
StackFilter->Prg.StaticData.Add(StaticDataSize);
|
||||
memcpy(&StackFilter->Prg.StaticData[0],&Filter->Prg.StaticData[0],StaticDataSize);
|
||||
}
|
||||
|
||||
if (StackFilter->Prg.GlobalData.Size()<VM_FIXEDGLOBALSIZE)
|
||||
{
|
||||
StackFilter->Prg.GlobalData.Reset();
|
||||
StackFilter->Prg.GlobalData.Add(VM_FIXEDGLOBALSIZE);
|
||||
}
|
||||
byte *GlobalData=&StackFilter->Prg.GlobalData[0];
|
||||
for (int I=0;I<7;I++)
|
||||
VM.SetValue((uint *)&GlobalData[I*4],StackFilter->Prg.InitR[I]);
|
||||
VM.SetValue((uint *)&GlobalData[0x1c],StackFilter->BlockLength);
|
||||
VM.SetValue((uint *)&GlobalData[0x20],0);
|
||||
VM.SetValue((uint *)&GlobalData[0x2c],StackFilter->ExecCount);
|
||||
memset(&GlobalData[0x30],0,16);
|
||||
|
||||
if (FirstByte & 8)
|
||||
{
|
||||
uint DataSize=RarVM::ReadData(Inp);
|
||||
if (DataSize>=0x10000)
|
||||
return(false);
|
||||
unsigned int CurSize=StackFilter->Prg.GlobalData.Size();
|
||||
if (CurSize<DataSize+VM_FIXEDGLOBALSIZE)
|
||||
StackFilter->Prg.GlobalData.Add(DataSize+VM_FIXEDGLOBALSIZE-CurSize);
|
||||
byte *GlobalData=&StackFilter->Prg.GlobalData[VM_FIXEDGLOBALSIZE];
|
||||
for (int I=0;I<DataSize;I++)
|
||||
{
|
||||
GlobalData[I]=Inp.fgetbits()>>8;
|
||||
Inp.faddbits(8);
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
bool Unpack::UnpReadBuf()
|
||||
{
|
||||
int DataSize=ReadTop-InAddr;
|
||||
if (DataSize<0)
|
||||
return(false);
|
||||
if (InAddr>BitInput::MAX_SIZE/2)
|
||||
{
|
||||
if (DataSize>0)
|
||||
memmove(InBuf,InBuf+InAddr,DataSize);
|
||||
InAddr=0;
|
||||
ReadTop=DataSize;
|
||||
}
|
||||
else
|
||||
DataSize=ReadTop;
|
||||
int ReadCode=UnpIO->UnpRead(InBuf+DataSize,(BitInput::MAX_SIZE-DataSize)&~0xf);
|
||||
if (ReadCode>0)
|
||||
ReadTop+=ReadCode;
|
||||
ReadBorder=ReadTop-30;
|
||||
return(ReadCode!=-1);
|
||||
}
|
||||
|
||||
|
||||
void Unpack::UnpWriteBuf()
|
||||
{
|
||||
unsigned int WrittenBorder=WrPtr;
|
||||
unsigned int WriteSize=(UnpPtr-WrittenBorder)&MAXWINMASK;
|
||||
for (int I=0;I<PrgStack.Size();I++)
|
||||
{
|
||||
UnpackFilter *flt=PrgStack[I];
|
||||
if (flt==NULL)
|
||||
continue;
|
||||
if (flt->NextWindow)
|
||||
{
|
||||
flt->NextWindow=false;
|
||||
continue;
|
||||
}
|
||||
unsigned int BlockStart=flt->BlockStart;
|
||||
unsigned int BlockLength=flt->BlockLength;
|
||||
if (((BlockStart-WrittenBorder)&MAXWINMASK)<WriteSize)
|
||||
{
|
||||
if (WrittenBorder!=BlockStart)
|
||||
{
|
||||
UnpWriteArea(WrittenBorder,BlockStart);
|
||||
WrittenBorder=BlockStart;
|
||||
WriteSize=(UnpPtr-WrittenBorder)&MAXWINMASK;
|
||||
}
|
||||
if (BlockLength<=WriteSize)
|
||||
{
|
||||
unsigned int BlockEnd=(BlockStart+BlockLength)&MAXWINMASK;
|
||||
if (BlockStart<BlockEnd || BlockEnd==0)
|
||||
VM.SetMemory(0,Window+BlockStart,BlockLength);
|
||||
else
|
||||
{
|
||||
unsigned int FirstPartLength=MAXWINSIZE-BlockStart;
|
||||
VM.SetMemory(0,Window+BlockStart,FirstPartLength);
|
||||
VM.SetMemory(FirstPartLength,Window,BlockEnd);
|
||||
}
|
||||
VM_PreparedProgram *Prg=&flt->Prg;
|
||||
ExecuteCode(Prg);
|
||||
|
||||
byte *FilteredData=Prg->FilteredData;
|
||||
unsigned int FilteredDataSize=Prg->FilteredDataSize;
|
||||
|
||||
delete PrgStack[I];
|
||||
PrgStack[I]=NULL;
|
||||
while (I+1<PrgStack.Size())
|
||||
{
|
||||
UnpackFilter *NextFilter=PrgStack[I+1];
|
||||
if (NextFilter==NULL || NextFilter->BlockStart!=BlockStart ||
|
||||
NextFilter->BlockLength!=FilteredDataSize || NextFilter->NextWindow)
|
||||
break;
|
||||
VM.SetMemory(0,FilteredData,FilteredDataSize);
|
||||
VM_PreparedProgram *NextPrg=&PrgStack[I+1]->Prg;
|
||||
ExecuteCode(NextPrg);
|
||||
FilteredData=NextPrg->FilteredData;
|
||||
FilteredDataSize=NextPrg->FilteredDataSize;
|
||||
I++;
|
||||
delete PrgStack[I];
|
||||
PrgStack[I]=NULL;
|
||||
}
|
||||
UnpIO->UnpWrite(FilteredData,FilteredDataSize);
|
||||
UnpSomeRead=true;
|
||||
WrittenFileSize+=FilteredDataSize;
|
||||
WrittenBorder=BlockEnd;
|
||||
WriteSize=(UnpPtr-WrittenBorder)&MAXWINMASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int J=I;J<PrgStack.Size();J++)
|
||||
{
|
||||
UnpackFilter *flt=PrgStack[J];
|
||||
if (flt!=NULL && flt->NextWindow)
|
||||
flt->NextWindow=false;
|
||||
}
|
||||
WrPtr=WrittenBorder;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UnpWriteArea(WrittenBorder,UnpPtr);
|
||||
WrPtr=UnpPtr;
|
||||
}
|
||||
|
||||
|
||||
void Unpack::ExecuteCode(VM_PreparedProgram *Prg)
|
||||
{
|
||||
if (Prg->GlobalData.Size()>0)
|
||||
{
|
||||
Prg->InitR[6]=int64to32(WrittenFileSize);
|
||||
VM.SetValue((uint *)&Prg->GlobalData[0x24],int64to32(WrittenFileSize));
|
||||
VM.SetValue((uint *)&Prg->GlobalData[0x28],int64to32(WrittenFileSize>>32));
|
||||
VM.Execute(Prg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Unpack::UnpWriteArea(unsigned int StartPtr,unsigned int EndPtr)
|
||||
{
|
||||
if (EndPtr!=StartPtr)
|
||||
UnpSomeRead=true;
|
||||
if (EndPtr<StartPtr)
|
||||
{
|
||||
UnpWriteData(&Window[StartPtr],-StartPtr & MAXWINMASK);
|
||||
UnpWriteData(Window,EndPtr);
|
||||
UnpAllBuf=true;
|
||||
}
|
||||
else
|
||||
UnpWriteData(&Window[StartPtr],EndPtr-StartPtr);
|
||||
}
|
||||
|
||||
|
||||
void Unpack::UnpWriteData(byte *Data,int Size)
|
||||
{
|
||||
if (WrittenFileSize>=DestUnpSize)
|
||||
return;
|
||||
int WriteSize=Size;
|
||||
Int64 LeftToWrite=DestUnpSize-WrittenFileSize;
|
||||
if (WriteSize>LeftToWrite)
|
||||
WriteSize=int64to32(LeftToWrite);
|
||||
UnpIO->UnpWrite(Data,WriteSize);
|
||||
WrittenFileSize+=Size;
|
||||
}
|
||||
|
||||
|
||||
bool Unpack::ReadTables()
|
||||
{
|
||||
byte BitLength[BC];
|
||||
unsigned char Table[HUFF_TABLE_SIZE];
|
||||
if (InAddr>ReadTop-25)
|
||||
if (!UnpReadBuf())
|
||||
return(false);
|
||||
faddbits((8-InBit)&7);
|
||||
unsigned int BitField=fgetbits();
|
||||
if (BitField & 0x8000)
|
||||
{
|
||||
UnpBlockType=BLOCK_PPM;
|
||||
return(PPM.DecodeInit(this,PPMEscChar));
|
||||
}
|
||||
UnpBlockType=BLOCK_LZ;
|
||||
|
||||
PrevLowDist=0;
|
||||
LowDistRepCount=0;
|
||||
|
||||
if (!(BitField & 0x4000))
|
||||
memset(UnpOldTable,0,sizeof(UnpOldTable));
|
||||
faddbits(2);
|
||||
|
||||
for (int I=0;I<BC;I++)
|
||||
{
|
||||
int Length=(byte)(fgetbits() >> 12);
|
||||
faddbits(4);
|
||||
if (Length==15)
|
||||
{
|
||||
int ZeroCount=(byte)(fgetbits() >> 12);
|
||||
faddbits(4);
|
||||
if (ZeroCount==0)
|
||||
BitLength[I]=15;
|
||||
else
|
||||
{
|
||||
ZeroCount+=2;
|
||||
while (ZeroCount-- > 0 && I<sizeof(BitLength)/sizeof(BitLength[0]))
|
||||
BitLength[I++]=0;
|
||||
I--;
|
||||
}
|
||||
}
|
||||
else
|
||||
BitLength[I]=Length;
|
||||
}
|
||||
MakeDecodeTables(BitLength,(struct Decode *)&BD,BC);
|
||||
|
||||
const int TableSize=HUFF_TABLE_SIZE;
|
||||
for (int I=0;I<TableSize;)
|
||||
{
|
||||
if (InAddr>ReadTop-5)
|
||||
if (!UnpReadBuf())
|
||||
return(false);
|
||||
int Number=DecodeNumber((struct Decode *)&BD);
|
||||
if (Number<16)
|
||||
{
|
||||
Table[I]=(Number+UnpOldTable[I]) & 0xf;
|
||||
I++;
|
||||
}
|
||||
else
|
||||
if (Number<18)
|
||||
{
|
||||
int N;
|
||||
if (Number==16)
|
||||
{
|
||||
N=(fgetbits() >> 13)+3;
|
||||
faddbits(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
N=(fgetbits() >> 9)+11;
|
||||
faddbits(7);
|
||||
}
|
||||
while (N-- > 0 && I<TableSize)
|
||||
{
|
||||
Table[I]=Table[I-1];
|
||||
I++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int N;
|
||||
if (Number==18)
|
||||
{
|
||||
N=(fgetbits() >> 13)+3;
|
||||
faddbits(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
N=(fgetbits() >> 9)+11;
|
||||
faddbits(7);
|
||||
}
|
||||
while (N-- > 0 && I<TableSize)
|
||||
Table[I++]=0;
|
||||
}
|
||||
}
|
||||
TablesRead=true;
|
||||
if (InAddr>ReadTop)
|
||||
return(false);
|
||||
MakeDecodeTables(&Table[0],(struct Decode *)&LD,NC);
|
||||
MakeDecodeTables(&Table[NC],(struct Decode *)&DD,DC);
|
||||
MakeDecodeTables(&Table[NC+DC],(struct Decode *)&LDD,LDC);
|
||||
MakeDecodeTables(&Table[NC+DC+LDC],(struct Decode *)&RD,RC);
|
||||
memcpy(UnpOldTable,Table,sizeof(UnpOldTable));
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
void Unpack::UnpInitData(int Solid)
|
||||
{
|
||||
if (!Solid)
|
||||
{
|
||||
TablesRead=false;
|
||||
memset(OldDist,0,sizeof(OldDist));
|
||||
OldDistPtr=0;
|
||||
LastDist=LastLength=0;
|
||||
// memset(Window,0,MAXWINSIZE);
|
||||
memset(UnpOldTable,0,sizeof(UnpOldTable));
|
||||
UnpPtr=WrPtr=0;
|
||||
PPMEscChar=2;
|
||||
|
||||
InitFilters();
|
||||
}
|
||||
InitBitInput();
|
||||
PPMError=false;
|
||||
WrittenFileSize=0;
|
||||
ReadTop=0;
|
||||
ReadBorder=0;
|
||||
#ifndef SFX_MODULE
|
||||
// Igor Pavlov
|
||||
// UnpInitData20(Solid);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Unpack::InitFilters()
|
||||
{
|
||||
OldFilterLengths.Reset();
|
||||
LastFilter=0;
|
||||
|
||||
for (int I=0;I<Filters.Size();I++)
|
||||
delete Filters[I];
|
||||
Filters.Reset();
|
||||
for (int I=0;I<PrgStack.Size();I++)
|
||||
delete PrgStack[I];
|
||||
PrgStack.Reset();
|
||||
}
|
||||
|
||||
|
||||
void Unpack::MakeDecodeTables(unsigned char *LenTab,struct Decode *Dec,int Size)
|
||||
{
|
||||
int LenCount[16],TmpPos[16],I;
|
||||
long M,N;
|
||||
memset(LenCount,0,sizeof(LenCount));
|
||||
memset(Dec->DecodeNum,0,Size*sizeof(*Dec->DecodeNum));
|
||||
for (I=0;I<Size;I++)
|
||||
LenCount[LenTab[I] & 0xF]++;
|
||||
|
||||
LenCount[0]=0;
|
||||
for (TmpPos[0]=Dec->DecodePos[0]=Dec->DecodeLen[0]=0,N=0,I=1;I<16;I++)
|
||||
{
|
||||
N=2*(N+LenCount[I]);
|
||||
M=N<<(15-I);
|
||||
if (M>0xFFFF)
|
||||
M=0xFFFF;
|
||||
Dec->DecodeLen[I]=(unsigned int)M;
|
||||
TmpPos[I]=Dec->DecodePos[I]=Dec->DecodePos[I-1]+LenCount[I-1];
|
||||
}
|
||||
|
||||
for (I=0;I<Size;I++)
|
||||
if (LenTab[I]!=0)
|
||||
Dec->DecodeNum[TmpPos[LenTab[I] & 0xF]++]=I;
|
||||
Dec->MaxNum=Size;
|
||||
}
|
||||
205
7zip/Compress/Rar29/Original/unpack.hpp
Executable file
205
7zip/Compress/Rar29/Original/unpack.hpp
Executable file
@@ -0,0 +1,205 @@
|
||||
#ifndef _RAR_UNPACK_
|
||||
#define _RAR_UNPACK_
|
||||
|
||||
enum BLOCK_TYPES {BLOCK_LZ,BLOCK_PPM};
|
||||
|
||||
struct Decode
|
||||
{
|
||||
unsigned int MaxNum;
|
||||
unsigned int DecodeLen[16];
|
||||
unsigned int DecodePos[16];
|
||||
unsigned int DecodeNum[2];
|
||||
};
|
||||
|
||||
struct LitDecode
|
||||
{
|
||||
unsigned int MaxNum;
|
||||
unsigned int DecodeLen[16];
|
||||
unsigned int DecodePos[16];
|
||||
unsigned int DecodeNum[NC];
|
||||
};
|
||||
|
||||
struct DistDecode
|
||||
{
|
||||
unsigned int MaxNum;
|
||||
unsigned int DecodeLen[16];
|
||||
unsigned int DecodePos[16];
|
||||
unsigned int DecodeNum[DC];
|
||||
};
|
||||
|
||||
struct LowDistDecode
|
||||
{
|
||||
unsigned int MaxNum;
|
||||
unsigned int DecodeLen[16];
|
||||
unsigned int DecodePos[16];
|
||||
unsigned int DecodeNum[LDC];
|
||||
};
|
||||
|
||||
struct RepDecode
|
||||
{
|
||||
unsigned int MaxNum;
|
||||
unsigned int DecodeLen[16];
|
||||
unsigned int DecodePos[16];
|
||||
unsigned int DecodeNum[RC];
|
||||
};
|
||||
|
||||
struct BitDecode
|
||||
{
|
||||
unsigned int MaxNum;
|
||||
unsigned int DecodeLen[16];
|
||||
unsigned int DecodePos[16];
|
||||
unsigned int DecodeNum[BC];
|
||||
};
|
||||
|
||||
struct UnpackFilter
|
||||
{
|
||||
unsigned int BlockStart;
|
||||
unsigned int BlockLength;
|
||||
unsigned int ExecCount;
|
||||
bool NextWindow;
|
||||
VM_PreparedProgram Prg;
|
||||
};
|
||||
|
||||
/***************************** Unpack v 2.0 *********************************/
|
||||
struct MultDecode
|
||||
{
|
||||
unsigned int MaxNum;
|
||||
unsigned int DecodeLen[16];
|
||||
unsigned int DecodePos[16];
|
||||
unsigned int DecodeNum[MC20];
|
||||
};
|
||||
|
||||
struct AudioVariables
|
||||
{
|
||||
int K1,K2,K3,K4,K5;
|
||||
int D1,D2,D3,D4;
|
||||
int LastDelta;
|
||||
unsigned int Dif[11];
|
||||
unsigned int ByteCount;
|
||||
int LastChar;
|
||||
};
|
||||
/***************************** Unpack v 2.0 *********************************/
|
||||
|
||||
|
||||
class Unpack:private BitInput
|
||||
{
|
||||
private:
|
||||
friend class Pack;
|
||||
|
||||
void Unpack29(bool Solid);
|
||||
bool UnpReadBuf();
|
||||
void UnpWriteBuf();
|
||||
void ExecuteCode(VM_PreparedProgram *Prg);
|
||||
void UnpWriteArea(unsigned int StartPtr,unsigned int EndPtr);
|
||||
void UnpWriteData(byte *Data,int Size);
|
||||
bool ReadTables();
|
||||
void MakeDecodeTables(unsigned char *LenTab,struct Decode *Dec,int Size);
|
||||
int DecodeNumber(struct Decode *Dec);
|
||||
void CopyString();
|
||||
inline void InsertOldDist(unsigned int Distance);
|
||||
inline void InsertLastMatch(unsigned int Length,unsigned int Distance);
|
||||
void UnpInitData(int Solid);
|
||||
void CopyString(unsigned int Length,unsigned int Distance);
|
||||
bool ReadEndOfBlock();
|
||||
bool ReadVMCode();
|
||||
bool ReadVMCodePPM();
|
||||
bool AddVMCode(unsigned int FirstByte,byte *Code,int CodeSize);
|
||||
void InitFilters();
|
||||
|
||||
ComprDataIO *UnpIO;
|
||||
ModelPPM PPM;
|
||||
int PPMEscChar;
|
||||
|
||||
RarVM VM;
|
||||
Array<UnpackFilter*> Filters;
|
||||
Array<UnpackFilter*> PrgStack;
|
||||
Array<int> OldFilterLengths;
|
||||
int LastFilter;
|
||||
|
||||
bool TablesRead;
|
||||
struct LitDecode LD;
|
||||
struct DistDecode DD;
|
||||
struct LowDistDecode LDD;
|
||||
struct RepDecode RD;
|
||||
struct BitDecode BD;
|
||||
|
||||
unsigned int OldDist[4],OldDistPtr;
|
||||
unsigned int LastDist,LastLength;
|
||||
|
||||
unsigned int UnpPtr,WrPtr;
|
||||
|
||||
int ReadTop;
|
||||
int ReadBorder;
|
||||
|
||||
unsigned char UnpOldTable[HUFF_TABLE_SIZE];
|
||||
|
||||
int UnpBlockType;
|
||||
|
||||
byte *Window;
|
||||
bool ExternalWindow;
|
||||
|
||||
|
||||
Int64 DestUnpSize;
|
||||
|
||||
bool Suspended;
|
||||
bool UnpAllBuf;
|
||||
bool UnpSomeRead;
|
||||
Int64 WrittenFileSize;
|
||||
bool FileExtracted;
|
||||
bool PPMError;
|
||||
|
||||
int PrevLowDist,LowDistRepCount;
|
||||
|
||||
/***************************** Unpack v 1.5 *********************************/
|
||||
void Unpack15(bool Solid);
|
||||
void ShortLZ();
|
||||
void LongLZ();
|
||||
void HuffDecode();
|
||||
void GetFlagsBuf();
|
||||
void OldUnpInitData(int Solid);
|
||||
void InitHuff();
|
||||
void CorrHuff(unsigned int *CharSet,unsigned int *NumToPlace);
|
||||
void OldCopyString(unsigned int Distance,unsigned int Length);
|
||||
unsigned int DecodeNum(int Num,unsigned int StartPos,
|
||||
unsigned int *DecTab,unsigned int *PosTab);
|
||||
void OldUnpWriteBuf();
|
||||
|
||||
unsigned int ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256];
|
||||
unsigned int Place[256],PlaceA[256],PlaceB[256],PlaceC[256];
|
||||
unsigned int NToPl[256],NToPlB[256],NToPlC[256];
|
||||
unsigned int FlagBuf,AvrPlc,AvrPlcB,AvrLn1,AvrLn2,AvrLn3;
|
||||
int Buf60,NumHuf,StMode,LCount,FlagsCnt;
|
||||
unsigned int Nhfb,Nlzb,MaxDist3;
|
||||
/***************************** Unpack v 1.5 *********************************/
|
||||
|
||||
/***************************** Unpack v 2.0 *********************************/
|
||||
void Unpack20(bool Solid);
|
||||
struct MultDecode MD[4];
|
||||
unsigned char UnpOldTable20[MC20*4];
|
||||
int UnpAudioBlock,UnpChannels,UnpCurChannel,UnpChannelDelta;
|
||||
void CopyString20(unsigned int Length,unsigned int Distance);
|
||||
bool ReadTables20();
|
||||
void UnpInitData20(int Solid);
|
||||
void ReadLastTables();
|
||||
byte DecodeAudio(int Delta);
|
||||
struct AudioVariables AudV[4];
|
||||
/***************************** Unpack v 2.0 *********************************/
|
||||
|
||||
public:
|
||||
Unpack(ComprDataIO *DataIO);
|
||||
~Unpack();
|
||||
void Init(byte *Window=NULL);
|
||||
void DoUnpack(int Method,bool Solid);
|
||||
bool IsFileExtracted() {return(FileExtracted);}
|
||||
void SetDestSize(Int64 DestSize) {DestUnpSize=DestSize;FileExtracted=false;}
|
||||
void SetSuspended(bool Suspended) {Unpack::Suspended=Suspended;}
|
||||
|
||||
unsigned int GetChar()
|
||||
{
|
||||
if (InAddr>BitInput::MAX_SIZE-30)
|
||||
UnpReadBuf();
|
||||
return(InBuf[InAddr++]);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
507
7zip/Compress/Rar29/Original/unpack15.cpp
Executable file
507
7zip/Compress/Rar29/Original/unpack15.cpp
Executable file
@@ -0,0 +1,507 @@
|
||||
#define STARTL1 2
|
||||
static unsigned int DecL1[]={0x8000,0xa000,0xc000,0xd000,0xe000,0xea00,
|
||||
0xee00,0xf000,0xf200,0xf200,0xffff};
|
||||
static unsigned int PosL1[]={0,0,0,2,3,5,7,11,16,20,24,32,32};
|
||||
|
||||
#define STARTL2 3
|
||||
static unsigned int DecL2[]={0xa000,0xc000,0xd000,0xe000,0xea00,0xee00,
|
||||
0xf000,0xf200,0xf240,0xffff};
|
||||
static unsigned int PosL2[]={0,0,0,0,5,7,9,13,18,22,26,34,36};
|
||||
|
||||
#define STARTHF0 4
|
||||
static unsigned int DecHf0[]={0x8000,0xc000,0xe000,0xf200,0xf200,0xf200,
|
||||
0xf200,0xf200,0xffff};
|
||||
static unsigned int PosHf0[]={0,0,0,0,0,8,16,24,33,33,33,33,33};
|
||||
|
||||
|
||||
#define STARTHF1 5
|
||||
static unsigned int DecHf1[]={0x2000,0xc000,0xe000,0xf000,0xf200,0xf200,
|
||||
0xf7e0,0xffff};
|
||||
static unsigned int PosHf1[]={0,0,0,0,0,0,4,44,60,76,80,80,127};
|
||||
|
||||
|
||||
#define STARTHF2 5
|
||||
static unsigned int DecHf2[]={0x1000,0x2400,0x8000,0xc000,0xfa00,0xffff,
|
||||
0xffff,0xffff};
|
||||
static unsigned int PosHf2[]={0,0,0,0,0,0,2,7,53,117,233,0,0};
|
||||
|
||||
|
||||
#define STARTHF3 6
|
||||
static unsigned int DecHf3[]={0x800,0x2400,0xee00,0xfe80,0xffff,0xffff,
|
||||
0xffff};
|
||||
static unsigned int PosHf3[]={0,0,0,0,0,0,0,2,16,218,251,0,0};
|
||||
|
||||
|
||||
#define STARTHF4 8
|
||||
static unsigned int DecHf4[]={0xff00,0xffff,0xffff,0xffff,0xffff,0xffff};
|
||||
static unsigned int PosHf4[]={0,0,0,0,0,0,0,0,0,255,0,0,0};
|
||||
|
||||
|
||||
void Unpack::Unpack15(bool Solid)
|
||||
{
|
||||
if (Suspended)
|
||||
UnpPtr=WrPtr;
|
||||
else
|
||||
{
|
||||
UnpInitData(Solid);
|
||||
OldUnpInitData(Solid);
|
||||
UnpReadBuf();
|
||||
if (!Solid)
|
||||
{
|
||||
InitHuff();
|
||||
UnpPtr=0;
|
||||
}
|
||||
else
|
||||
UnpPtr=WrPtr;
|
||||
--DestUnpSize;
|
||||
}
|
||||
if (DestUnpSize>=0)
|
||||
{
|
||||
GetFlagsBuf();
|
||||
FlagsCnt=8;
|
||||
}
|
||||
|
||||
while (DestUnpSize>=0)
|
||||
{
|
||||
UnpPtr&=MAXWINMASK;
|
||||
|
||||
if (InAddr>ReadTop-30 && !UnpReadBuf())
|
||||
break;
|
||||
if (((WrPtr-UnpPtr) & MAXWINMASK)<270 && WrPtr!=UnpPtr)
|
||||
{
|
||||
OldUnpWriteBuf();
|
||||
if (Suspended)
|
||||
return;
|
||||
}
|
||||
if (StMode)
|
||||
{
|
||||
HuffDecode();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (--FlagsCnt < 0)
|
||||
{
|
||||
GetFlagsBuf();
|
||||
FlagsCnt=7;
|
||||
}
|
||||
|
||||
if (FlagBuf & 0x80)
|
||||
{
|
||||
FlagBuf<<=1;
|
||||
if (Nlzb > Nhfb)
|
||||
LongLZ();
|
||||
else
|
||||
HuffDecode();
|
||||
}
|
||||
else
|
||||
{
|
||||
FlagBuf<<=1;
|
||||
if (--FlagsCnt < 0)
|
||||
{
|
||||
GetFlagsBuf();
|
||||
FlagsCnt=7;
|
||||
}
|
||||
if (FlagBuf & 0x80)
|
||||
{
|
||||
FlagBuf<<=1;
|
||||
if (Nlzb > Nhfb)
|
||||
HuffDecode();
|
||||
else
|
||||
LongLZ();
|
||||
}
|
||||
else
|
||||
{
|
||||
FlagBuf<<=1;
|
||||
ShortLZ();
|
||||
}
|
||||
}
|
||||
}
|
||||
OldUnpWriteBuf();
|
||||
}
|
||||
|
||||
|
||||
void Unpack::OldUnpWriteBuf()
|
||||
{
|
||||
if (UnpPtr!=WrPtr)
|
||||
UnpSomeRead=true;
|
||||
if (UnpPtr<WrPtr)
|
||||
{
|
||||
UnpIO->UnpWrite(&Window[WrPtr],-WrPtr & MAXWINMASK);
|
||||
UnpIO->UnpWrite(Window,UnpPtr);
|
||||
UnpAllBuf=true;
|
||||
}
|
||||
else
|
||||
UnpIO->UnpWrite(&Window[WrPtr],UnpPtr-WrPtr);
|
||||
WrPtr=UnpPtr;
|
||||
}
|
||||
|
||||
|
||||
void Unpack::ShortLZ()
|
||||
{
|
||||
static unsigned int ShortLen1[]={1,3,4,4,5,6,7,8,8,4,4,5,6,6,4,0};
|
||||
static unsigned int ShortXor1[]={0,0xa0,0xd0,0xe0,0xf0,0xf8,0xfc,0xfe,
|
||||
0xff,0xc0,0x80,0x90,0x98,0x9c,0xb0};
|
||||
static unsigned int ShortLen2[]={2,3,3,3,4,4,5,6,6,4,4,5,6,6,4,0};
|
||||
static unsigned int ShortXor2[]={0,0x40,0x60,0xa0,0xd0,0xe0,0xf0,0xf8,
|
||||
0xfc,0xc0,0x80,0x90,0x98,0x9c,0xb0};
|
||||
|
||||
|
||||
unsigned int Length,SaveLength;
|
||||
unsigned int LastDistance;
|
||||
unsigned int Distance;
|
||||
int DistancePlace;
|
||||
NumHuf=0;
|
||||
|
||||
unsigned int BitField=fgetbits();
|
||||
if (LCount==2)
|
||||
{
|
||||
faddbits(1);
|
||||
if (BitField >= 0x8000)
|
||||
{
|
||||
OldCopyString((unsigned int)LastDist,LastLength);
|
||||
return;
|
||||
}
|
||||
BitField <<= 1;
|
||||
LCount=0;
|
||||
}
|
||||
|
||||
BitField>>=8;
|
||||
|
||||
ShortLen1[1]=ShortLen2[3]=Buf60+3;
|
||||
|
||||
if (AvrLn1<37)
|
||||
{
|
||||
for (Length=0;;Length++)
|
||||
if (((BitField^ShortXor1[Length]) & (~(0xff>>ShortLen1[Length])))==0)
|
||||
break;
|
||||
faddbits(ShortLen1[Length]);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Length=0;;Length++)
|
||||
if (((BitField^ShortXor2[Length]) & (~(0xff>>ShortLen2[Length])))==0)
|
||||
break;
|
||||
faddbits(ShortLen2[Length]);
|
||||
}
|
||||
|
||||
if (Length >= 9)
|
||||
{
|
||||
if (Length == 9)
|
||||
{
|
||||
LCount++;
|
||||
OldCopyString((unsigned int)LastDist,LastLength);
|
||||
return;
|
||||
}
|
||||
if (Length == 14)
|
||||
{
|
||||
LCount=0;
|
||||
Length=DecodeNum(fgetbits(),STARTL2,DecL2,PosL2)+5;
|
||||
Distance=(fgetbits()>>1) | 0x8000;
|
||||
faddbits(15);
|
||||
LastLength=Length;
|
||||
LastDist=Distance;
|
||||
OldCopyString(Distance,Length);
|
||||
return;
|
||||
}
|
||||
|
||||
LCount=0;
|
||||
SaveLength=Length;
|
||||
Distance=OldDist[(OldDistPtr-(Length-9)) & 3];
|
||||
Length=DecodeNum(fgetbits(),STARTL1,DecL1,PosL1)+2;
|
||||
if (Length==0x101 && SaveLength==10)
|
||||
{
|
||||
Buf60 ^= 1;
|
||||
return;
|
||||
}
|
||||
if (Distance > 256)
|
||||
Length++;
|
||||
if (Distance >= MaxDist3)
|
||||
Length++;
|
||||
|
||||
OldDist[OldDistPtr++]=Distance;
|
||||
OldDistPtr = OldDistPtr & 3;
|
||||
LastLength=Length;
|
||||
LastDist=Distance;
|
||||
OldCopyString(Distance,Length);
|
||||
return;
|
||||
}
|
||||
|
||||
LCount=0;
|
||||
AvrLn1 += Length;
|
||||
AvrLn1 -= AvrLn1 >> 4;
|
||||
|
||||
DistancePlace=DecodeNum(fgetbits(),STARTHF2,DecHf2,PosHf2) & 0xff;
|
||||
Distance=ChSetA[DistancePlace];
|
||||
if (--DistancePlace != -1)
|
||||
{
|
||||
PlaceA[Distance]--;
|
||||
LastDistance=ChSetA[DistancePlace];
|
||||
PlaceA[LastDistance]++;
|
||||
ChSetA[DistancePlace+1]=LastDistance;
|
||||
ChSetA[DistancePlace]=Distance;
|
||||
}
|
||||
Length+=2;
|
||||
OldDist[OldDistPtr++] = ++Distance;
|
||||
OldDistPtr = OldDistPtr & 3;
|
||||
LastLength=Length;
|
||||
LastDist=Distance;
|
||||
OldCopyString(Distance,Length);
|
||||
}
|
||||
|
||||
|
||||
void Unpack::LongLZ()
|
||||
{
|
||||
unsigned int Length;
|
||||
unsigned int Distance;
|
||||
unsigned int DistancePlace,NewDistancePlace;
|
||||
unsigned int OldAvr2,OldAvr3;
|
||||
|
||||
NumHuf=0;
|
||||
Nlzb+=16;
|
||||
if (Nlzb > 0xff)
|
||||
{
|
||||
Nlzb=0x90;
|
||||
Nhfb >>= 1;
|
||||
}
|
||||
OldAvr2=AvrLn2;
|
||||
|
||||
unsigned int BitField=fgetbits();
|
||||
if (AvrLn2 >= 122)
|
||||
Length=DecodeNum(BitField,STARTL2,DecL2,PosL2);
|
||||
else
|
||||
if (AvrLn2 >= 64)
|
||||
Length=DecodeNum(BitField,STARTL1,DecL1,PosL1);
|
||||
else
|
||||
if (BitField < 0x100)
|
||||
{
|
||||
Length=BitField;
|
||||
faddbits(16);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Length=0;((BitField<<Length)&0x8000)==0;Length++)
|
||||
;
|
||||
faddbits(Length+1);
|
||||
}
|
||||
|
||||
AvrLn2 += Length;
|
||||
AvrLn2 -= AvrLn2 >> 5;
|
||||
|
||||
BitField=fgetbits();
|
||||
if (AvrPlcB > 0x28ff)
|
||||
DistancePlace=DecodeNum(BitField,STARTHF2,DecHf2,PosHf2);
|
||||
else
|
||||
if (AvrPlcB > 0x6ff)
|
||||
DistancePlace=DecodeNum(BitField,STARTHF1,DecHf1,PosHf1);
|
||||
else
|
||||
DistancePlace=DecodeNum(BitField,STARTHF0,DecHf0,PosHf0);
|
||||
|
||||
AvrPlcB += DistancePlace;
|
||||
AvrPlcB -= AvrPlcB >> 8;
|
||||
while (1)
|
||||
{
|
||||
Distance = ChSetB[DistancePlace & 0xff];
|
||||
NewDistancePlace = NToPlB[Distance++ & 0xff]++;
|
||||
if (!(Distance & 0xff))
|
||||
CorrHuff(ChSetB,NToPlB);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
ChSetB[DistancePlace]=ChSetB[NewDistancePlace];
|
||||
ChSetB[NewDistancePlace]=Distance;
|
||||
|
||||
Distance=((Distance & 0xff00) | (fgetbits() >> 8)) >> 1;
|
||||
faddbits(7);
|
||||
|
||||
OldAvr3=AvrLn3;
|
||||
if (Length!=1 && Length!=4)
|
||||
if (Length==0 && Distance <= MaxDist3)
|
||||
{
|
||||
AvrLn3++;
|
||||
AvrLn3 -= AvrLn3 >> 8;
|
||||
}
|
||||
else
|
||||
if (AvrLn3 > 0)
|
||||
AvrLn3--;
|
||||
Length+=3;
|
||||
if (Distance >= MaxDist3)
|
||||
Length++;
|
||||
if (Distance <= 256)
|
||||
Length+=8;
|
||||
if (OldAvr3 > 0xb0 || AvrPlc >= 0x2a00 && OldAvr2 < 0x40)
|
||||
MaxDist3=0x7f00;
|
||||
else
|
||||
MaxDist3=0x2001;
|
||||
OldDist[OldDistPtr++]=Distance;
|
||||
OldDistPtr = OldDistPtr & 3;
|
||||
LastLength=Length;
|
||||
LastDist=Distance;
|
||||
OldCopyString(Distance,Length);
|
||||
}
|
||||
|
||||
|
||||
void Unpack::HuffDecode()
|
||||
{
|
||||
unsigned int CurByte,NewBytePlace;
|
||||
unsigned int Length;
|
||||
unsigned int Distance;
|
||||
int BytePlace;
|
||||
|
||||
unsigned int BitField=fgetbits();
|
||||
|
||||
if (AvrPlc > 0x75ff)
|
||||
BytePlace=DecodeNum(BitField,STARTHF4,DecHf4,PosHf4);
|
||||
else
|
||||
if (AvrPlc > 0x5dff)
|
||||
BytePlace=DecodeNum(BitField,STARTHF3,DecHf3,PosHf3);
|
||||
else
|
||||
if (AvrPlc > 0x35ff)
|
||||
BytePlace=DecodeNum(BitField,STARTHF2,DecHf2,PosHf2);
|
||||
else
|
||||
if (AvrPlc > 0x0dff)
|
||||
BytePlace=DecodeNum(BitField,STARTHF1,DecHf1,PosHf1);
|
||||
else
|
||||
BytePlace=DecodeNum(BitField,STARTHF0,DecHf0,PosHf0);
|
||||
BytePlace&=0xff;
|
||||
if (StMode)
|
||||
{
|
||||
if (BytePlace==0 && BitField > 0xfff)
|
||||
BytePlace=0x100;
|
||||
if (--BytePlace==-1)
|
||||
{
|
||||
BitField=fgetbits();
|
||||
faddbits(1);
|
||||
if (BitField & 0x8000)
|
||||
{
|
||||
NumHuf=StMode=0;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Length = (BitField & 0x4000) ? 4 : 3;
|
||||
faddbits(1);
|
||||
Distance=DecodeNum(fgetbits(),STARTHF2,DecHf2,PosHf2);
|
||||
Distance = (Distance << 5) | (fgetbits() >> 11);
|
||||
faddbits(5);
|
||||
OldCopyString(Distance,Length);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (NumHuf++ >= 16 && FlagsCnt==0)
|
||||
StMode=1;
|
||||
AvrPlc += BytePlace;
|
||||
AvrPlc -= AvrPlc >> 8;
|
||||
Nhfb+=16;
|
||||
if (Nhfb > 0xff)
|
||||
{
|
||||
Nhfb=0x90;
|
||||
Nlzb >>= 1;
|
||||
}
|
||||
|
||||
Window[UnpPtr++]=(byte)(ChSet[BytePlace]>>8);
|
||||
--DestUnpSize;
|
||||
|
||||
while (1)
|
||||
{
|
||||
CurByte=ChSet[BytePlace];
|
||||
NewBytePlace=NToPl[CurByte++ & 0xff]++;
|
||||
if ((CurByte & 0xff) > 0xa1)
|
||||
CorrHuff(ChSet,NToPl);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
ChSet[BytePlace]=ChSet[NewBytePlace];
|
||||
ChSet[NewBytePlace]=CurByte;
|
||||
}
|
||||
|
||||
|
||||
void Unpack::GetFlagsBuf()
|
||||
{
|
||||
unsigned int Flags,NewFlagsPlace;
|
||||
unsigned int FlagsPlace=DecodeNum(fgetbits(),STARTHF2,DecHf2,PosHf2);
|
||||
|
||||
while (1)
|
||||
{
|
||||
Flags=ChSetC[FlagsPlace];
|
||||
FlagBuf=Flags>>8;
|
||||
NewFlagsPlace=NToPlC[Flags++ & 0xff]++;
|
||||
if ((Flags & 0xff) != 0)
|
||||
break;
|
||||
CorrHuff(ChSetC,NToPlC);
|
||||
}
|
||||
|
||||
ChSetC[FlagsPlace]=ChSetC[NewFlagsPlace];
|
||||
ChSetC[NewFlagsPlace]=Flags;
|
||||
}
|
||||
|
||||
|
||||
void Unpack::OldUnpInitData(int Solid)
|
||||
{
|
||||
if (!Solid)
|
||||
{
|
||||
AvrPlcB=AvrLn1=AvrLn2=AvrLn3=NumHuf=Buf60=0;
|
||||
AvrPlc=0x3500;
|
||||
MaxDist3=0x2001;
|
||||
Nhfb=Nlzb=0x80;
|
||||
}
|
||||
FlagsCnt=0;
|
||||
FlagBuf=0;
|
||||
StMode=0;
|
||||
LCount=0;
|
||||
ReadTop=0;
|
||||
}
|
||||
|
||||
|
||||
void Unpack::InitHuff()
|
||||
{
|
||||
for (unsigned int I=0;I<256;I++)
|
||||
{
|
||||
Place[I]=PlaceA[I]=PlaceB[I]=I;
|
||||
PlaceC[I]=(~I+1) & 0xff;
|
||||
ChSet[I]=ChSetB[I]=I<<8;
|
||||
ChSetA[I]=I;
|
||||
ChSetC[I]=((~I+1) & 0xff)<<8;
|
||||
}
|
||||
memset(NToPl,0,sizeof(NToPl));
|
||||
memset(NToPlB,0,sizeof(NToPlB));
|
||||
memset(NToPlC,0,sizeof(NToPlC));
|
||||
CorrHuff(ChSetB,NToPlB);
|
||||
}
|
||||
|
||||
|
||||
void Unpack::CorrHuff(unsigned int *CharSet,unsigned int *NumToPlace)
|
||||
{
|
||||
int I,J;
|
||||
for (I=7;I>=0;I--)
|
||||
for (J=0;J<32;J++,CharSet++)
|
||||
*CharSet=(*CharSet & ~0xff) | I;
|
||||
memset(NumToPlace,0,sizeof(NToPl));
|
||||
for (I=6;I>=0;I--)
|
||||
NumToPlace[I]=(7-I)*32;
|
||||
}
|
||||
|
||||
|
||||
void Unpack::OldCopyString(unsigned int Distance,unsigned int Length)
|
||||
{
|
||||
DestUnpSize-=Length;
|
||||
while (Length--)
|
||||
{
|
||||
Window[UnpPtr]=Window[(UnpPtr-Distance) & MAXWINMASK];
|
||||
UnpPtr=(UnpPtr+1) & MAXWINMASK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned int Unpack::DecodeNum(int Num,unsigned int StartPos,
|
||||
unsigned int *DecTab,unsigned int *PosTab)
|
||||
{
|
||||
int I;
|
||||
for (Num&=0xfff0,I=0;DecTab[I]<=Num;I++)
|
||||
StartPos++;
|
||||
faddbits(StartPos);
|
||||
return(((Num-(I ? DecTab[I-1]:0))>>(16-StartPos))+PosTab[StartPos]);
|
||||
}
|
||||
6
7zip/Compress/Rar29/Original/version.hpp
Executable file
6
7zip/Compress/Rar29/Original/version.hpp
Executable file
@@ -0,0 +1,6 @@
|
||||
#define RARVER_MAJOR 3
|
||||
#define RARVER_MINOR 50
|
||||
#define RARVER_BETA 0
|
||||
#define RARVER_DAY 3
|
||||
#define RARVER_MONTH 8
|
||||
#define RARVER_YEAR 2005
|
||||
11
7zip/Compress/Rar29/Original/volume.hpp
Executable file
11
7zip/Compress/Rar29/Original/volume.hpp
Executable file
@@ -0,0 +1,11 @@
|
||||
#ifndef _RAR_VOLUME_
|
||||
#define _RAR_VOLUME_
|
||||
|
||||
void SplitArchive(Archive &Arc,FileHeader *fh,Int64 *HeaderPos,
|
||||
ComprDataIO *DataIO);
|
||||
bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,
|
||||
char Command);
|
||||
void SetVolWrite(Archive &Dest,Int64 VolSize);
|
||||
bool AskNextVol(char *ArcName);
|
||||
|
||||
#endif
|
||||
415
7zip/Compress/Rar29/Rar29.dsp
Executable file
415
7zip/Compress/Rar29/Rar29.dsp
Executable file
@@ -0,0 +1,415 @@
|
||||
# Microsoft Developer Studio Project File - Name="Rar29" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=Rar29 - 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 "RAR29.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 "RAR29.mak" CFG="Rar29 - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Rar29 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Rar29 - 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)" == "Rar29 - 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 "RAR29_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RAR29_EXPORTS" /D "SILENT" /D "NOCRYPT" /D "NOVOLUME" /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 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:\Program Files\7-Zip\Codecs\Rar29.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - 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 "RAR29_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 "RAR29_EXPORTS" /D "SILENT" /D "NOCRYPT" /D "NOVOLUME" /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 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:\Program Files\7-Zip\Codecs\Rar29.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Rar29 - Win32 Release"
|
||||
# Name "Rar29 - Win32 Debug"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Codec.def
|
||||
# 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 "7zip Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InBuffer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\InBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\MSBFDecoder.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\StreamUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\StreamUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "UnRar Sources"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "hpp"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Original\int64.hpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\crc.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\errhnd.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\getbits.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\rar.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\rarvm.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\rdwrfn.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\rdwrfn.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\resource.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\smallfn.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\system.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\unpack.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=Original\unpack.hpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Rar20"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Rar20\Rar20Const.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Rar20\Rar20Decoder.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Rar20\Rar20Decoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Rar20\Rar20ExtConst.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Rar20\Rar20Multimedia.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Rar20\Rar20Multimedia.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "LZ"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\LZ\LZOutWindow.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\LZ\LZOutWindow.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Huffman"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Huffman\HuffmanDecoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Alloc.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Rar29Decoder.cpp
|
||||
|
||||
!IF "$(CFG)" == "Rar29 - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Rar29 - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Rar29Decoder.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
29
7zip/Compress/Rar29/Rar29.dsw
Executable file
29
7zip/Compress/Rar29/Rar29.dsw
Executable file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "RAR29"=.\RAR29.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
153
7zip/Compress/Rar29/Rar29Decoder.cpp
Executable file
153
7zip/Compress/Rar29/Rar29Decoder.cpp
Executable file
@@ -0,0 +1,153 @@
|
||||
// Rar29Decoder.cpp
|
||||
// According to unRAR license,
|
||||
// this code may not be used to develop a
|
||||
// RAR (WinRAR) compatible archiver
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Rar29Decoder.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
|
||||
// #include "Original/unpack15.cpp"
|
||||
|
||||
ErrorHandler ErrHandler;
|
||||
|
||||
namespace NCompress {
|
||||
namespace NRar29 {
|
||||
|
||||
CDecoder::CDecoder():
|
||||
m_IsSolid(false),
|
||||
// DataIO(NULL)
|
||||
DataIO()
|
||||
{
|
||||
Unp = new Unpack(&DataIO);
|
||||
Unp->Init(NULL);
|
||||
}
|
||||
|
||||
CDecoder::~CDecoder()
|
||||
{
|
||||
delete Unp;
|
||||
}
|
||||
|
||||
STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
// CCoderReleaser coderReleaser(this);
|
||||
|
||||
DataIO.CurUnpRead=0;
|
||||
DataIO.CurUnpWrite=0;
|
||||
DataIO.UnpFileCRC=0xffffffff;
|
||||
DataIO.PackedCRC=0xffffffff;
|
||||
/*
|
||||
DataIO.SetEncryption(
|
||||
0,0,
|
||||
NULL,false);
|
||||
*/
|
||||
|
||||
DataIO.SetPackedSizeToRead(*inSize);
|
||||
DataIO.SetFiles(inStream, outStream, progress);
|
||||
DataIO.SetTestMode(false);
|
||||
// DataIO.SetSkipUnpCRC(SkipSolid);
|
||||
/*
|
||||
if (!TestMode && Arc.NewLhd.FullUnpSize>0x1000)
|
||||
CurFile.Prealloc(Arc.NewLhd.FullUnpSize);
|
||||
|
||||
CurFile.SetAllowDelete(!Cmd->KeepBroken);
|
||||
*/
|
||||
|
||||
Unp->SetDestSize(*outSize);
|
||||
|
||||
Unp->DoUnpack(29, m_IsSolid);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
|
||||
catch(const CExitCode &exitCode) { return exitCode.Result; }
|
||||
catch(...) { return S_FALSE; }
|
||||
}
|
||||
|
||||
STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
|
||||
{
|
||||
if (size < 1)
|
||||
return E_INVALIDARG;
|
||||
m_IsSolid = (data[0] != 0);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace NRar15 {
|
||||
|
||||
CDecoder::CDecoder():
|
||||
m_IsSolid(false),
|
||||
DataIO()
|
||||
{
|
||||
Unp=new Unpack(&DataIO);
|
||||
Unp->Init(NULL);
|
||||
}
|
||||
|
||||
CDecoder::~CDecoder()
|
||||
{
|
||||
delete Unp;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
// CCoderReleaser coderReleaser(this);
|
||||
|
||||
DataIO.CurUnpRead=0;
|
||||
DataIO.CurUnpWrite=0;
|
||||
DataIO.UnpFileCRC=0xffffffff;
|
||||
DataIO.PackedCRC=0xffffffff;
|
||||
/*
|
||||
DataIO.SetEncryption(
|
||||
0,0,
|
||||
NULL,false);
|
||||
*/
|
||||
|
||||
DataIO.SetPackedSizeToRead(*inSize);
|
||||
DataIO.SetFiles(inStream, outStream, progress);
|
||||
DataIO.SetTestMode(false);
|
||||
// DataIO.SetSkipUnpCRC(SkipSolid);
|
||||
/*
|
||||
if (!TestMode && Arc.NewLhd.FullUnpSize>0x1000)
|
||||
CurFile.Prealloc(Arc.NewLhd.FullUnpSize);
|
||||
|
||||
CurFile.SetAllowDelete(!Cmd->KeepBroken);
|
||||
*/
|
||||
Unp->SetDestSize(*outSize);
|
||||
Unp->DoUnpack(15, m_IsSolid);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UInt64 *inSize,
|
||||
const UInt64 *outSize,
|
||||
ICompressProgressInfo *progress)
|
||||
{
|
||||
try { return CodeReal(inStream, outStream, inSize, outSize, progress); }
|
||||
catch(const CExitCode &exitCode) { return exitCode.Result; }
|
||||
catch(...) { return S_FALSE;}
|
||||
}
|
||||
|
||||
STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
|
||||
{
|
||||
if (size < 1)
|
||||
return E_INVALIDARG;
|
||||
m_IsSolid = (data[0] != 0);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
97
7zip/Compress/Rar29/Rar29Decoder.h
Executable file
97
7zip/Compress/Rar29/Rar29Decoder.h
Executable file
@@ -0,0 +1,97 @@
|
||||
// Rar29Decoder.h
|
||||
// According to unRAR license,
|
||||
// this code may not be used to develop a
|
||||
// RAR (WinRAR) compatible archiver
|
||||
|
||||
#ifndef __RAR_DECODER_H
|
||||
#define __RAR_DECODER_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "../../ICoder.h"
|
||||
|
||||
#include "Original/rar.hpp"
|
||||
|
||||
namespace NCompress {
|
||||
|
||||
namespace NRar29 {
|
||||
|
||||
class CDecoder :
|
||||
public ICompressCoder,
|
||||
public ICompressSetDecoderProperties2,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Unpack *Unp;
|
||||
bool m_IsSolid;
|
||||
public:
|
||||
ComprDataIO DataIO;
|
||||
CDecoder();
|
||||
~CDecoder();
|
||||
/*
|
||||
class CCoderReleaser
|
||||
{
|
||||
CCoder *m_Coder;
|
||||
public:
|
||||
CCoderReleaser(CCoder *aCoder): m_Coder(aCoder) {}
|
||||
~CCoderReleaser()
|
||||
{
|
||||
m_Coder->DataIO.ReleaseStreams();
|
||||
}
|
||||
};
|
||||
*/
|
||||
MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
|
||||
|
||||
// void ReleaseStreams();
|
||||
STDMETHOD(CodeReal)(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
|
||||
ICompressProgressInfo *progress);
|
||||
STDMETHOD(Code)(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
|
||||
ICompressProgressInfo *progress);
|
||||
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace NRar15{
|
||||
|
||||
class CDecoder :
|
||||
public ICompressCoder,
|
||||
public ICompressSetDecoderProperties2,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
Unpack *Unp;
|
||||
bool m_IsSolid;
|
||||
public:
|
||||
ComprDataIO DataIO;
|
||||
CDecoder();
|
||||
~CDecoder();
|
||||
/*
|
||||
class CCoderReleaser
|
||||
{
|
||||
CDecoder *m_Coder;
|
||||
public:
|
||||
CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
|
||||
~CCoderReleaser()
|
||||
{
|
||||
m_Coder->DataIO.ReleaseStreams();
|
||||
}
|
||||
};
|
||||
*/
|
||||
MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
|
||||
|
||||
// void ReleaseStreams();
|
||||
STDMETHOD(CodeReal)(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
|
||||
ICompressProgressInfo *progress);
|
||||
STDMETHOD(Code)(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
|
||||
ICompressProgressInfo *progress);
|
||||
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
3
7zip/Compress/Rar29/StdAfx.cpp
Executable file
3
7zip/Compress/Rar29/StdAfx.cpp
Executable file
@@ -0,0 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
8
7zip/Compress/Rar29/StdAfx.h
Executable file
8
7zip/Compress/Rar29/StdAfx.h
Executable file
@@ -0,0 +1,8 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#endif
|
||||
62
7zip/Compress/Rar29/makefile
Executable file
62
7zip/Compress/Rar29/makefile
Executable file
@@ -0,0 +1,62 @@
|
||||
PROG = Rar29.dll
|
||||
DEF_FILE = ../Codec.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../
|
||||
LIBS = $(LIBS) oleaut32.lib
|
||||
|
||||
RAR29_OBJS = \
|
||||
$O\DllExports.obj \
|
||||
$O\Rar29Decoder.obj \
|
||||
|
||||
RAR29_OPT_OBJS = \
|
||||
$O\crc.obj \
|
||||
$O\errhnd.obj \
|
||||
$O\getbits.obj \
|
||||
$O\rarvm.obj \
|
||||
$O\rdwrfn.obj \
|
||||
$O\resource.obj \
|
||||
$O\smallfn.obj \
|
||||
$O\system.obj \
|
||||
$O\unpack.obj \
|
||||
|
||||
RAR20_OPT_OBJS = \
|
||||
$O\Rar20Decoder.obj \
|
||||
$O\Rar20Multimedia.obj \
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
|
||||
7ZIP_COMMON_OBJS = \
|
||||
$O\InBuffer.obj \
|
||||
$O\OutBuffer.obj \
|
||||
$O\StreamUtils.obj \
|
||||
|
||||
LZ_OBJS = \
|
||||
$O\LZOutWindow.obj \
|
||||
|
||||
|
||||
OBJS = \
|
||||
$O\StdAfx.obj \
|
||||
$(RAR29_OBJS) \
|
||||
$(RAR29_OPT_OBJS) \
|
||||
$(RAR20_OPT_OBJS) \
|
||||
$(COMMON_OBJS) \
|
||||
$(7ZIP_COMMON_OBJS) \
|
||||
$(LZ_OBJS) \
|
||||
$O\resource.res
|
||||
|
||||
!include "../../../Build.mak"
|
||||
|
||||
COMPL_SPEC = $(CPP) $(CFLAGS_O2) -DSILENT -DNOCRYPT -DNOVOLUME $**
|
||||
|
||||
$(RAR29_OBJS): $(*B).cpp
|
||||
$(COMPL)
|
||||
$(RAR29_OPT_OBJS): Original/$(*B).cpp
|
||||
$(COMPL_SPEC)
|
||||
$(RAR20_OPT_OBJS): ../Rar20/$(*B).cpp
|
||||
$(COMPL_O2)
|
||||
$(COMMON_OBJS): ../../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
|
||||
$(COMPL)
|
||||
$(LZ_OBJS): ../LZ/$(*B).cpp
|
||||
$(COMPL)
|
||||
3
7zip/Compress/Rar29/resource.rc
Executable file
3
7zip/Compress/Rar29/resource.rc
Executable file
@@ -0,0 +1,3 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_DLL("Rar29 Codec", "Rar29")
|
||||
Reference in New Issue
Block a user