Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/C
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2009-08-17 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:00 +0300
commitc99f3ebdd639c2adb03d8b44001b10af18516504 (patch)
tree92aaf34e5edbd7287c3f55037190da75ab0a8000 /C
parent829409452d85cd6dd9dfc9151f109d6e13a2bb1c (diff)
9.06 beta
Diffstat (limited to 'C')
-rwxr-xr-xC/7z.h201
-rwxr-xr-xC/7zDec.c (renamed from C/Archive/7z/7zDecode.c)24
-rwxr-xr-xC/7zFile.c16
-rwxr-xr-xC/7zFile.h15
-rwxr-xr-xC/7zIn.c (renamed from C/Archive/7z/7zIn.c)330
-rwxr-xr-xC/7zVersion.h6
-rwxr-xr-xC/Aes.c8
-rwxr-xr-xC/Archive/7z/7zDecode.h21
-rwxr-xr-xC/Archive/7z/7zExtract.c93
-rwxr-xr-xC/Archive/7z/7zExtract.h49
-rwxr-xr-xC/Archive/7z/7zHeader.c6
-rwxr-xr-xC/Archive/7z/7zHeader.h65
-rwxr-xr-xC/Archive/7z/7zIn.h49
-rwxr-xr-xC/Archive/7z/7zItem.c127
-rwxr-xr-xC/Archive/7z/7zItem.h92
-rwxr-xr-xC/CpuArch.h16
-rwxr-xr-xC/Lzma86.h (renamed from C/LzmaUtil/Lzma86Enc.h)61
-rwxr-xr-xC/Lzma86Dec.c (renamed from C/LzmaUtil/Lzma86Dec.c)17
-rwxr-xr-xC/Lzma86Enc.c (renamed from C/LzmaUtil/Lzma86Enc.c)17
-rwxr-xr-xC/LzmaUtil/Lzma86Dec.h51
-rwxr-xr-xC/LzmaUtil/makefile.gcc44
-rwxr-xr-xC/Threads.c9
-rwxr-xr-xC/Types.h16
-rwxr-xr-xC/Util/7z/7z.dsp (renamed from C/Archive/7z/7z.dsp)46
-rwxr-xr-xC/Util/7z/7z.dsw (renamed from C/Archive/7z/7z.dsw)0
-rwxr-xr-xC/Util/7z/7zAlloc.c (renamed from C/Archive/7z/7zAlloc.c)0
-rwxr-xr-xC/Util/7z/7zAlloc.h (renamed from C/Archive/7z/7zAlloc.h)0
-rwxr-xr-xC/Util/7z/7zMain.c (renamed from C/Archive/7z/7zMain.c)280
-rwxr-xr-xC/Util/7z/makefile (renamed from C/Archive/7z/makefile)15
-rwxr-xr-xC/Util/7z/makefile.gcc (renamed from C/Archive/7z/makefile.gcc)19
-rwxr-xr-xC/Util/Lzma/LzmaUtil.c (renamed from C/LzmaUtil/LzmaUtil.c)12
-rwxr-xr-xC/Util/Lzma/LzmaUtil.dsp (renamed from C/LzmaUtil/LzmaUtil.dsp)42
-rwxr-xr-xC/Util/Lzma/LzmaUtil.dsw (renamed from C/LzmaUtil/LzmaUtil.dsw)0
-rwxr-xr-xC/Util/Lzma/makefile (renamed from C/LzmaUtil/makefile)4
-rwxr-xr-xC/Util/Lzma/makefile.gcc44
-rwxr-xr-xC/Util/LzmaLib/LzmaLib.def (renamed from C/LzmaLib/LzmaLib.def)0
-rwxr-xr-xC/Util/LzmaLib/LzmaLib.dsp (renamed from C/LzmaLib/LzmaLib.dsp)34
-rwxr-xr-xC/Util/LzmaLib/LzmaLib.dsw (renamed from C/LzmaLib/LzmaLib.dsw)0
-rwxr-xr-xC/Util/LzmaLib/LzmaLibExports.c (renamed from C/LzmaLib/LzmaLibExports.c)0
-rwxr-xr-xC/Util/LzmaLib/makefile (renamed from C/LzmaLib/makefile)6
-rwxr-xr-xC/Util/LzmaLib/resource.rc (renamed from C/LzmaLib/resource.rc)2
-rwxr-xr-xC/XzDec.c7
-rwxr-xr-xC/XzEnc.c4
-rwxr-xr-xC/XzIn.c5
44 files changed, 917 insertions, 936 deletions
diff --git a/C/7z.h b/C/7z.h
new file mode 100755
index 00000000..e5fad3dd
--- /dev/null
+++ b/C/7z.h
@@ -0,0 +1,201 @@
+/* 7z.h -- 7z interface
+2009-08-17 : Igor Pavlov : Public domain */
+
+#ifndef __7Z_H
+#define __7Z_H
+
+#include "7zBuf.h"
+
+EXTERN_C_BEGIN
+
+#define k7zStartHeaderSize 0x20
+#define k7zSignatureSize 6
+extern Byte k7zSignature[k7zSignatureSize];
+#define k7zMajorVersion 0
+
+enum EIdEnum
+{
+ k7zIdEnd,
+ k7zIdHeader,
+ k7zIdArchiveProperties,
+ k7zIdAdditionalStreamsInfo,
+ k7zIdMainStreamsInfo,
+ k7zIdFilesInfo,
+ k7zIdPackInfo,
+ k7zIdUnpackInfo,
+ k7zIdSubStreamsInfo,
+ k7zIdSize,
+ k7zIdCRC,
+ k7zIdFolder,
+ k7zIdCodersUnpackSize,
+ k7zIdNumUnpackStream,
+ k7zIdEmptyStream,
+ k7zIdEmptyFile,
+ k7zIdAnti,
+ k7zIdName,
+ k7zIdCTime,
+ k7zIdATime,
+ k7zIdMTime,
+ k7zIdWinAttributes,
+ k7zIdComment,
+ k7zIdEncodedHeader,
+ k7zIdStartPos,
+ k7zIdDummy
+};
+
+typedef struct
+{
+ UInt32 NumInStreams;
+ UInt32 NumOutStreams;
+ UInt64 MethodID;
+ CBuf Props;
+} CSzCoderInfo;
+
+void SzCoderInfo_Init(CSzCoderInfo *p);
+void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc);
+
+typedef struct
+{
+ UInt32 InIndex;
+ UInt32 OutIndex;
+} CSzBindPair;
+
+typedef struct
+{
+ CSzCoderInfo *Coders;
+ CSzBindPair *BindPairs;
+ UInt32 *PackStreams;
+ UInt64 *UnpackSizes;
+ UInt32 NumCoders;
+ UInt32 NumBindPairs;
+ UInt32 NumPackStreams;
+ int UnpackCRCDefined;
+ UInt32 UnpackCRC;
+
+ UInt32 NumUnpackStreams;
+} CSzFolder;
+
+void SzFolder_Init(CSzFolder *p);
+UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
+int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex);
+UInt32 SzFolder_GetNumOutStreams(CSzFolder *p);
+UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
+
+SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes,
+ ILookInStream *stream, UInt64 startPos,
+ Byte *outBuffer, size_t outSize, ISzAlloc *allocMain);
+
+typedef struct
+{
+ UInt32 Low;
+ UInt32 High;
+} CNtfsFileTime;
+
+typedef struct
+{
+ CNtfsFileTime MTime;
+ UInt64 Size;
+ UInt32 Crc;
+ Byte HasStream;
+ Byte IsDir;
+ Byte IsAnti;
+ Byte CrcDefined;
+ Byte MTimeDefined;
+} CSzFileItem;
+
+void SzFile_Init(CSzFileItem *p);
+
+typedef struct
+{
+ UInt64 *PackSizes;
+ Byte *PackCRCsDefined;
+ UInt32 *PackCRCs;
+ CSzFolder *Folders;
+ CSzFileItem *Files;
+ UInt32 NumPackStreams;
+ UInt32 NumFolders;
+ UInt32 NumFiles;
+} CSzAr;
+
+void SzAr_Init(CSzAr *p);
+void SzAr_Free(CSzAr *p, ISzAlloc *alloc);
+
+
+/*
+ SzExtract extracts file from archive
+
+ *outBuffer must be 0 before first call for each new archive.
+
+ Extracting cache:
+ If you need to decompress more than one file, you can send
+ these values from previous call:
+ *blockIndex,
+ *outBuffer,
+ *outBufferSize
+ You can consider "*outBuffer" as cache of solid block. If your archive is solid,
+ it will increase decompression speed.
+
+ If you use external function, you can declare these 3 cache variables
+ (blockIndex, outBuffer, outBufferSize) as static in that external function.
+
+ Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
+*/
+
+typedef struct
+{
+ CSzAr db;
+
+ UInt64 startPosAfterHeader;
+ UInt64 dataPos;
+
+ UInt32 *FolderStartPackStreamIndex;
+ UInt64 *PackStreamStartPositions;
+ UInt32 *FolderStartFileIndex;
+ UInt32 *FileIndexToFolderIndexMap;
+
+ size_t *FileNameOffsets; /* in 2-byte steps */
+ CBuf FileNames; /* UTF-16-LE */
+} CSzArEx;
+
+void SzArEx_Init(CSzArEx *p);
+void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc);
+UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);
+int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize);
+
+/*
+if dest == NULL, the return value specifies the required size of the buffer,
+ in 16-bit characters, including the null-terminating character.
+if dest != NULL, the return value specifies the number of 16-bit characters that
+ are written to the dest, including the null-terminating character. */
+
+size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
+
+SRes SzArEx_Extract(
+ const CSzArEx *db,
+ ILookInStream *inStream,
+ UInt32 fileIndex, /* index of file */
+ UInt32 *blockIndex, /* index of solid block */
+ Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
+ size_t *outBufferSize, /* buffer size for output buffer */
+ size_t *offset, /* offset of stream for required file in *outBuffer */
+ size_t *outSizeProcessed, /* size of file in *outBuffer */
+ ISzAlloc *allocMain,
+ ISzAlloc *allocTemp);
+
+
+/*
+SzArEx_Open Errors:
+SZ_ERROR_NO_ARCHIVE
+SZ_ERROR_ARCHIVE
+SZ_ERROR_UNSUPPORTED
+SZ_ERROR_MEM
+SZ_ERROR_CRC
+SZ_ERROR_INPUT_EOF
+SZ_ERROR_FAIL
+*/
+
+SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp);
+
+EXTERN_C_END
+
+#endif
diff --git a/C/Archive/7z/7zDecode.c b/C/7zDec.c
index 0d310a48..b2b1a731 100755
--- a/C/Archive/7z/7zDecode.c
+++ b/C/7zDec.c
@@ -1,14 +1,14 @@
-/* 7zDecode.c -- Decoding from 7z folder
-2009-05-03 : Igor Pavlov : Public domain */
+/* 7zDec.c -- Decoding from 7z folder
+2009-08-16 : Igor Pavlov : Public domain */
#include <string.h>
-#include "../../Bcj2.h"
-#include "../../Bra.h"
-#include "../../LzmaDec.h"
-#include "../../Lzma2Dec.h"
+#include "7z.h"
-#include "7zDecode.h"
+#include "Bcj2.h"
+#include "Bra.h"
+#include "LzmaDec.h"
+#include "Lzma2Dec.h"
#define k_Copy 0
#define k_LZMA2 0x21
@@ -137,7 +137,7 @@ static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer
#define IS_NO_BCJ(c) (c.MethodID != k_BCJ || c.NumInStreams != 1 || c.NumOutStreams != 1)
#define IS_NO_BCJ2(c) (c.MethodID != k_BCJ2 || c.NumInStreams != 4 || c.NumOutStreams != 1)
-SRes CheckSupportedFolder(const CSzFolder *f)
+static SRes CheckSupportedFolder(const CSzFolder *f)
{
if (f->NumCoders < 1 || f->NumCoders > 4)
return SZ_ERROR_UNSUPPORTED;
@@ -179,7 +179,7 @@ SRes CheckSupportedFolder(const CSzFolder *f)
return SZ_ERROR_UNSUPPORTED;
}
-UInt64 GetSum(const UInt64 *values, UInt32 index)
+static UInt64 GetSum(const UInt64 *values, UInt32 index)
{
UInt64 sum = 0;
UInt32 i;
@@ -188,7 +188,7 @@ UInt64 GetSum(const UInt64 *values, UInt32 index)
return sum;
}
-SRes SzDecode2(const UInt64 *packSizes, const CSzFolder *folder,
+static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes,
ILookInStream *inStream, UInt64 startPos,
Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain,
Byte *tempBuf[])
@@ -296,13 +296,13 @@ SRes SzDecode2(const UInt64 *packSizes, const CSzFolder *folder,
return SZ_OK;
}
-SRes SzDecode(const UInt64 *packSizes, const CSzFolder *folder,
+SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes,
ILookInStream *inStream, UInt64 startPos,
Byte *outBuffer, size_t outSize, ISzAlloc *allocMain)
{
Byte *tempBuf[3] = { 0, 0, 0};
int i;
- SRes res = SzDecode2(packSizes, folder, inStream, startPos,
+ SRes res = SzFolder_Decode2(folder, packSizes, inStream, startPos,
outBuffer, (SizeT)outSize, allocMain, tempBuf);
for (i = 0; i < 3; i++)
IAlloc_Free(allocMain, tempBuf[i]);
diff --git a/C/7zFile.c b/C/7zFile.c
index 9a44c59a..299e0c47 100755
--- a/C/7zFile.c
+++ b/C/7zFile.c
@@ -1,5 +1,5 @@
/* 7zFile.c -- File IO
-2008-11-22 : Igor Pavlov : Public domain */
+2009-08-16 : Igor Pavlov : Public domain */
#include "7zFile.h"
@@ -52,6 +52,20 @@ static WRes File_Open(CSzFile *p, const char *name, int writeMode)
WRes InFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 0); }
WRes OutFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 1); }
+#ifdef USE_WINDOWS_FILE
+static WRes File_OpenW(CSzFile *p, const WCHAR *name, int writeMode)
+{
+ p->handle = CreateFileW(name,
+ writeMode ? GENERIC_WRITE : GENERIC_READ,
+ FILE_SHARE_READ, NULL,
+ writeMode ? CREATE_ALWAYS : OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError();
+}
+WRes InFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 0); }
+WRes OutFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 1); }
+#endif
+
WRes File_Close(CSzFile *p)
{
#ifdef USE_WINDOWS_FILE
diff --git a/C/7zFile.h b/C/7zFile.h
index bf9806bb..58ee9128 100755
--- a/C/7zFile.h
+++ b/C/7zFile.h
@@ -1,5 +1,5 @@
/* 7zFile.h -- File IO
-2009-02-07 : Igor Pavlov : Public domain */
+2009-08-16 : Igor Pavlov : Public domain */
#ifndef __7Z_FILE_H
#define __7Z_FILE_H
@@ -16,10 +16,7 @@
#include "Types.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
+EXTERN_C_BEGIN
/* ---------- File ---------- */
@@ -35,6 +32,10 @@ typedef struct
void File_Construct(CSzFile *p);
WRes InFile_Open(CSzFile *p, const char *name);
WRes OutFile_Open(CSzFile *p, const char *name);
+#ifdef USE_WINDOWS_FILE
+WRes InFile_OpenW(CSzFile *p, const WCHAR *name);
+WRes OutFile_OpenW(CSzFile *p, const WCHAR *name);
+#endif
WRes File_Close(CSzFile *p);
/* reads max(*size, remain file's size) bytes */
@@ -75,8 +76,6 @@ typedef struct
void FileOutStream_CreateVTable(CFileOutStream *p);
-#ifdef __cplusplus
-}
-#endif
+EXTERN_C_END
#endif
diff --git a/C/Archive/7z/7zIn.c b/C/7zIn.c
index f6143f83..e687fbf2 100755
--- a/C/Archive/7z/7zIn.c
+++ b/C/7zIn.c
@@ -1,17 +1,134 @@
/* 7zIn.c -- 7z Input functions
-2008-12-31 : Igor Pavlov : Public domain */
+2009-08-17 : Igor Pavlov : Public domain */
-#include "../../7zCrc.h"
-#include "../../CpuArch.h"
+#include <string.h>
-#include "7zDecode.h"
-#include "7zIn.h"
+#include "7z.h"
+#include "7zCrc.h"
+#include "CpuArch.h"
+
+Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
#define RINOM(x) { if ((x) == 0) return SZ_ERROR_MEM; }
#define NUM_FOLDER_CODERS_MAX 32
#define NUM_CODER_STREAMS_MAX 32
+void SzCoderInfo_Init(CSzCoderInfo *p)
+{
+ Buf_Init(&p->Props);
+}
+
+void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc)
+{
+ Buf_Free(&p->Props, alloc);
+ SzCoderInfo_Init(p);
+}
+
+void SzFolder_Init(CSzFolder *p)
+{
+ p->Coders = 0;
+ p->BindPairs = 0;
+ p->PackStreams = 0;
+ p->UnpackSizes = 0;
+ p->NumCoders = 0;
+ p->NumBindPairs = 0;
+ p->NumPackStreams = 0;
+ p->UnpackCRCDefined = 0;
+ p->UnpackCRC = 0;
+ p->NumUnpackStreams = 0;
+}
+
+void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc)
+{
+ UInt32 i;
+ if (p->Coders)
+ for (i = 0; i < p->NumCoders; i++)
+ SzCoderInfo_Free(&p->Coders[i], alloc);
+ IAlloc_Free(alloc, p->Coders);
+ IAlloc_Free(alloc, p->BindPairs);
+ IAlloc_Free(alloc, p->PackStreams);
+ IAlloc_Free(alloc, p->UnpackSizes);
+ SzFolder_Init(p);
+}
+
+UInt32 SzFolder_GetNumOutStreams(CSzFolder *p)
+{
+ UInt32 result = 0;
+ UInt32 i;
+ for (i = 0; i < p->NumCoders; i++)
+ result += p->Coders[i].NumOutStreams;
+ return result;
+}
+
+int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex)
+{
+ UInt32 i;
+ for (i = 0; i < p->NumBindPairs; i++)
+ if (p->BindPairs[i].InIndex == inStreamIndex)
+ return i;
+ return -1;
+}
+
+
+int SzFolder_FindBindPairForOutStream(CSzFolder *p, UInt32 outStreamIndex)
+{
+ UInt32 i;
+ for (i = 0; i < p->NumBindPairs; i++)
+ if (p->BindPairs[i].OutIndex == outStreamIndex)
+ return i;
+ return -1;
+}
+
+UInt64 SzFolder_GetUnpackSize(CSzFolder *p)
+{
+ int i = (int)SzFolder_GetNumOutStreams(p);
+ if (i == 0)
+ return 0;
+ for (i--; i >= 0; i--)
+ if (SzFolder_FindBindPairForOutStream(p, i) < 0)
+ return p->UnpackSizes[i];
+ /* throw 1; */
+ return 0;
+}
+
+void SzFile_Init(CSzFileItem *p)
+{
+ p->HasStream = 1;
+ p->IsDir = 0;
+ p->IsAnti = 0;
+ p->CrcDefined = 0;
+ p->MTimeDefined = 0;
+}
+
+void SzAr_Init(CSzAr *p)
+{
+ p->PackSizes = 0;
+ p->PackCRCsDefined = 0;
+ p->PackCRCs = 0;
+ p->Folders = 0;
+ p->Files = 0;
+ p->NumPackStreams = 0;
+ p->NumFolders = 0;
+ p->NumFiles = 0;
+}
+
+void SzAr_Free(CSzAr *p, ISzAlloc *alloc)
+{
+ UInt32 i;
+ if (p->Folders)
+ for (i = 0; i < p->NumFolders; i++)
+ SzFolder_Free(&p->Folders[i], alloc);
+
+ IAlloc_Free(alloc, p->PackSizes);
+ IAlloc_Free(alloc, p->PackCRCsDefined);
+ IAlloc_Free(alloc, p->PackCRCs);
+ IAlloc_Free(alloc, p->Folders);
+ IAlloc_Free(alloc, p->Files);
+ SzAr_Init(p);
+}
+
+
void SzArEx_Init(CSzArEx *p)
{
SzAr_Init(&p->db);
@@ -19,6 +136,8 @@ void SzArEx_Init(CSzArEx *p)
p->PackStreamStartPositions = 0;
p->FolderStartFileIndex = 0;
p->FileIndexToFolderIndexMap = 0;
+ p->FileNameOffsets = 0;
+ Buf_Init(&p->FileNames);
}
void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc)
@@ -27,6 +146,10 @@ void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc)
IAlloc_Free(alloc, p->PackStreamStartPositions);
IAlloc_Free(alloc, p->FolderStartFileIndex);
IAlloc_Free(alloc, p->FileIndexToFolderIndexMap);
+
+ IAlloc_Free(alloc, p->FileNameOffsets);
+ Buf_Free(&p->FileNames, alloc);
+
SzAr_Free(&p->db, alloc);
SzArEx_Init(p);
}
@@ -488,11 +611,11 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc)
return SZ_ERROR_UNSUPPORTED;
folder->NumBindPairs = numBindPairs = numOutStreams - 1;
- MY_ALLOC(CBindPair, folder->BindPairs, (size_t)numBindPairs, alloc);
+ MY_ALLOC(CSzBindPair, folder->BindPairs, (size_t)numBindPairs, alloc);
for (i = 0; i < numBindPairs; i++)
{
- CBindPair *bp = folder->BindPairs + i;
+ CSzBindPair *bp = folder->BindPairs + i;
RINOK(SzReadNumber32(sd, &bp->InIndex));
RINOK(SzReadNumber32(sd, &bp->OutIndex));
}
@@ -780,81 +903,38 @@ static SRes SzReadStreamsInfo(
}
}
-Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
+size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest)
+{
+ size_t len = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex];
+ if (dest != 0)
+ {
+ size_t i;
+ const Byte *src = p->FileNames.data + (p->FileNameOffsets[fileIndex] * 2);
+ for (i = 0; i < len; i++)
+ dest[i] = GetUi16(src + i * 2);
+ }
+ return len;
+}
-static SRes SzReadFileNames(CSzData *sd, UInt32 numFiles, CSzFileItem *files, ISzAlloc *alloc)
+static SRes SzReadFileNames(const Byte *p, size_t size, UInt32 numFiles, size_t *sizes)
{
UInt32 i;
+ size_t pos = 0;
for (i = 0; i < numFiles; i++)
{
- UInt32 len = 0;
- UInt32 pos = 0;
- CSzFileItem *file = files + i;
- while (pos + 2 <= sd->Size)
+ sizes[i] = pos;
+ for (;;)
{
- int numAdds;
- UInt32 value = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8));
- pos += 2;
- len++;
- if (value == 0)
+ if (pos >= size)
+ return SZ_ERROR_ARCHIVE;
+ if (p[pos * 2] == 0 && p[pos * 2 + 1] == 0)
break;
- if (value < 0x80)
- continue;
- if (value >= 0xD800 && value < 0xE000)
- {
- UInt32 c2;
- if (value >= 0xDC00)
- return SZ_ERROR_ARCHIVE;
- if (pos + 2 > sd->Size)
- return SZ_ERROR_ARCHIVE;
- c2 = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8));
- pos += 2;
- if (c2 < 0xDC00 || c2 >= 0xE000)
- return SZ_ERROR_ARCHIVE;
- value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
- }
- for (numAdds = 1; numAdds < 5; numAdds++)
- if (value < (((UInt32)1) << (numAdds * 5 + 6)))
- break;
- len += numAdds;
- }
-
- MY_ALLOC(char, file->Name, (size_t)len, alloc);
-
- len = 0;
- while (2 <= sd->Size)
- {
- int numAdds;
- UInt32 value = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8));
- SzSkeepDataSize(sd, 2);
- if (value < 0x80)
- {
- file->Name[len++] = (char)value;
- if (value == 0)
- break;
- continue;
- }
- if (value >= 0xD800 && value < 0xE000)
- {
- UInt32 c2 = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8));
- SzSkeepDataSize(sd, 2);
- value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
- }
- for (numAdds = 1; numAdds < 5; numAdds++)
- if (value < (((UInt32)1) << (numAdds * 5 + 6)))
- break;
- file->Name[len++] = (char)(kUtf8Limits[numAdds - 1] + (value >> (6 * numAdds)));
- do
- {
- numAdds--;
- file->Name[len++] = (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F));
- }
- while (numAdds > 0);
-
- len += numAdds;
+ pos++;
}
+ pos++;
}
- return SZ_OK;
+ sizes[i] = pos;
+ return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE;
}
static SRes SzReadHeader2(
@@ -920,7 +1000,8 @@ static SRes SzReadHeader2(
if (type == k7zIdEnd)
break;
RINOK(SzReadNumber(sd, &size));
-
+ if (size > sd->Size)
+ return SZ_ERROR_ARCHIVE;
if ((UInt64)(int)type != type)
{
RINOK(SzSkeepDataSize(sd, size));
@@ -930,8 +1011,16 @@ static SRes SzReadHeader2(
{
case k7zIdName:
{
+ size_t namesSize;
RINOK(SzReadSwitch(sd));
- RINOK(SzReadFileNames(sd, numFiles, files, allocMain))
+ namesSize = (size_t)size - 1;
+ if ((namesSize & 1) != 0)
+ return SZ_ERROR_ARCHIVE;
+ if (!Buf_Create(&p->FileNames, namesSize, allocMain))
+ return SZ_ERROR_MEM;
+ MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain);
+ memcpy(p->FileNames.data, sd->Data, namesSize);
+ RINOK(SzReadFileNames(sd->Data, namesSize >> 1, numFiles, p->FileNameOffsets))
break;
}
case k7zIdEmptyStream:
@@ -988,8 +1077,8 @@ static SRes SzReadHeader2(
{
file->IsDir = 0;
file->Size = (*unpackSizes)[sizeIndex];
- file->FileCRC = (*digests)[sizeIndex];
- file->FileCRCDefined = (Byte)(*digestsDefined)[sizeIndex];
+ file->Crc = (*digests)[sizeIndex];
+ file->CrcDefined = (Byte)(*digestsDefined)[sizeIndex];
sizeIndex++;
}
else
@@ -1000,7 +1089,8 @@ static SRes SzReadHeader2(
file->IsDir = (Byte)((*emptyFileVector)[emptyFileIndex] ? 0 : 1);
emptyFileIndex++;
file->Size = 0;
- file->FileCRCDefined = 0;
+ file->Crc = 0;
+ file->CrcDefined = 0;
}
}
}
@@ -1066,7 +1156,7 @@ static SRes SzReadAndDecodePackedStreams2(
if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp))
return SZ_ERROR_MEM;
- res = SzDecode(p->PackSizes, folder,
+ res = SzFolder_Decode(folder, p->PackSizes,
inStream, dataStartPos,
outBuffer->data, (size_t)unpackSize, allocTemp);
RINOK(res);
@@ -1202,3 +1292,85 @@ SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAl
SzArEx_Free(p, allocMain);
return res;
}
+
+SRes SzArEx_Extract(
+ const CSzArEx *p,
+ ILookInStream *inStream,
+ UInt32 fileIndex,
+ UInt32 *blockIndex,
+ Byte **outBuffer,
+ size_t *outBufferSize,
+ size_t *offset,
+ size_t *outSizeProcessed,
+ ISzAlloc *allocMain,
+ ISzAlloc *allocTemp)
+{
+ UInt32 folderIndex = p->FileIndexToFolderIndexMap[fileIndex];
+ SRes res = SZ_OK;
+ *offset = 0;
+ *outSizeProcessed = 0;
+ if (folderIndex == (UInt32)-1)
+ {
+ IAlloc_Free(allocMain, *outBuffer);
+ *blockIndex = folderIndex;
+ *outBuffer = 0;
+ *outBufferSize = 0;
+ return SZ_OK;
+ }
+
+ if (*outBuffer == 0 || *blockIndex != folderIndex)
+ {
+ CSzFolder *folder = p->db.Folders + folderIndex;
+ UInt64 unpackSizeSpec = SzFolder_GetUnpackSize(folder);
+ size_t unpackSize = (size_t)unpackSizeSpec;
+ UInt64 startOffset = SzArEx_GetFolderStreamPos(p, folderIndex, 0);
+
+ if (unpackSize != unpackSizeSpec)
+ return SZ_ERROR_MEM;
+ *blockIndex = folderIndex;
+ IAlloc_Free(allocMain, *outBuffer);
+ *outBuffer = 0;
+
+ RINOK(LookInStream_SeekTo(inStream, startOffset));
+
+ if (res == SZ_OK)
+ {
+ *outBufferSize = unpackSize;
+ if (unpackSize != 0)
+ {
+ *outBuffer = (Byte *)IAlloc_Alloc(allocMain, unpackSize);
+ if (*outBuffer == 0)
+ res = SZ_ERROR_MEM;
+ }
+ if (res == SZ_OK)
+ {
+ res = SzFolder_Decode(folder,
+ p->db.PackSizes + p->FolderStartPackStreamIndex[folderIndex],
+ inStream, startOffset,
+ *outBuffer, unpackSize, allocTemp);
+ if (res == SZ_OK)
+ {
+ if (folder->UnpackCRCDefined)
+ {
+ if (CrcCalc(*outBuffer, unpackSize) != folder->UnpackCRC)
+ res = SZ_ERROR_CRC;
+ }
+ }
+ }
+ }
+ }
+ if (res == SZ_OK)
+ {
+ UInt32 i;
+ CSzFileItem *fileItem = p->db.Files + fileIndex;
+ *offset = 0;
+ for (i = p->FolderStartFileIndex[folderIndex]; i < fileIndex; i++)
+ *offset += (UInt32)p->db.Files[i].Size;
+ *outSizeProcessed = (size_t)fileItem->Size;
+ if (*offset + *outSizeProcessed > *outBufferSize)
+ return SZ_ERROR_FAIL;
+ if (fileItem->CrcDefined && CrcCalc(*outBuffer + *offset, *outSizeProcessed) != fileItem->Crc)
+ res = SZ_ERROR_CRC;
+ }
+ return res;
+}
diff --git a/C/7zVersion.h b/C/7zVersion.h
index 2804bc47..d26e721f 100755
--- a/C/7zVersion.h
+++ b/C/7zVersion.h
@@ -1,7 +1,7 @@
#define MY_VER_MAJOR 9
-#define MY_VER_MINOR 04
+#define MY_VER_MINOR 06
#define MY_VER_BUILD 0
-#define MY_VERSION "9.04 beta"
-#define MY_DATE "2009-05-30"
+#define MY_VERSION "9.06 beta"
+#define MY_DATE "2009-08-17"
#define MY_COPYRIGHT ": Igor Pavlov : Public domain"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE
diff --git a/C/Aes.c b/C/Aes.c
index 5feb9fc3..669fef6e 100755
--- a/C/Aes.c
+++ b/C/Aes.c
@@ -1,7 +1,5 @@
/* Aes.c -- AES encryption / decryption
-2008-08-05
-Igor Pavlov
-Public domain */
+2009-06-10 : Igor Pavlov : Public domain */
#include "Aes.h"
#include "CpuArch.h"
@@ -49,7 +47,7 @@ void AesGenTables(void)
{
UInt32 a1 = Sbox[i];
UInt32 a2 = xtime(a1);
- UInt32 a3 = xtime(a1) ^ a1;
+ UInt32 a3 = a2 ^ a1;
T[ i] = Ui32(a2, a1, a1, a3);
T[0x100 + i] = Ui32(a3, a2, a1, a1);
T[0x200 + i] = Ui32(a1, a3, a2, a1);
@@ -115,7 +113,7 @@ void Aes_SetKeyEncode(CAes *p, const Byte *key, unsigned keySize)
w = p->rkey;
for (i = 0; i < keySize; i++, key += 4)
- w[i] = Ui32(key[0], key[1], key[2], key[3]);
+ w[i] = GetUi32(key);
for (; i < wSize; i++)
{
diff --git a/C/Archive/7z/7zDecode.h b/C/Archive/7z/7zDecode.h
deleted file mode 100755
index 0d77970d..00000000
--- a/C/Archive/7z/7zDecode.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* 7zDecode.h -- Decoding from 7z folder
-2009-02-07 : Igor Pavlov : Public domain */
-
-#ifndef __7Z_DECODE_H
-#define __7Z_DECODE_H
-
-#include "7zItem.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-SRes SzDecode(const UInt64 *packSizes, const CSzFolder *folder,
- ILookInStream *stream, UInt64 startPos,
- Byte *outBuffer, size_t outSize, ISzAlloc *allocMain);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/C/Archive/7z/7zExtract.c b/C/Archive/7z/7zExtract.c
deleted file mode 100755
index ff79802b..00000000
--- a/C/Archive/7z/7zExtract.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* 7zExtract.c -- Extracting from 7z archive
-2008-11-23 : Igor Pavlov : Public domain */
-
-#include "../../7zCrc.h"
-#include "7zDecode.h"
-#include "7zExtract.h"
-
-SRes SzAr_Extract(
- const CSzArEx *p,
- ILookInStream *inStream,
- UInt32 fileIndex,
- UInt32 *blockIndex,
- Byte **outBuffer,
- size_t *outBufferSize,
- size_t *offset,
- size_t *outSizeProcessed,
- ISzAlloc *allocMain,
- ISzAlloc *allocTemp)
-{
- UInt32 folderIndex = p->FileIndexToFolderIndexMap[fileIndex];
- SRes res = SZ_OK;
- *offset = 0;
- *outSizeProcessed = 0;
- if (folderIndex == (UInt32)-1)
- {
- IAlloc_Free(allocMain, *outBuffer);
- *blockIndex = folderIndex;
- *outBuffer = 0;
- *outBufferSize = 0;
- return SZ_OK;
- }
-
- if (*outBuffer == 0 || *blockIndex != folderIndex)
- {
- CSzFolder *folder = p->db.Folders + folderIndex;
- UInt64 unpackSizeSpec = SzFolder_GetUnpackSize(folder);
- size_t unpackSize = (size_t)unpackSizeSpec;
- UInt64 startOffset = SzArEx_GetFolderStreamPos(p, folderIndex, 0);
-
- if (unpackSize != unpackSizeSpec)
- return SZ_ERROR_MEM;
- *blockIndex = folderIndex;
- IAlloc_Free(allocMain, *outBuffer);
- *outBuffer = 0;
-
- RINOK(LookInStream_SeekTo(inStream, startOffset));
-
- if (res == SZ_OK)
- {
- *outBufferSize = unpackSize;
- if (unpackSize != 0)
- {
- *outBuffer = (Byte *)IAlloc_Alloc(allocMain, unpackSize);
- if (*outBuffer == 0)
- res = SZ_ERROR_MEM;
- }
- if (res == SZ_OK)
- {
- res = SzDecode(p->db.PackSizes +
- p->FolderStartPackStreamIndex[folderIndex], folder,
- inStream, startOffset,
- *outBuffer, unpackSize, allocTemp);
- if (res == SZ_OK)
- {
- if (folder->UnpackCRCDefined)
- {
- if (CrcCalc(*outBuffer, unpackSize) != folder->UnpackCRC)
- res = SZ_ERROR_CRC;
- }
- }
- }
- }
- }
- if (res == SZ_OK)
- {
- UInt32 i;
- CSzFileItem *fileItem = p->db.Files + fileIndex;
- *offset = 0;
- for (i = p->FolderStartFileIndex[folderIndex]; i < fileIndex; i++)
- *offset += (UInt32)p->db.Files[i].Size;
- *outSizeProcessed = (size_t)fileItem->Size;
- if (*offset + *outSizeProcessed > *outBufferSize)
- return SZ_ERROR_FAIL;
- {
- if (fileItem->FileCRCDefined)
- {
- if (CrcCalc(*outBuffer + *offset, *outSizeProcessed) != fileItem->FileCRC)
- res = SZ_ERROR_CRC;
- }
- }
- }
- return res;
-}
diff --git a/C/Archive/7z/7zExtract.h b/C/Archive/7z/7zExtract.h
deleted file mode 100755
index 6f46bfa6..00000000
--- a/C/Archive/7z/7zExtract.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* 7zExtract.h -- Extracting from 7z archive
-2009-02-07 : Igor Pavlov : Public domain */
-
-#ifndef __7Z_EXTRACT_H
-#define __7Z_EXTRACT_H
-
-#include "7zIn.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- SzExtract extracts file from archive
-
- *outBuffer must be 0 before first call for each new archive.
-
- Extracting cache:
- If you need to decompress more than one file, you can send
- these values from previous call:
- *blockIndex,
- *outBuffer,
- *outBufferSize
- You can consider "*outBuffer" as cache of solid block. If your archive is solid,
- it will increase decompression speed.
-
- If you use external function, you can declare these 3 cache variables
- (blockIndex, outBuffer, outBufferSize) as static in that external function.
-
- Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
-*/
-
-SRes SzAr_Extract(
- const CSzArEx *db,
- ILookInStream *inStream,
- UInt32 fileIndex, /* index of file */
- UInt32 *blockIndex, /* index of solid block */
- Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
- size_t *outBufferSize, /* buffer size for output buffer */
- size_t *offset, /* offset of stream for required file in *outBuffer */
- size_t *outSizeProcessed, /* size of file in *outBuffer */
- ISzAlloc *allocMain,
- ISzAlloc *allocTemp);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/C/Archive/7z/7zHeader.c b/C/Archive/7z/7zHeader.c
deleted file mode 100755
index e48faa48..00000000
--- a/C/Archive/7z/7zHeader.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* 7zHeader.c -- 7z Headers
-2008-10-04 : Igor Pavlov : Public domain */
-
-#include "7zHeader.h"
-
-Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
diff --git a/C/Archive/7z/7zHeader.h b/C/Archive/7z/7zHeader.h
deleted file mode 100755
index bc117d2e..00000000
--- a/C/Archive/7z/7zHeader.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* 7zHeader.h -- 7z Headers
-2009-02-07 : Igor Pavlov : Public domain */
-
-#ifndef __7Z_HEADER_H
-#define __7Z_HEADER_H
-
-#include "../../Types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define k7zSignatureSize 6
-extern Byte k7zSignature[k7zSignatureSize];
-
-#define k7zMajorVersion 0
-
-#define k7zStartHeaderSize 0x20
-
-enum EIdEnum
-{
- k7zIdEnd,
-
- k7zIdHeader,
-
- k7zIdArchiveProperties,
-
- k7zIdAdditionalStreamsInfo,
- k7zIdMainStreamsInfo,
- k7zIdFilesInfo,
-
- k7zIdPackInfo,
- k7zIdUnpackInfo,
- k7zIdSubStreamsInfo,
-
- k7zIdSize,
- k7zIdCRC,
-
- k7zIdFolder,
-
- k7zIdCodersUnpackSize,
- k7zIdNumUnpackStream,
-
- k7zIdEmptyStream,
- k7zIdEmptyFile,
- k7zIdAnti,
-
- k7zIdName,
- k7zIdCTime,
- k7zIdATime,
- k7zIdMTime,
- k7zIdWinAttributes,
- k7zIdComment,
-
- k7zIdEncodedHeader,
-
- k7zIdStartPos,
- k7zIdDummy
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/C/Archive/7z/7zIn.h b/C/Archive/7z/7zIn.h
deleted file mode 100755
index 50db4d38..00000000
--- a/C/Archive/7z/7zIn.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* 7zIn.h -- 7z Input
-2009-02-07 : Igor Pavlov : Public domain */
-
-#ifndef __7Z_IN_H
-#define __7Z_IN_H
-
-#include "7zHeader.h"
-#include "7zItem.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct
-{
- CSzAr db;
-
- UInt64 startPosAfterHeader;
- UInt64 dataPos;
-
- UInt32 *FolderStartPackStreamIndex;
- UInt64 *PackStreamStartPositions;
- UInt32 *FolderStartFileIndex;
- UInt32 *FileIndexToFolderIndexMap;
-} CSzArEx;
-
-void SzArEx_Init(CSzArEx *p);
-void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc);
-UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);
-int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize);
-
-/*
-Errors:
-SZ_ERROR_NO_ARCHIVE
-SZ_ERROR_ARCHIVE
-SZ_ERROR_UNSUPPORTED
-SZ_ERROR_MEM
-SZ_ERROR_CRC
-SZ_ERROR_INPUT_EOF
-SZ_ERROR_FAIL
-*/
-
-SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/C/Archive/7z/7zItem.c b/C/Archive/7z/7zItem.c
deleted file mode 100755
index db44571e..00000000
--- a/C/Archive/7z/7zItem.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* 7zItem.c -- 7z Items
-2008-10-04 : Igor Pavlov : Public domain */
-
-#include "7zItem.h"
-
-void SzCoderInfo_Init(CSzCoderInfo *p)
-{
- Buf_Init(&p->Props);
-}
-
-void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc)
-{
- Buf_Free(&p->Props, alloc);
- SzCoderInfo_Init(p);
-}
-
-void SzFolder_Init(CSzFolder *p)
-{
- p->Coders = 0;
- p->BindPairs = 0;
- p->PackStreams = 0;
- p->UnpackSizes = 0;
- p->NumCoders = 0;
- p->NumBindPairs = 0;
- p->NumPackStreams = 0;
- p->UnpackCRCDefined = 0;
- p->UnpackCRC = 0;
- p->NumUnpackStreams = 0;
-}
-
-void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc)
-{
- UInt32 i;
- if (p->Coders)
- for (i = 0; i < p->NumCoders; i++)
- SzCoderInfo_Free(&p->Coders[i], alloc);
- IAlloc_Free(alloc, p->Coders);
- IAlloc_Free(alloc, p->BindPairs);
- IAlloc_Free(alloc, p->PackStreams);
- IAlloc_Free(alloc, p->UnpackSizes);
- SzFolder_Init(p);
-}
-
-UInt32 SzFolder_GetNumOutStreams(CSzFolder *p)
-{
- UInt32 result = 0;
- UInt32 i;
- for (i = 0; i < p->NumCoders; i++)
- result += p->Coders[i].NumOutStreams;
- return result;
-}
-
-int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex)
-{
- UInt32 i;
- for (i = 0; i < p->NumBindPairs; i++)
- if (p->BindPairs[i].InIndex == inStreamIndex)
- return i;
- return -1;
-}
-
-
-int SzFolder_FindBindPairForOutStream(CSzFolder *p, UInt32 outStreamIndex)
-{
- UInt32 i;
- for (i = 0; i < p->NumBindPairs; i++)
- if (p->BindPairs[i].OutIndex == outStreamIndex)
- return i;
- return -1;
-}
-
-UInt64 SzFolder_GetUnpackSize(CSzFolder *p)
-{
- int i = (int)SzFolder_GetNumOutStreams(p);
- if (i == 0)
- return 0;
- for (i--; i >= 0; i--)
- if (SzFolder_FindBindPairForOutStream(p, i) < 0)
- return p->UnpackSizes[i];
- /* throw 1; */
- return 0;
-}
-
-void SzFile_Init(CSzFileItem *p)
-{
- p->HasStream = 1;
- p->IsDir = 0;
- p->IsAnti = 0;
- p->FileCRCDefined = 0;
- p->MTimeDefined = 0;
- p->Name = 0;
-}
-
-static void SzFile_Free(CSzFileItem *p, ISzAlloc *alloc)
-{
- IAlloc_Free(alloc, p->Name);
- SzFile_Init(p);
-}
-
-void SzAr_Init(CSzAr *p)
-{
- p->PackSizes = 0;
- p->PackCRCsDefined = 0;
- p->PackCRCs = 0;
- p->Folders = 0;
- p->Files = 0;
- p->NumPackStreams = 0;
- p->NumFolders = 0;
- p->NumFiles = 0;
-}
-
-void SzAr_Free(CSzAr *p, ISzAlloc *alloc)
-{
- UInt32 i;
- if (p->Folders)
- for (i = 0; i < p->NumFolders; i++)
- SzFolder_Free(&p->Folders[i], alloc);
- if (p->Files)
- for (i = 0; i < p->NumFiles; i++)
- SzFile_Free(&p->Files[i], alloc);
- IAlloc_Free(alloc, p->PackSizes);
- IAlloc_Free(alloc, p->PackCRCsDefined);
- IAlloc_Free(alloc, p->PackCRCs);
- IAlloc_Free(alloc, p->Folders);
- IAlloc_Free(alloc, p->Files);
- SzAr_Init(p);
-}
diff --git a/C/Archive/7z/7zItem.h b/C/Archive/7z/7zItem.h
deleted file mode 100755
index ce7288c2..00000000
--- a/C/Archive/7z/7zItem.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* 7zItem.h -- 7z Items
-2009-02-07 : Igor Pavlov : Public domain */
-
-#ifndef __7Z_ITEM_H
-#define __7Z_ITEM_H
-
-#include "../../7zBuf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct
-{
- UInt32 NumInStreams;
- UInt32 NumOutStreams;
- UInt64 MethodID;
- CBuf Props;
-} CSzCoderInfo;
-
-void SzCoderInfo_Init(CSzCoderInfo *p);
-void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc);
-
-typedef struct
-{
- UInt32 InIndex;
- UInt32 OutIndex;
-} CBindPair;
-
-typedef struct
-{
- CSzCoderInfo *Coders;
- CBindPair *BindPairs;
- UInt32 *PackStreams;
- UInt64 *UnpackSizes;
- UInt32 NumCoders;
- UInt32 NumBindPairs;
- UInt32 NumPackStreams;
- int UnpackCRCDefined;
- UInt32 UnpackCRC;
-
- UInt32 NumUnpackStreams;
-} CSzFolder;
-
-void SzFolder_Init(CSzFolder *p);
-UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
-int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex);
-UInt32 SzFolder_GetNumOutStreams(CSzFolder *p);
-UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
-
-typedef struct
-{
- UInt32 Low;
- UInt32 High;
-} CNtfsFileTime;
-
-typedef struct
-{
- CNtfsFileTime MTime;
- UInt64 Size;
- char *Name;
- UInt32 FileCRC;
-
- Byte HasStream;
- Byte IsDir;
- Byte IsAnti;
- Byte FileCRCDefined;
- Byte MTimeDefined;
-} CSzFileItem;
-
-void SzFile_Init(CSzFileItem *p);
-
-typedef struct
-{
- UInt64 *PackSizes;
- Byte *PackCRCsDefined;
- UInt32 *PackCRCs;
- CSzFolder *Folders;
- CSzFileItem *Files;
- UInt32 NumPackStreams;
- UInt32 NumFolders;
- UInt32 NumFiles;
-} CSzAr;
-
-void SzAr_Init(CSzAr *p);
-void SzAr_Free(CSzAr *p, ISzAlloc *alloc);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/C/CpuArch.h b/C/CpuArch.h
index 10ec02b3..13f53dd9 100755
--- a/C/CpuArch.h
+++ b/C/CpuArch.h
@@ -1,5 +1,5 @@
/* CpuArch.h
-2009-03-22 : Igor Pavlov : Public domain */
+2009-08-11 : Igor Pavlov : Public domain */
#ifndef __CPU_ARCH_H
#define __CPU_ARCH_H
@@ -16,7 +16,19 @@ if LITTLE_ENDIAN_UNALIGN is not defined, it means that we don't know
about these properties of platform.
*/
-#if defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || defined(__i386__) || defined(__x86_64__)
+#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__)
+#define MY_CPU_AMD64
+#endif
+
+#if defined(MY_CPU_AMD64) || defined(_M_IA64)
+#define MY_CPU_64BIT
+#endif
+
+#if defined(_M_IX86) || defined(__i386__) || defined(MY_CPU_AMD64)
+#define MY_CPU_X86_OR_AMD64
+#endif
+
+#if defined(MY_CPU_X86_OR_AMD64)
#define LITTLE_ENDIAN_UNALIGN
#endif
diff --git a/C/LzmaUtil/Lzma86Enc.h b/C/Lzma86.h
index 355bf343..6acbd888 100755
--- a/C/LzmaUtil/Lzma86Enc.h
+++ b/C/Lzma86.h
@@ -1,14 +1,15 @@
-/* Lzma86Enc.h -- LZMA + x86 (BCJ) Filter Encoder
-2009-02-07 : Igor Pavlov : Public domain */
+/* Lzma86.h -- LZMA + x86 (BCJ) Filter
+2009-08-14 : Igor Pavlov : Public domain */
-#ifndef __LZMA86_ENC_H
-#define __LZMA86_ENC_H
+#ifndef __LZMA86_H
+#define __LZMA86_H
-#include "../Types.h"
+#include "Types.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+EXTERN_C_BEGIN
+
+#define LZMA86_SIZE_OFFSET (1 + 5)
+#define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)
/*
It's an example for LZMA + x86 Filter use.
@@ -16,8 +17,8 @@ You can use .lzma86 extension, if you write that stream to file.
.lzma86 header adds one additional byte to standard .lzma header.
.lzma86 header (14 bytes):
Offset Size Description
- 0 1 = 0 - no filter,
- = 1 - x86 filter
+ 0 1 = 0 - no filter, pure LZMA
+ = 1 - x86 filter + LZMA
1 1 lc, lp and pb in encoded form
2 4 dictSize (little endian)
6 8 uncompressed size (little endian)
@@ -27,7 +28,6 @@ Lzma86_Encode
-------------
level - compression level: 0 <= level <= 9, the default value for "level" is 5.
-
dictSize - The dictionary size in bytes. The maximum value is
128 MB = (1 << 27) bytes for 32-bit version
1 GB = (1 << 30) bytes for 64-bit version
@@ -71,8 +71,41 @@ enum ESzFilterMode
SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
int level, UInt32 dictSize, int filterMode);
-#ifdef __cplusplus
-}
-#endif
+
+/*
+Lzma86_GetUnpackSize:
+ In:
+ src - input data
+ srcLen - input data size
+ Out:
+ unpackSize - size of uncompressed stream
+ Return code:
+ SZ_OK - OK
+ SZ_ERROR_INPUT_EOF - Error in headers
+*/
+
+SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize);
+
+/*
+Lzma86_Decode:
+ In:
+ dest - output data
+ destLen - output data size
+ src - input data
+ srcLen - input data size
+ Out:
+ destLen - processed output size
+ srcLen - processed input size
+ Return code:
+ SZ_OK - OK
+ SZ_ERROR_DATA - Data error
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_UNSUPPORTED - unsupported file
+ SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer
+*/
+
+SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen);
+
+EXTERN_C_END
#endif
diff --git a/C/LzmaUtil/Lzma86Dec.c b/C/Lzma86Dec.c
index b801dd1c..fe772609 100755
--- a/C/LzmaUtil/Lzma86Dec.c
+++ b/C/Lzma86Dec.c
@@ -1,20 +1,14 @@
/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
-2008-04-07
-Igor Pavlov
-Public domain */
+2009-08-14 : Igor Pavlov : Public domain */
-#include "Lzma86Dec.h"
+#include "Lzma86.h"
-#include "../Alloc.h"
-#include "../Bra.h"
-#include "../LzmaDec.h"
-
-#define LZMA86_SIZE_OFFSET (1 + LZMA_PROPS_SIZE)
-#define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)
+#include "Alloc.h"
+#include "Bra.h"
+#include "LzmaDec.h"
static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
static void SzFree(void *p, void *address) { p = p; MyFree(address); }
-static ISzAlloc g_Alloc = { SzAlloc, SzFree };
SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
{
@@ -29,6 +23,7 @@ SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)
{
+ ISzAlloc g_Alloc = { SzAlloc, SzFree };
SRes res;
int useFilter;
SizeT inSizePure;
diff --git a/C/LzmaUtil/Lzma86Enc.c b/C/Lzma86Enc.c
index efc81ea3..2ea4ac2d 100755
--- a/C/LzmaUtil/Lzma86Enc.c
+++ b/C/Lzma86Enc.c
@@ -1,28 +1,23 @@
/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder
-2008-08-05
-Igor Pavlov
-Public domain */
+2009-08-14 : Igor Pavlov : Public domain */
#include <string.h>
-#include "Lzma86Enc.h"
+#include "Lzma86.h"
-#include "../Alloc.h"
-#include "../Bra.h"
-#include "../LzmaEnc.h"
+#include "Alloc.h"
+#include "Bra.h"
+#include "LzmaEnc.h"
#define SZE_OUT_OVERFLOW SZE_DATA_ERROR
static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
static void SzFree(void *p, void *address) { p = p; MyFree(address); }
-static ISzAlloc g_Alloc = { SzAlloc, SzFree };
-
-#define LZMA86_SIZE_OFFSET (1 + LZMA_PROPS_SIZE)
-#define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)
int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
int level, UInt32 dictSize, int filterMode)
{
+ ISzAlloc g_Alloc = { SzAlloc, SzFree };
size_t outSize2 = *destLen;
Byte *filteredStream;
Bool useFilter;
diff --git a/C/LzmaUtil/Lzma86Dec.h b/C/LzmaUtil/Lzma86Dec.h
deleted file mode 100755
index 138ce1ff..00000000
--- a/C/LzmaUtil/Lzma86Dec.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Lzma86Dec.h -- LZMA + x86 (BCJ) Filter Decoder
-2009-02-07 : Igor Pavlov : Public domain */
-
-#ifndef __LZMA86_DEC_H
-#define __LZMA86_DEC_H
-
-#include "../Types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
-Lzma86_GetUnpackSize:
- In:
- src - input data
- srcLen - input data size
- Out:
- unpackSize - size of uncompressed stream
- Return code:
- SZ_OK - OK
- SZ_ERROR_INPUT_EOF - Error in headers
-*/
-
-SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize);
-
-/*
-Lzma86_Decode:
- In:
- dest - output data
- destLen - output data size
- src - input data
- srcLen - input data size
- Out:
- destLen - processed output size
- srcLen - processed input size
- Return code:
- SZ_OK - OK
- SZ_ERROR_DATA - Data error
- SZ_ERROR_MEM - Memory allocation error
- SZ_ERROR_UNSUPPORTED - unsupported file
- SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer
-*/
-
-SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/C/LzmaUtil/makefile.gcc b/C/LzmaUtil/makefile.gcc
deleted file mode 100755
index 9fcdeadb..00000000
--- a/C/LzmaUtil/makefile.gcc
+++ /dev/null
@@ -1,44 +0,0 @@
-PROG = lzma
-CXX = g++
-LIB =
-RM = rm -f
-CFLAGS = -c -O2 -Wall
-
-OBJS = \
- LzmaUtil.o \
- Alloc.o \
- LzFind.o \
- LzmaDec.o \
- LzmaEnc.o \
- 7zFile.o \
- 7zStream.o \
-
-
-all: $(PROG)
-
-$(PROG): $(OBJS)
- $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB) $(LIB2)
-
-LzmaUtil.o: LzmaUtil.c
- $(CXX) $(CFLAGS) LzmaUtil.c
-
-Alloc.o: ../Alloc.c
- $(CXX) $(CFLAGS) ../Alloc.c
-
-LzFind.o: ../LzFind.c
- $(CXX) $(CFLAGS) ../LzFind.c
-
-LzmaDec.o: ../LzmaDec.c
- $(CXX) $(CFLAGS) ../LzmaDec.c
-
-LzmaEnc.o: ../LzmaEnc.c
- $(CXX) $(CFLAGS) ../LzmaEnc.c
-
-7zFile.o: ../7zFile.c
- $(CXX) $(CFLAGS) ../7zFile.c
-
-7zStream.o: ../7zStream.c
- $(CXX) $(CFLAGS) ../7zStream.c
-
-clean:
- -$(RM) $(PROG) $(OBJS)
diff --git a/C/Threads.c b/C/Threads.c
index 562b3484..212032aa 100755
--- a/C/Threads.c
+++ b/C/Threads.c
@@ -1,7 +1,9 @@
/* Threads.c -- multithreading library
-2009-03-27 : Igor Pavlov : Public domain */
+2009-07-20 : Igor Pavlov : Public domain */
+#ifndef _WIN32_WCE
#include <process.h>
+#endif
#include "Threads.h"
@@ -29,8 +31,11 @@ WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param)
{
unsigned threadId; /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */
*p =
- /* CreateThread(0, 0, startAddress, param, 0, &threadId); */
+ #ifdef UNDER_CE
+ CreateThread(0, 0, func, param, 0, &threadId);
+ #else
(HANDLE)_beginthreadex(NULL, 0, func, param, 0, &threadId);
+ #endif
/* maybe we must use errno here, but probably GetLastError() is also OK. */
return HandleToWRes(*p);
}
diff --git a/C/Types.h b/C/Types.h
index 9af877ff..04580915 100755
--- a/C/Types.h
+++ b/C/Types.h
@@ -1,5 +1,5 @@
/* Types.h -- Basic types
-2009-02-07 : Igor Pavlov : Public domain */
+2009-08-14 : Igor Pavlov : Public domain */
#ifndef __7Z_TYPES_H
#define __7Z_TYPES_H
@@ -10,10 +10,18 @@
#include <windows.h>
#endif
+#ifndef EXTERN_C_BEGIN
#ifdef __cplusplus
-extern "C" {
+#define EXTERN_C_BEGIN extern "C" {
+#define EXTERN_C_END }
+#else
+#define EXTERN_C_BEGIN
+#define EXTERN_C_END
+#endif
#endif
+EXTERN_C_BEGIN
+
#define SZ_OK 0
#define SZ_ERROR_DATA 1
@@ -209,8 +217,6 @@ typedef struct
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
#define IAlloc_Free(p, a) (p)->Free((p), a)
-#ifdef __cplusplus
-}
-#endif
+EXTERN_C_END
#endif
diff --git a/C/Archive/7z/7z.dsp b/C/Util/7z/7z.dsp
index 6d6b8d93..491f3c94 100755
--- a/C/Archive/7z/7z.dsp
+++ b/C/Util/7z/7z.dsp
@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FAs /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FAs /YX /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -67,7 +67,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W4 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /YX /FD /GZ /c
+# ADD CPP /nologo /W4 /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /YX /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -132,6 +132,10 @@ SOURCE=..\..\Bra86.c
# End Source File
# Begin Source File
+SOURCE=..\..\CpuArch.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Lzma2Dec.c
# End Source File
# Begin Source File
@@ -153,51 +157,23 @@ SOURCE=..\..\Types.h
# End Group
# Begin Source File
-SOURCE=.\7zAlloc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zAlloc.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zDecode.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zDecode.h
+SOURCE=..\..\7z.h
# End Source File
# Begin Source File
-SOURCE=.\7zExtract.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zExtract.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zHeader.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zHeader.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\7zIn.c
+SOURCE=.\7zAlloc.c
# End Source File
# Begin Source File
-SOURCE=.\7zIn.h
+SOURCE=.\7zAlloc.h
# End Source File
# Begin Source File
-SOURCE=.\7zItem.c
+SOURCE=..\..\7zDec.c
# End Source File
# Begin Source File
-SOURCE=.\7zItem.h
+SOURCE=..\..\7zIn.c
# End Source File
# Begin Source File
diff --git a/C/Archive/7z/7z.dsw b/C/Util/7z/7z.dsw
index 848d13cb..848d13cb 100755
--- a/C/Archive/7z/7z.dsw
+++ b/C/Util/7z/7z.dsw
diff --git a/C/Archive/7z/7zAlloc.c b/C/Util/7z/7zAlloc.c
index 4bfaf42a..4bfaf42a 100755
--- a/C/Archive/7z/7zAlloc.c
+++ b/C/Util/7z/7zAlloc.c
diff --git a/C/Archive/7z/7zAlloc.h b/C/Util/7z/7zAlloc.h
index a5e88e47..a5e88e47 100755
--- a/C/Archive/7z/7zAlloc.h
+++ b/C/Util/7z/7zAlloc.h
diff --git a/C/Archive/7z/7zMain.c b/C/Util/7z/7zMain.c
index ae65125f..585449e3 100755
--- a/C/Archive/7z/7zMain.c
+++ b/C/Util/7z/7zMain.c
@@ -1,17 +1,16 @@
/* 7zMain.c - Test application for 7z Decoder
-2009-04-04 : Igor Pavlov : Public domain */
+2009-08-17 : Igor Pavlov : Public domain */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include "../../7z.h"
#include "../../7zCrc.h"
#include "../../7zFile.h"
#include "../../7zVersion.h"
#include "7zAlloc.h"
-#include "7zExtract.h"
-#include "7zIn.h"
#ifndef USE_WINDOWS_FILE
/* for mkdir */
@@ -29,20 +28,162 @@
#define CHAR_PATH_SEPARATOR '/'
#endif
-static WRes MyCreateDir(const char *name)
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+
+static int Buf_EnsureSize(CBuf *dest, size_t size)
+{
+ if (dest->size >= size)
+ return 1;
+ Buf_Free(dest, &g_Alloc);
+ return Buf_Create(dest, size, &g_Alloc);
+}
+
+#ifndef _WIN32
+
+static Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
+
+static Bool Utf16_To_Utf8(Byte *dest, size_t *destLen, const UInt16 *src, size_t srcLen)
+{
+ size_t destPos = 0, srcPos = 0;
+ for (;;)
+ {
+ unsigned numAdds;
+ UInt32 value;
+ if (srcPos == srcLen)
+ {
+ *destLen = destPos;
+ return True;
+ }
+ value = src[srcPos++];
+ if (value < 0x80)
+ {
+ if (dest)
+ dest[destPos] = (char)value;
+ destPos++;
+ continue;
+ }
+ if (value >= 0xD800 && value < 0xE000)
+ {
+ UInt32 c2;
+ if (value >= 0xDC00 || srcPos == srcLen)
+ break;
+ c2 = src[srcPos++];
+ if (c2 < 0xDC00 || c2 >= 0xE000)
+ break;
+ value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
+ }
+ for (numAdds = 1; numAdds < 5; numAdds++)
+ if (value < (((UInt32)1) << (numAdds * 5 + 6)))
+ break;
+ if (dest)
+ dest[destPos] = (char)(kUtf8Limits[numAdds - 1] + (value >> (6 * numAdds)));
+ destPos++;
+ do
+ {
+ numAdds--;
+ if (dest)
+ dest[destPos] = (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F));
+ destPos++;
+ }
+ while (numAdds != 0);
+ }
+ *destLen = destPos;
+ return False;
+}
+
+static SRes Utf16_To_Utf8Buf(CBuf *dest, const UInt16 *src, size_t srcLen)
+{
+ size_t destLen = 0;
+ Bool res;
+ Utf16_To_Utf8(NULL, &destLen, src, srcLen);
+ destLen += 1;
+ if (!Buf_EnsureSize(dest, destLen))
+ return SZ_ERROR_MEM;
+ res = Utf16_To_Utf8(dest->data, &destLen, src, srcLen);
+ dest->data[destLen] = 0;
+ return res ? SZ_OK : SZ_ERROR_FAIL;
+}
+#endif
+
+static WRes Utf16_To_Char(CBuf *buf, const UInt16 *s, int fileMode)
+{
+ int len = 0;
+ for (len = 0; s[len] != '\0'; len++);
+
+ #ifdef _WIN32
+ {
+ int size = len * 3 + 100;
+ if (!Buf_EnsureSize(buf, size))
+ return SZ_ERROR_MEM;
+ {
+ char defaultChar = '_';
+ BOOL defUsed;
+ int numChars = WideCharToMultiByte(fileMode ? (AreFileApisANSI() ? CP_ACP : CP_OEMCP) : CP_OEMCP,
+ 0, s, len, (char *)buf->data, size, &defaultChar, &defUsed);
+ if (numChars == 0 || numChars >= size)
+ return SZ_ERROR_FAIL;
+ buf->data[numChars] = 0;
+ return SZ_OK;
+ }
+ }
+ #else
+ fileMode = fileMode;
+ return Utf16_To_Utf8Buf(buf, s, len);
+ #endif
+}
+
+static WRes MyCreateDir(const UInt16 *name)
{
#ifdef USE_WINDOWS_FILE
- return CreateDirectoryA(name, NULL) ? 0 : GetLastError();
+
+ return CreateDirectoryW(name, NULL) ? 0 : GetLastError();
+
#else
+
+ CBuf buf;
+ WRes res;
+ Buf_Init(&buf);
+ RINOK(Utf16_To_Char(&buf, name, 1));
+
+ res =
#ifdef _WIN32
- return _mkdir(name)
+ _mkdir((const char *)buf.data)
#else
- return mkdir(name, 0777)
+ mkdir((const char *)buf.data, 0777)
#endif
== 0 ? 0 : errno;
+ Buf_Free(&buf, &g_Alloc);
+ return res;
+
+ #endif
+}
+
+static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name)
+{
+ #ifdef USE_WINDOWS_FILE
+ return OutFile_OpenW(p, name);
+ #else
+ CBuf buf;
+ WRes res;
+ Buf_Init(&buf);
+ RINOK(Utf16_To_Char(&buf, name, 1));
+ res = OutFile_Open(p, (const char *)buf.data);
+ Buf_Free(&buf, &g_Alloc);
+ return res;
#endif
}
+static void PrintString(const UInt16 *s)
+{
+ CBuf buf;
+ Buf_Init(&buf);
+ if (Utf16_To_Char(&buf, s, 0) == 0)
+ {
+ printf("%s", buf.data);
+ Buf_Free(&buf, &g_Alloc);
+ }
+}
+
static void ConvertNumberToString(UInt64 value, char *s)
{
@@ -128,7 +269,7 @@ int MY_CDECL main(int numargs, char *args[])
SRes res;
ISzAlloc allocImp;
ISzAlloc allocTempImp;
- char *temp = NULL;
+ UInt16 *temp = NULL;
size_t tempSize = 0;
printf("\n7z ANSI-C Decoder " MY_VERSION_COPYRIGHT_DATE "\n\n");
@@ -149,25 +290,24 @@ int MY_CDECL main(int numargs, char *args[])
return 1;
}
+ allocImp.Alloc = SzAlloc;
+ allocImp.Free = SzFree;
+
+ allocTempImp.Alloc = SzAllocTemp;
+ allocTempImp.Free = SzFreeTemp;
+
if (InFile_Open(&archiveStream.file, args[2]))
{
PrintError("can not open input file");
return 1;
}
-
FileInStream_CreateVTable(&archiveStream);
LookToRead_CreateVTable(&lookStream, False);
lookStream.realStream = &archiveStream.s;
LookToRead_Init(&lookStream);
- allocImp.Alloc = SzAlloc;
- allocImp.Free = SzFree;
-
- allocTempImp.Alloc = SzAllocTemp;
- allocTempImp.Free = SzFreeTemp;
-
CrcGenerateTable();
SzArEx_Init(&db);
@@ -180,27 +320,13 @@ int MY_CDECL main(int numargs, char *args[])
else if (strcmp(command, "t") == 0) testCommand = 1;
else if (strcmp(command, "e") == 0) extractCommand = 1;
else if (strcmp(command, "x") == 0) { extractCommand = 1; fullPaths = 1; }
-
- if (listCommand)
+ else
{
- UInt32 i;
- for (i = 0; i < db.db.NumFiles; i++)
- {
- const CSzFileItem *f = db.db.Files + i;
- char s[32], t[32];
- ConvertNumberToString(f->Size, s);
- if (f->MTimeDefined)
- ConvertFileTimeToString(&f->MTime, t);
- else
- strcpy(t, " ");
-
- printf("%s %10s %s", t, s, f->Name);
- if (f->IsDir)
- printf("/");
- printf("\n");
- }
+ PrintError("incorrect command");
+ res = SZ_ERROR_FAIL;
}
- else if (testCommand || extractCommand)
+
+ if (res == SZ_OK)
{
UInt32 i;
@@ -214,20 +340,52 @@ int MY_CDECL main(int numargs, char *args[])
for (i = 0; i < db.db.NumFiles; i++)
{
- size_t offset;
- size_t outSizeProcessed;
+ size_t offset = 0;
+ size_t outSizeProcessed = 0;
const CSzFileItem *f = db.db.Files + i;
- if (f->IsDir && !fullPaths)
+ size_t len;
+ if (listCommand == 0 && f->IsDir && !fullPaths)
+ continue;
+ len = SzArEx_GetFileNameUtf16(&db, i, NULL);
+
+ if (len > tempSize)
+ {
+ SzFree(NULL, temp);
+ tempSize = len;
+ temp = (UInt16 *)SzAlloc(NULL, tempSize * sizeof(temp[0]));
+ if (temp == 0)
+ {
+ res = SZ_ERROR_MEM;
+ break;
+ }
+ }
+
+ SzArEx_GetFileNameUtf16(&db, i, temp);
+ if (listCommand)
+ {
+ char s[32], t[32];
+ ConvertNumberToString(f->Size, s);
+ if (f->MTimeDefined)
+ ConvertFileTimeToString(&f->MTime, t);
+ else
+ strcpy(t, " ");
+
+ printf("%s %10s ", t, s);
+ PrintString(temp);
+ if (f->IsDir)
+ printf("/");
+ printf("\n");
continue;
+ }
printf(testCommand ?
- "Testing ":
- "Extracting");
- printf(" %s", f->Name);
+ "Testing ":
+ "Extracting ");
+ PrintString(temp);
if (f->IsDir)
printf("/");
else
{
- res = SzAr_Extract(&db, &lookStream.s, i,
+ res = SzArEx_Extract(&db, &lookStream.s, i,
&blockIndex, &outBuffer, &outBufferSize,
&offset, &outSizeProcessed,
&allocImp, &allocTempImp);
@@ -238,32 +396,20 @@ int MY_CDECL main(int numargs, char *args[])
{
CSzFile outFile;
size_t processedSize;
- size_t j, nameLen = strlen(f->Name);
- const char *destPath;
- if (nameLen + 1 > tempSize)
- {
- SzFree(NULL, temp);
- tempSize = nameLen + 1;
- temp = (char *)SzAlloc(NULL, tempSize);
- if (temp == 0)
- {
- res = SZ_ERROR_MEM;
- break;
- }
- }
- destPath = temp;
- strcpy(temp, f->Name);
- for (j = 0; j < nameLen; j++)
- if (temp[j] == '/')
+ size_t j;
+ UInt16 *name = (UInt16 *)temp;
+ const UInt16 *destPath = (const UInt16 *)name;
+ for (j = 0; name[j] != 0; j++)
+ if (name[j] == '/')
{
if (fullPaths)
{
- temp[j] = 0;
- MyCreateDir(temp);
- temp[j] = CHAR_PATH_SEPARATOR;
+ name[j] = 0;
+ MyCreateDir(name);
+ name[j] = CHAR_PATH_SEPARATOR;
}
else
- destPath = temp + j + 1;
+ destPath = name + j + 1;
}
if (f->IsDir)
@@ -272,15 +418,14 @@ int MY_CDECL main(int numargs, char *args[])
printf("\n");
continue;
}
- else if (OutFile_Open(&outFile, destPath))
+ else if (OutFile_OpenUtf16(&outFile, destPath))
{
PrintError("can not open output file");
res = SZ_ERROR_FAIL;
break;
}
processedSize = outSizeProcessed;
- if (File_Write(&outFile, outBuffer + offset, &processedSize) != 0 ||
- processedSize != outSizeProcessed)
+ if (File_Write(&outFile, outBuffer + offset, &processedSize) != 0 || processedSize != outSizeProcessed)
{
PrintError("can not write output file");
res = SZ_ERROR_FAIL;
@@ -297,11 +442,6 @@ int MY_CDECL main(int numargs, char *args[])
}
IAlloc_Free(&allocImp, outBuffer);
}
- else
- {
- PrintError("incorrect command");
- res = SZ_ERROR_FAIL;
- }
}
SzArEx_Free(&db, &allocImp);
SzFree(NULL, temp);
diff --git a/C/Archive/7z/makefile b/C/Util/7z/makefile
index cf06c860..fc814dc9 100755
--- a/C/Archive/7z/makefile
+++ b/C/Util/7z/makefile
@@ -6,20 +6,17 @@ C_OBJS = \
$O\7zBuf.obj \
$O\7zBuf2.obj \
$O\7zCrc.obj \
- $O\LzmaDec.obj \
- $O\Lzma2Dec.obj \
- $O\Bra86.obj \
- $O\Bcj2.obj \
$O\7zFile.obj \
+ $O\7zDec.obj \
+ $O\7zIn.obj \
$O\7zStream.obj \
+ $O\Bcj2.obj \
+ $O\Bra86.obj \
+ $O\Lzma2Dec.obj \
+ $O\LzmaDec.obj \
7Z_OBJS = \
$O\7zAlloc.obj \
- $O\7zDecode.obj \
- $O\7zExtract.obj \
- $O\7zHeader.obj \
- $O\7zIn.obj \
- $O\7zItem.obj \
$O\7zMain.obj \
OBJS = \
diff --git a/C/Archive/7z/makefile.gcc b/C/Util/7z/makefile.gcc
index 29d2aa02..25c0e69b 100755
--- a/C/Archive/7z/makefile.gcc
+++ b/C/Util/7z/makefile.gcc
@@ -4,7 +4,7 @@ LIB =
RM = rm -f
CFLAGS = -c -O2 -Wall
-OBJS = 7zAlloc.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zDecode.o 7zExtract.o 7zHeader.o 7zIn.o 7zItem.o 7zMain.o LzmaDec.o Lzma2Dec.o Bra86.o Bcj2.o 7zFile.o 7zStream.o
+OBJS = 7zAlloc.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zDec.o 7zIn.o 7zMain.o LzmaDec.o Lzma2Dec.o Bra86.o Bcj2.o 7zFile.o 7zStream.o
all: $(PROG)
@@ -23,20 +23,11 @@ $(PROG): $(OBJS)
7zCrc.o: ../../7zCrc.c
$(CXX) $(CFLAGS) ../../7zCrc.c
-7zDecode.o: 7zDecode.c
- $(CXX) $(CFLAGS) 7zDecode.c
+7zDec.o: ../../7zDec.c
+ $(CXX) $(CFLAGS) ../../7zDec.c
-7zExtract.o: 7zExtract.c
- $(CXX) $(CFLAGS) 7zExtract.c
-
-7zHeader.o: 7zHeader.c
- $(CXX) $(CFLAGS) 7zHeader.c
-
-7zIn.o: 7zIn.c
- $(CXX) $(CFLAGS) 7zIn.c
-
-7zItem.o: 7zItem.c
- $(CXX) $(CFLAGS) 7zItem.c
+7zIn.o: ../../7zIn.c
+ $(CXX) $(CFLAGS) ../../7zIn.c
7zMain.o: 7zMain.c
$(CXX) $(CFLAGS) 7zMain.c
diff --git a/C/LzmaUtil/LzmaUtil.c b/C/Util/Lzma/LzmaUtil.c
index 016d7b04..0d0e3ee7 100755
--- a/C/LzmaUtil/LzmaUtil.c
+++ b/C/Util/Lzma/LzmaUtil.c
@@ -1,5 +1,5 @@
/* LzmaUtil.c -- Test application for LZMA compression
-2008-11-23 : Igor Pavlov : Public domain */
+2009-08-14 : Igor Pavlov : Public domain */
#define _CRT_SECURE_NO_WARNINGS
@@ -7,11 +7,11 @@
#include <stdlib.h>
#include <string.h>
-#include "../Alloc.h"
-#include "../7zFile.h"
-#include "../7zVersion.h"
-#include "../LzmaDec.h"
-#include "../LzmaEnc.h"
+#include "../../Alloc.h"
+#include "../../7zFile.h"
+#include "../../7zVersion.h"
+#include "../../LzmaDec.h"
+#include "../../LzmaEnc.h"
const char *kCantReadMessage = "Can not read input file";
const char *kCantWriteMessage = "Can not write output file";
diff --git a/C/LzmaUtil/LzmaUtil.dsp b/C/Util/Lzma/LzmaUtil.dsp
index faac2e6e..d10af8b4 100755
--- a/C/LzmaUtil/LzmaUtil.dsp
+++ b/C/Util/Lzma/LzmaUtil.dsp
@@ -51,7 +51,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\util\lzmac.exe"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\util\7lzma.exe"
!ELSEIF "$(CFG)" == "LzmaUtil - Win32 Debug"
@@ -76,7 +76,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\util\lzmac.exe" /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\util\7lzma.exe" /pdbtype:sept
!ENDIF
@@ -86,67 +86,67 @@ LINK32=link.exe
# Name "LzmaUtil - Win32 Debug"
# Begin Source File
-SOURCE=..\7zFile.c
+SOURCE=..\..\7zFile.c
# End Source File
# Begin Source File
-SOURCE=..\7zFile.h
+SOURCE=..\..\7zFile.h
# End Source File
# Begin Source File
-SOURCE=..\7zStream.c
+SOURCE=..\..\7zStream.c
# End Source File
# Begin Source File
-SOURCE=..\7zVersion.h
+SOURCE=..\..\7zVersion.h
# End Source File
# Begin Source File
-SOURCE=..\Alloc.c
+SOURCE=..\..\Alloc.c
# End Source File
# Begin Source File
-SOURCE=..\Alloc.h
+SOURCE=..\..\Alloc.h
# End Source File
# Begin Source File
-SOURCE=..\CpuArch.h
+SOURCE=..\..\CpuArch.h
# End Source File
# Begin Source File
-SOURCE=..\LzFind.c
+SOURCE=..\..\LzFind.c
# End Source File
# Begin Source File
-SOURCE=..\LzFind.h
+SOURCE=..\..\LzFind.h
# End Source File
# Begin Source File
-SOURCE=..\LzFindMt.c
+SOURCE=..\..\LzFindMt.c
# End Source File
# Begin Source File
-SOURCE=..\LzFindMt.h
+SOURCE=..\..\LzFindMt.h
# End Source File
# Begin Source File
-SOURCE=..\LzHash.h
+SOURCE=..\..\LzHash.h
# End Source File
# Begin Source File
-SOURCE=..\LzmaDec.c
+SOURCE=..\..\LzmaDec.c
# End Source File
# Begin Source File
-SOURCE=..\LzmaDec.h
+SOURCE=..\..\LzmaDec.h
# End Source File
# Begin Source File
-SOURCE=..\LzmaEnc.c
+SOURCE=..\..\LzmaEnc.c
# End Source File
# Begin Source File
-SOURCE=..\LzmaEnc.h
+SOURCE=..\..\LzmaEnc.h
# End Source File
# Begin Source File
@@ -154,15 +154,15 @@ SOURCE=.\LzmaUtil.c
# End Source File
# Begin Source File
-SOURCE=..\Threads.c
+SOURCE=..\..\Threads.c
# End Source File
# Begin Source File
-SOURCE=..\Threads.h
+SOURCE=..\..\Threads.h
# End Source File
# Begin Source File
-SOURCE=..\Types.h
+SOURCE=..\..\Types.h
# End Source File
# End Target
# End Project
diff --git a/C/LzmaUtil/LzmaUtil.dsw b/C/Util/Lzma/LzmaUtil.dsw
index c52eaf6d..c52eaf6d 100755
--- a/C/LzmaUtil/LzmaUtil.dsw
+++ b/C/Util/Lzma/LzmaUtil.dsw
diff --git a/C/LzmaUtil/makefile b/C/Util/Lzma/makefile
index fbb98b84..bd55f826 100755
--- a/C/LzmaUtil/makefile
+++ b/C/Util/Lzma/makefile
@@ -21,9 +21,9 @@ OBJS = \
$(LIB_OBJS) \
$(C_OBJS) \
-!include "../../CPP/Build.mak"
+!include "../../../CPP/Build.mak"
$(LIB_OBJS): $(*B).c
$(COMPL_O2)
-$(C_OBJS): ../$(*B).c
+$(C_OBJS): ../../$(*B).c
$(COMPL_O2)
diff --git a/C/Util/Lzma/makefile.gcc b/C/Util/Lzma/makefile.gcc
new file mode 100755
index 00000000..9b0c5b7f
--- /dev/null
+++ b/C/Util/Lzma/makefile.gcc
@@ -0,0 +1,44 @@
+PROG = lzma
+CXX = g++
+LIB =
+RM = rm -f
+CFLAGS = -c -O2 -Wall
+
+OBJS = \
+ LzmaUtil.o \
+ Alloc.o \
+ LzFind.o \
+ LzmaDec.o \
+ LzmaEnc.o \
+ 7zFile.o \
+ 7zStream.o \
+
+
+all: $(PROG)
+
+$(PROG): $(OBJS)
+ $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB) $(LIB2)
+
+LzmaUtil.o: LzmaUtil.c
+ $(CXX) $(CFLAGS) LzmaUtil.c
+
+Alloc.o: ../../Alloc.c
+ $(CXX) $(CFLAGS) ../../Alloc.c
+
+LzFind.o: ../../LzFind.c
+ $(CXX) $(CFLAGS) ../../LzFind.c
+
+LzmaDec.o: ../../LzmaDec.c
+ $(CXX) $(CFLAGS) ../../LzmaDec.c
+
+LzmaEnc.o: ../../LzmaEnc.c
+ $(CXX) $(CFLAGS) ../../LzmaEnc.c
+
+7zFile.o: ../../7zFile.c
+ $(CXX) $(CFLAGS) ../../7zFile.c
+
+7zStream.o: ../../7zStream.c
+ $(CXX) $(CFLAGS) ../../7zStream.c
+
+clean:
+ -$(RM) $(PROG) $(OBJS)
diff --git a/C/LzmaLib/LzmaLib.def b/C/Util/LzmaLib/LzmaLib.def
index 8bc6add9..8bc6add9 100755
--- a/C/LzmaLib/LzmaLib.def
+++ b/C/Util/LzmaLib/LzmaLib.def
diff --git a/C/LzmaLib/LzmaLib.dsp b/C/Util/LzmaLib/LzmaLib.dsp
index 3ba6d254..163f6cd8 100755
--- a/C/LzmaLib/LzmaLib.dsp
+++ b/C/Util/LzmaLib/LzmaLib.dsp
@@ -104,59 +104,59 @@ SOURCE=.\LzmaLibExports.c
# End Group
# Begin Source File
-SOURCE=..\Alloc.c
+SOURCE=..\..\Alloc.c
# End Source File
# Begin Source File
-SOURCE=..\Alloc.h
+SOURCE=..\..\Alloc.h
# End Source File
# Begin Source File
-SOURCE=..\IStream.h
+SOURCE=..\..\IStream.h
# End Source File
# Begin Source File
-SOURCE=..\LzFind.c
+SOURCE=..\..\LzFind.c
# End Source File
# Begin Source File
-SOURCE=..\LzFind.h
+SOURCE=..\..\LzFind.h
# End Source File
# Begin Source File
-SOURCE=..\LzFindMt.c
+SOURCE=..\..\LzFindMt.c
# End Source File
# Begin Source File
-SOURCE=..\LzFindMt.h
+SOURCE=..\..\LzFindMt.h
# End Source File
# Begin Source File
-SOURCE=..\LzHash.h
+SOURCE=..\..\LzHash.h
# End Source File
# Begin Source File
-SOURCE=..\LzmaDec.c
+SOURCE=..\..\LzmaDec.c
# End Source File
# Begin Source File
-SOURCE=..\LzmaDec.h
+SOURCE=..\..\LzmaDec.h
# End Source File
# Begin Source File
-SOURCE=..\LzmaEnc.c
+SOURCE=..\..\LzmaEnc.c
# End Source File
# Begin Source File
-SOURCE=..\LzmaEnc.h
+SOURCE=..\..\LzmaEnc.h
# End Source File
# Begin Source File
-SOURCE=..\LzmaLib.c
+SOURCE=..\..\LzmaLib.c
# End Source File
# Begin Source File
-SOURCE=..\LzmaLib.h
+SOURCE=..\..\LzmaLib.h
# End Source File
# Begin Source File
@@ -164,15 +164,15 @@ SOURCE=.\resource.rc
# End Source File
# Begin Source File
-SOURCE=..\Threads.c
+SOURCE=..\..\Threads.c
# End Source File
# Begin Source File
-SOURCE=..\Threads.h
+SOURCE=..\..\Threads.h
# End Source File
# Begin Source File
-SOURCE=..\Types.h
+SOURCE=..\..\Types.h
# End Source File
# End Target
# End Project
diff --git a/C/LzmaLib/LzmaLib.dsw b/C/Util/LzmaLib/LzmaLib.dsw
index 6faf3336..6faf3336 100755
--- a/C/LzmaLib/LzmaLib.dsw
+++ b/C/Util/LzmaLib/LzmaLib.dsw
diff --git a/C/LzmaLib/LzmaLibExports.c b/C/Util/LzmaLib/LzmaLibExports.c
index 845545db..845545db 100755
--- a/C/LzmaLib/LzmaLibExports.c
+++ b/C/Util/LzmaLib/LzmaLibExports.c
diff --git a/C/LzmaLib/makefile b/C/Util/LzmaLib/makefile
index 1e6b40cc..038bc15c 100755
--- a/C/LzmaLib/makefile
+++ b/C/Util/LzmaLib/makefile
@@ -7,8 +7,6 @@ DEF_FILE = LzmaLib.def
CFLAGS = $(CFLAGS) \
-DCOMPRESS_MF_MT \
-LIBS = $(LIBS) oleaut32.lib
-
LIB_OBJS = \
$O\LzmaLibExports.obj \
@@ -26,12 +24,12 @@ OBJS = \
$(C_OBJS) \
$O\resource.res
-!include "../../CPP/Build.mak"
+!include "../../../CPP/Build.mak"
$(SLIBPATH): $O $(OBJS)
lib -out:$(SLIBPATH) $(OBJS) $(LIBS)
$(LIB_OBJS): $(*B).c
$(COMPL_O2)
-$(C_OBJS): ../$(*B).c
+$(C_OBJS): ../../$(*B).c
$(COMPL_O2)
diff --git a/C/LzmaLib/resource.rc b/C/Util/LzmaLib/resource.rc
index 1e489161..864b5287 100755
--- a/C/LzmaLib/resource.rc
+++ b/C/Util/LzmaLib/resource.rc
@@ -1,4 +1,4 @@
-#include "../../CPP/7zip/MyVersionInfo.rc"
+#include "../../../CPP/7zip/MyVersionInfo.rc"
MY_VERSION_INFO_DLL("LZMA library", "LZMA")
diff --git a/C/XzDec.c b/C/XzDec.c
index 8ae234d0..40261b2f 100755
--- a/C/XzDec.c
+++ b/C/XzDec.c
@@ -1,5 +1,5 @@
/* XzDec.c -- Xz Decode
-2009-05-29 : Igor Pavlov : Public domain */
+2009-06-08 : Igor Pavlov : Public domain */
/* #define XZ_DUMP */
@@ -291,9 +291,10 @@ static void Lzma2State_Init(void *pp)
}
static SRes Lzma2State_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
- int srcWasFinished, ELzmaFinishMode finishMode, int *wasFinished)
+ int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished)
{
ELzmaStatus status;
+ /* ELzmaFinishMode fm = (finishMode == LZMA_FINISH_ANY) ? LZMA_FINISH_ANY : LZMA_FINISH_END; */
SRes res = Lzma2Dec_DecodeToBuf((CLzma2Dec *)pp, dest, destLen, src, srcLen, finishMode, &status);
srcWasFinished = srcWasFinished;
*wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK);
@@ -373,7 +374,7 @@ SRes MixCoder_SetFromMethod(CMixCoder *p, int coderIndex, UInt64 methodId)
SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
const Byte *src, SizeT *srcLen, int srcWasFinished,
- ELzmaFinishMode finishMode, ECoderStatus *status)
+ ECoderFinishMode finishMode, ECoderStatus *status)
{
SizeT destLenOrig = *destLen;
SizeT srcLenOrig = *srcLen;
diff --git a/C/XzEnc.c b/C/XzEnc.c
index 3958308b..721b4e76 100755
--- a/C/XzEnc.c
+++ b/C/XzEnc.c
@@ -1,5 +1,5 @@
/* XzEnc.c -- Xz Encode
-2009-05-26 : Igor Pavlov : Public domain */
+2009-06-04 : Igor Pavlov : Public domain */
#include <stdlib.h>
#include <string.h>
@@ -442,7 +442,7 @@ static SRes Xz_Compress(CXzStream *xz,
{
UInt64 packPos = seqSizeOutStream.processed;
- HRESULT res = Lzma2Enc_Encode(lzmaf->lzma2, &seqSizeOutStream.p,
+ SRes res = Lzma2Enc_Encode(lzmaf->lzma2, &seqSizeOutStream.p,
#ifdef USE_SUBBLOCK
useSubblock ? &lzmaf->sb.p:
#endif
diff --git a/C/XzIn.c b/C/XzIn.c
index f8c76bfe..7f0f6af8 100755
--- a/C/XzIn.c
+++ b/C/XzIn.c
@@ -1,10 +1,11 @@
/* XzIn.c - Xz input
-2009-04-15 : Igor Pavlov : Public domain */
+2009-06-19 : Igor Pavlov : Public domain */
-#include "Xz.h"
+#include <string.h>
#include "7zCrc.h"
#include "CpuArch.h"
+#include "Xz.h"
SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream)
{