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>2007-04-17 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:50 +0300
commita145bfc7cf17f7bbcfae8f0064333c8ea75b455c (patch)
tree4ea458c9f35956fe080562989a702ea8c9af4b90 /C
parentd9666cf046a8453b33b3e2fbf4d82295a9f87df3 (diff)
4.45 beta
Diffstat (limited to 'C')
-rwxr-xr-xC/7zCrc.c123
-rwxr-xr-xC/7zCrc.h24
-rwxr-xr-xC/7zCrcT8.c40
-rwxr-xr-xC/Alloc.c120
-rwxr-xr-xC/Alloc.h29
-rwxr-xr-xC/Archive/7z/7zAlloc.h20
-rwxr-xr-xC/Archive/7z/7zBuffer.h19
-rwxr-xr-xC/Archive/7z/7zDecode.h21
-rwxr-xr-xC/Archive/7z/7zExtract.c4
-rwxr-xr-xC/Archive/7z/7zExtract.h40
-rwxr-xr-xC/Archive/7z/7zHeader.h55
-rwxr-xr-xC/Archive/7z/7zIn.c27
-rwxr-xr-xC/Archive/7z/7zIn.h55
-rwxr-xr-xC/Archive/7z/7zItem.h90
-rwxr-xr-xC/Archive/7z/7zMain.c8
-rwxr-xr-xC/Archive/7z/7zMethodID.h18
-rwxr-xr-xC/Archive/7z/7z_C.dsp12
-rwxr-xr-xC/Archive/7z/makefile13
-rwxr-xr-xC/Archive/7z/makefile.gcc8
-rwxr-xr-xC/Compress/Branch/BranchARM.c2
-rwxr-xr-xC/Compress/Branch/BranchARMThumb.c2
-rwxr-xr-xC/Compress/Branch/BranchIA64.c29
-rwxr-xr-xC/Compress/Branch/BranchSPARC.c2
-rwxr-xr-xC/Compress/Branch/BranchSPARC.h2
-rwxr-xr-xC/Compress/Branch/BranchTypes.h13
-rwxr-xr-xC/Compress/Lz/MatchFinderMt.c4
-rwxr-xr-xC/Compress/Lz/MatchFinderMt.h2
-rwxr-xr-xC/Types.h20
28 files changed, 612 insertions, 190 deletions
diff --git a/C/7zCrc.c b/C/7zCrc.c
index 136ac2e0..61050dd4 100755
--- a/C/7zCrc.c
+++ b/C/7zCrc.c
@@ -3,12 +3,9 @@
#include "7zCrc.h"
#define kCrcPoly 0xEDB88320
+UInt32 g_CrcTable[256];
-UInt32 g_CrcTable[256]
-
-#ifdef CRC_GENERATE_TABLE
-;
-void CrcGenerateTable()
+void MY_FAST_CALL CrcGenerateTable()
{
UInt32 i;
for (i = 0; i < 256; i++)
@@ -16,122 +13,20 @@ void CrcGenerateTable()
UInt32 r = i;
int j;
for (j = 0; j < 8; j++)
- if (r & 1)
- r = (r >> 1) ^ kCrcPoly;
- else
- r >>= 1;
+ r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
g_CrcTable[i] = r;
}
}
-#else
-
-= {
- 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
- 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
- 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
- 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
- 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
- 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
- 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
- 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
- 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
- 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
- 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
- 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
- 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
- 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
- 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
- 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
- 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
- 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
- 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
- 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
- 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
- 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
- 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
- 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
- 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
- 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
- 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
- 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
- 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
- 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
- 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
- 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
- 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
- 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
- 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
- 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
- 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
- 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
- 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
- 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
- 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
- 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
- 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
- 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
- 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
- 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
- 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
- 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
- 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
- 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
- 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
- 0x2d02ef8dL
-};
-
-#endif
-
-void CrcInit(UInt32 *crc) { *crc = 0xFFFFFFFF; }
-UInt32 CrcGetDigest(UInt32 *crc) { return *crc ^ 0xFFFFFFFF; }
-
-void CrcUpdateByte(UInt32 *crc, Byte b)
-{
- *crc = g_CrcTable[((Byte)(*crc)) ^ b] ^ (*crc >> 8);
-}
-
-void CrcUpdateUInt16(UInt32 *crc, UInt16 v)
-{
- CrcUpdateByte(crc, (Byte)v);
- CrcUpdateByte(crc, (Byte)(v >> 8));
-}
-
-void CrcUpdateUInt32(UInt32 *crc, UInt32 v)
-{
- int i;
- for (i = 0; i < 4; i++)
- CrcUpdateByte(crc, (Byte)(v >> (8 * i)));
-}
-
-void CrcUpdateUInt64(UInt32 *crc, UInt64 v)
-{
- int i;
- for (i = 0; i < 8; i++)
- {
- CrcUpdateByte(crc, (Byte)(v));
- v >>= 8;
- }
-}
-
-void CrcUpdate(UInt32 *crc, const void *data, size_t size)
+UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
{
- UInt32 v = *crc;
const Byte *p = (const Byte *)data;
- for (; size > 0 ; size--, p++)
- v = g_CrcTable[((Byte)(v)) ^ *p] ^ (v >> 8);
- *crc = v;
-}
-
-UInt32 CrcCalculateDigest(const void *data, size_t size)
-{
- UInt32 crc;
- CrcInit(&crc);
- CrcUpdate(&crc, data, size);
- return CrcGetDigest(&crc);
+ for (; size > 0 ; size--, p++)
+ v = CRC_UPDATE_BYTE(v, *p);
+ return v;
}
-int CrcVerifyDigest(UInt32 digest, const void *data, size_t size)
+UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
{
- return (CrcCalculateDigest(data, size) == digest);
+ return CrcUpdate(CRC_INIT_VAL, data, size) ^ 0xFFFFFFFF;
}
diff --git a/C/7zCrc.h b/C/7zCrc.h
index 370b2a0f..bb3d481f 100755
--- a/C/7zCrc.h
+++ b/C/7zCrc.h
@@ -7,25 +7,15 @@
#include "Types.h"
-extern UInt32 g_CrcTable[256];
+extern UInt32 g_CrcTable[];
-// #define CRC_GENERATE_TABLE
+void MY_FAST_CALL CrcGenerateTable();
-#ifdef CRC_GENERATE_TABLE
-void CrcGenerateTable();
-#else
-#define CrcGenerateTable()
-#endif
+#define CRC_INIT_VAL 0xFFFFFFFF
+#define CRC_GET_DIGEST(crc) ((crc) ^ 0xFFFFFFFF)
+#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
-void CrcInit(UInt32 *crc);
-UInt32 CrcGetDigest(UInt32 *crc);
-void CrcUpdateByte(UInt32 *crc, Byte v);
-void CrcUpdateUInt16(UInt32 *crc, UInt16 v);
-void CrcUpdateUInt32(UInt32 *crc, UInt32 v);
-void CrcUpdateUInt64(UInt32 *crc, UInt64 v);
-void CrcUpdate(UInt32 *crc, const void *data, size_t size);
-
-UInt32 CrcCalculateDigest(const void *data, size_t size);
-int CrcVerifyDigest(UInt32 digest, const void *data, size_t size);
+UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size);
+UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size);
#endif
diff --git a/C/7zCrcT8.c b/C/7zCrcT8.c
new file mode 100755
index 00000000..0619e21c
--- /dev/null
+++ b/C/7zCrcT8.c
@@ -0,0 +1,40 @@
+/* 7zCrc.c */
+
+#include "7zCrc.h"
+
+#define kCrcPoly 0xEDB88320
+#define CRC_NUM_TABLES 8
+
+UInt32 g_CrcTable[256 * CRC_NUM_TABLES];
+
+void MY_FAST_CALL CrcGenerateTable()
+{
+ UInt32 i;
+ for (i = 0; i < 256; i++)
+ {
+ UInt32 r = i;
+ int j;
+ for (j = 0; j < 8; j++)
+ r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
+ g_CrcTable[i] = r;
+ }
+ #if CRC_NUM_TABLES > 1
+ for (; i < 256 * CRC_NUM_TABLES; i++)
+ {
+ UInt32 r = g_CrcTable[i - 256];
+ g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
+ }
+ #endif
+}
+
+UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table);
+
+UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
+{
+ return CrcUpdateT8(v, data, size, g_CrcTable);
+}
+
+UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
+{
+ return CrcUpdateT8(CRC_INIT_VAL, data, size, g_CrcTable) ^ 0xFFFFFFFF;
+}
diff --git a/C/Alloc.c b/C/Alloc.c
new file mode 100755
index 00000000..7046bcf4
--- /dev/null
+++ b/C/Alloc.c
@@ -0,0 +1,120 @@
+// Common/Alloc.c
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+#include <stdlib.h>
+
+#include "Alloc.h"
+
+// #define _SZ_ALLOC_DEBUG
+
+/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
+#ifdef _SZ_ALLOC_DEBUG
+#include <stdio.h>
+int g_allocCount = 0;
+int g_allocCountMid = 0;
+int g_allocCountBig = 0;
+#endif
+
+void *MyAlloc(size_t size)
+{
+ if (size == 0)
+ return 0;
+ #ifdef _SZ_ALLOC_DEBUG
+ fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount++);
+ #endif
+ return malloc(size);
+}
+
+void MyFree(void *address)
+{
+ #ifdef _SZ_ALLOC_DEBUG
+ if (address != 0)
+ fprintf(stderr, "\nFree; count = %10d", --g_allocCount);
+ #endif
+ free(address);
+}
+
+#ifdef _WIN32
+
+void *MidAlloc(size_t size)
+{
+ if (size == 0)
+ return 0;
+ #ifdef _SZ_ALLOC_DEBUG
+ fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++);
+ #endif
+ return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
+}
+
+void MidFree(void *address)
+{
+ #ifdef _SZ_ALLOC_DEBUG
+ if (address != 0)
+ fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);
+ #endif
+ if (address == 0)
+ return;
+ VirtualFree(address, 0, MEM_RELEASE);
+}
+
+#ifndef MEM_LARGE_PAGES
+wedeed
+#undef _7ZIP_LARGE_PAGES
+#endif
+
+#ifdef _7ZIP_LARGE_PAGES
+SIZE_T g_LargePageSize = 0;
+typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
+#endif
+
+void SetLargePageSize()
+{
+ #ifdef _7ZIP_LARGE_PAGES
+ SIZE_T size = 0;
+ GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
+ GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
+ if (largePageMinimum == 0)
+ return;
+ size = largePageMinimum();
+ if (size == 0 || (size & (size - 1)) != 0)
+ return;
+ g_LargePageSize = size;
+ #endif
+}
+
+
+void *BigAlloc(size_t size)
+{
+ if (size == 0)
+ return 0;
+ #ifdef _SZ_ALLOC_DEBUG
+ fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
+ #endif
+
+ #ifdef _7ZIP_LARGE_PAGES
+ if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18))
+ {
+ void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
+ MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
+ if (res != 0)
+ return res;
+ }
+ #endif
+ return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
+}
+
+void BigFree(void *address)
+{
+ #ifdef _SZ_ALLOC_DEBUG
+ if (address != 0)
+ fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
+ #endif
+
+ if (address == 0)
+ return;
+ VirtualFree(address, 0, MEM_RELEASE);
+}
+
+#endif
diff --git a/C/Alloc.h b/C/Alloc.h
new file mode 100755
index 00000000..ab0b9234
--- /dev/null
+++ b/C/Alloc.h
@@ -0,0 +1,29 @@
+// Common/Alloc.h
+
+#ifndef __COMMON_ALLOC_H
+#define __COMMON_ALLOC_H
+
+#include <stddef.h>
+
+void *MyAlloc(size_t size);
+void MyFree(void *address);
+
+#ifdef _WIN32
+
+void SetLargePageSize();
+
+void *MidAlloc(size_t size);
+void MidFree(void *address);
+void *BigAlloc(size_t size);
+void BigFree(void *address);
+
+#else
+
+#define MidAlloc(size) MyAlloc(size)
+#define MidFree(address) MyFree(address)
+#define BigAlloc(size) MyAlloc(size)
+#define BigFree(address) MyFree(address)
+
+#endif
+
+#endif
diff --git a/C/Archive/7z/7zAlloc.h b/C/Archive/7z/7zAlloc.h
new file mode 100755
index 00000000..4ca4170c
--- /dev/null
+++ b/C/Archive/7z/7zAlloc.h
@@ -0,0 +1,20 @@
+/* 7zAlloc.h */
+
+#ifndef __7Z_ALLOC_H
+#define __7Z_ALLOC_H
+
+#include <stddef.h>
+
+typedef struct _ISzAlloc
+{
+ void *(*Alloc)(size_t size);
+ void (*Free)(void *address); /* address can be 0 */
+} ISzAlloc;
+
+void *SzAlloc(size_t size);
+void SzFree(void *address);
+
+void *SzAllocTemp(size_t size);
+void SzFreeTemp(void *address);
+
+#endif
diff --git a/C/Archive/7z/7zBuffer.h b/C/Archive/7z/7zBuffer.h
new file mode 100755
index 00000000..05c6d748
--- /dev/null
+++ b/C/Archive/7z/7zBuffer.h
@@ -0,0 +1,19 @@
+/* 7zBuffer.h */
+
+#ifndef __7Z_BUFFER_H
+#define __7Z_BUFFER_H
+
+#include <stddef.h>
+#include "../../Types.h"
+
+typedef struct _CSzByteBuffer
+{
+ size_t Capacity;
+ Byte *Items;
+}CSzByteBuffer;
+
+void SzByteBufferInit(CSzByteBuffer *buffer);
+int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size));
+void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *));
+
+#endif
diff --git a/C/Archive/7z/7zDecode.h b/C/Archive/7z/7zDecode.h
new file mode 100755
index 00000000..74bb180f
--- /dev/null
+++ b/C/Archive/7z/7zDecode.h
@@ -0,0 +1,21 @@
+/* 7zDecode.h */
+
+#ifndef __7Z_DECODE_H
+#define __7Z_DECODE_H
+
+#include "7zItem.h"
+#include "7zAlloc.h"
+#ifdef _LZMA_IN_CB
+#include "7zIn.h"
+#endif
+
+SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder,
+ #ifdef _LZMA_IN_CB
+ ISzInStream *stream,
+ #else
+ const Byte *inBuffer,
+ #endif
+ Byte *outBuffer, size_t outSize,
+ size_t *outSizeProcessed, ISzAlloc *allocMain);
+
+#endif
diff --git a/C/Archive/7z/7zExtract.c b/C/Archive/7z/7zExtract.c
index 748591a5..75733fd1 100755
--- a/C/Archive/7z/7zExtract.c
+++ b/C/Archive/7z/7zExtract.c
@@ -83,7 +83,7 @@ SZ_RESULT SzExtract(
{
if (folder->UnPackCRCDefined)
{
- if (!CrcVerifyDigest(folder->UnPackCRC, *outBuffer, (size_t)unPackSize))
+ if (CrcCalc(*outBuffer, (size_t)unPackSize) != folder->UnPackCRC)
res = SZE_FAIL;
}
}
@@ -109,7 +109,7 @@ SZ_RESULT SzExtract(
{
if (fileItem->IsFileCRCDefined)
{
- if (!CrcVerifyDigest(fileItem->FileCRC, *outBuffer + *offset, *outSizeProcessed))
+ if (CrcCalc(*outBuffer + *offset, *outSizeProcessed) != fileItem->FileCRC)
res = SZE_FAIL;
}
}
diff --git a/C/Archive/7z/7zExtract.h b/C/Archive/7z/7zExtract.h
new file mode 100755
index 00000000..e9a4fb4e
--- /dev/null
+++ b/C/Archive/7z/7zExtract.h
@@ -0,0 +1,40 @@
+/* 7zExtract.h */
+
+#ifndef __7Z_EXTRACT_H
+#define __7Z_EXTRACT_H
+
+#include "7zIn.h"
+
+/*
+ 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.
+*/
+
+SZ_RESULT SzExtract(
+ ISzInStream *inStream,
+ CArchiveDatabaseEx *db,
+ 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);
+
+#endif
diff --git a/C/Archive/7z/7zHeader.h b/C/Archive/7z/7zHeader.h
new file mode 100755
index 00000000..3e67cf57
--- /dev/null
+++ b/C/Archive/7z/7zHeader.h
@@ -0,0 +1,55 @@
+/* 7zHeader.h */
+
+#ifndef __7Z_HEADER_H
+#define __7Z_HEADER_H
+
+#include "../../Types.h"
+
+#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,
+ k7zIdCreationTime,
+ k7zIdLastAccessTime,
+ k7zIdLastWriteTime,
+ k7zIdWinAttributes,
+ k7zIdComment,
+
+ k7zIdEncodedHeader,
+
+ k7zIdStartPos
+};
+
+#endif
diff --git a/C/Archive/7z/7zIn.c b/C/Archive/7z/7zIn.c
index 8f3d7cae..04e83a8e 100755
--- a/C/Archive/7z/7zIn.c
+++ b/C/Archive/7z/7zIn.c
@@ -208,7 +208,7 @@ SZ_RESULT SafeReadDirectByte(ISzInStream *inStream, Byte *data)
return SafeReadDirect(inStream, data, 1);
}
-SZ_RESULT SafeReadDirectUInt32(ISzInStream *inStream, UInt32 *value)
+SZ_RESULT SafeReadDirectUInt32(ISzInStream *inStream, UInt32 *value, UInt32 *crc)
{
int i;
*value = 0;
@@ -217,11 +217,12 @@ SZ_RESULT SafeReadDirectUInt32(ISzInStream *inStream, UInt32 *value)
Byte b;
RINOK(SafeReadDirectByte(inStream, &b));
*value |= ((UInt32)b << (8 * i));
+ *crc = CRC_UPDATE_BYTE(*crc, b);
}
return SZ_OK;
}
-SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream, UInt64 *value)
+SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream, UInt64 *value, UInt32 *crc)
{
int i;
*value = 0;
@@ -230,6 +231,7 @@ SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream, UInt64 *value)
Byte b;
RINOK(SafeReadDirectByte(inStream, &b));
*value |= ((UInt64)b << (8 * i));
+ *crc = CRC_UPDATE_BYTE(*crc, b);
}
return SZ_OK;
}
@@ -1133,7 +1135,7 @@ SZ_RESULT SzReadAndDecodePackedStreams2(
if (outRealSize != (UInt32)unPackSize)
return SZE_FAIL;
if (folder->UnPackCRCDefined)
- if (!CrcVerifyDigest(folder->UnPackCRC, outBuffer->Items, (size_t)unPackSize))
+ if (CrcCalc(outBuffer->Items, (size_t)unPackSize) != folder->UnPackCRC)
return SZE_FAIL;
return SZ_OK;
}
@@ -1182,7 +1184,7 @@ SZ_RESULT SzArchiveOpen2(
UInt64 nextHeaderOffset;
UInt64 nextHeaderSize;
UInt32 nextHeaderCRC;
- UInt32 crc;
+ UInt32 crc = 0;
CFileSize pos = 0;
CSzByteBuffer buffer;
CSzData sd;
@@ -1202,20 +1204,17 @@ SZ_RESULT SzArchiveOpen2(
return SZE_ARCHIVE_ERROR;
RINOK(SafeReadDirectByte(inStream, &version));
- RINOK(SafeReadDirectUInt32(inStream, &crcFromArchive));
+ RINOK(SafeReadDirectUInt32(inStream, &crcFromArchive, &crc));
- CrcInit(&crc);
- RINOK(SafeReadDirectUInt64(inStream, &nextHeaderOffset));
- CrcUpdateUInt64(&crc, nextHeaderOffset);
- RINOK(SafeReadDirectUInt64(inStream, &nextHeaderSize));
- CrcUpdateUInt64(&crc, nextHeaderSize);
- RINOK(SafeReadDirectUInt32(inStream, &nextHeaderCRC));
- CrcUpdateUInt32(&crc, nextHeaderCRC);
+ crc = CRC_INIT_VAL;
+ RINOK(SafeReadDirectUInt64(inStream, &nextHeaderOffset, &crc));
+ RINOK(SafeReadDirectUInt64(inStream, &nextHeaderSize, &crc));
+ RINOK(SafeReadDirectUInt32(inStream, &nextHeaderCRC, &crc));
pos = k7zStartHeaderSize;
db->ArchiveInfo.StartPositionAfterHeader = pos;
- if (CrcGetDigest(&crc) != crcFromArchive)
+ if (CRC_GET_DIGEST(crc) != crcFromArchive)
return SZE_ARCHIVE_ERROR;
if (nextHeaderSize == 0)
@@ -1230,7 +1229,7 @@ SZ_RESULT SzArchiveOpen2(
if (res == SZ_OK)
{
res = SZE_ARCHIVE_ERROR;
- if (CrcVerifyDigest(nextHeaderCRC, buffer.Items, (UInt32)nextHeaderSize))
+ if (CrcCalc(buffer.Items, (UInt32)nextHeaderSize) == nextHeaderCRC)
{
for (;;)
{
diff --git a/C/Archive/7z/7zIn.h b/C/Archive/7z/7zIn.h
new file mode 100755
index 00000000..6bfa2a70
--- /dev/null
+++ b/C/Archive/7z/7zIn.h
@@ -0,0 +1,55 @@
+/* 7zIn.h */
+
+#ifndef __7Z_IN_H
+#define __7Z_IN_H
+
+#include "7zHeader.h"
+#include "7zItem.h"
+#include "7zAlloc.h"
+
+typedef struct _CInArchiveInfo
+{
+ CFileSize StartPositionAfterHeader;
+ CFileSize DataStartPosition;
+}CInArchiveInfo;
+
+typedef struct _CArchiveDatabaseEx
+{
+ CArchiveDatabase Database;
+ CInArchiveInfo ArchiveInfo;
+ UInt32 *FolderStartPackStreamIndex;
+ CFileSize *PackStreamStartPositions;
+ UInt32 *FolderStartFileIndex;
+ UInt32 *FileIndexToFolderIndexMap;
+}CArchiveDatabaseEx;
+
+void SzArDbExInit(CArchiveDatabaseEx *db);
+void SzArDbExFree(CArchiveDatabaseEx *db, void (*freeFunc)(void *));
+CFileSize SzArDbGetFolderStreamPos(CArchiveDatabaseEx *db, UInt32 folderIndex, UInt32 indexInFolder);
+CFileSize SzArDbGetFolderFullPackSize(CArchiveDatabaseEx *db, UInt32 folderIndex);
+
+typedef struct _ISzInStream
+{
+ #ifdef _LZMA_IN_CB
+ SZ_RESULT (*Read)(
+ void *object, /* pointer to ISzInStream itself */
+ void **buffer, /* out: pointer to buffer with data */
+ size_t maxRequiredSize, /* max required size to read */
+ size_t *processedSize); /* real processed size.
+ processedSize can be less than maxRequiredSize.
+ If processedSize == 0, then there are no more
+ bytes in stream. */
+ #else
+ SZ_RESULT (*Read)(void *object, void *buffer, size_t size, size_t *processedSize);
+ #endif
+ SZ_RESULT (*Seek)(void *object, CFileSize pos);
+} ISzInStream;
+
+
+int SzArchiveOpen(
+ ISzInStream *inStream,
+ CArchiveDatabaseEx *db,
+ ISzAlloc *allocMain,
+ ISzAlloc *allocTemp);
+
+#endif
diff --git a/C/Archive/7z/7zItem.h b/C/Archive/7z/7zItem.h
new file mode 100755
index 00000000..876539a9
--- /dev/null
+++ b/C/Archive/7z/7zItem.h
@@ -0,0 +1,90 @@
+/* 7zItem.h */
+
+#ifndef __7Z_ITEM_H
+#define __7Z_ITEM_H
+
+#include "7zMethodID.h"
+#include "7zHeader.h"
+#include "7zBuffer.h"
+
+typedef struct _CCoderInfo
+{
+ UInt32 NumInStreams;
+ UInt32 NumOutStreams;
+ CMethodID MethodID;
+ CSzByteBuffer Properties;
+}CCoderInfo;
+
+void SzCoderInfoInit(CCoderInfo *coder);
+void SzCoderInfoFree(CCoderInfo *coder, void (*freeFunc)(void *p));
+
+typedef struct _CBindPair
+{
+ UInt32 InIndex;
+ UInt32 OutIndex;
+}CBindPair;
+
+typedef struct _CFolder
+{
+ UInt32 NumCoders;
+ CCoderInfo *Coders;
+ UInt32 NumBindPairs;
+ CBindPair *BindPairs;
+ UInt32 NumPackStreams;
+ UInt32 *PackStreams;
+ CFileSize *UnPackSizes;
+ int UnPackCRCDefined;
+ UInt32 UnPackCRC;
+
+ UInt32 NumUnPackStreams;
+}CFolder;
+
+void SzFolderInit(CFolder *folder);
+CFileSize SzFolderGetUnPackSize(CFolder *folder);
+int SzFolderFindBindPairForInStream(CFolder *folder, UInt32 inStreamIndex);
+UInt32 SzFolderGetNumOutStreams(CFolder *folder);
+CFileSize SzFolderGetUnPackSize(CFolder *folder);
+
+/* #define CArchiveFileTime UInt64 */
+
+typedef struct _CFileItem
+{
+ /*
+ CArchiveFileTime LastWriteTime;
+ CFileSize StartPos;
+ UInt32 Attributes;
+ */
+ CFileSize Size;
+ UInt32 FileCRC;
+ char *Name;
+
+ Byte IsFileCRCDefined;
+ Byte HasStream;
+ Byte IsDirectory;
+ Byte IsAnti;
+ /*
+ int AreAttributesDefined;
+ int IsLastWriteTimeDefined;
+ int IsStartPosDefined;
+ */
+}CFileItem;
+
+void SzFileInit(CFileItem *fileItem);
+
+typedef struct _CArchiveDatabase
+{
+ UInt32 NumPackStreams;
+ CFileSize *PackSizes;
+ Byte *PackCRCsDefined;
+ UInt32 *PackCRCs;
+ UInt32 NumFolders;
+ CFolder *Folders;
+ UInt32 NumFiles;
+ CFileItem *Files;
+}CArchiveDatabase;
+
+void SzArchiveDatabaseInit(CArchiveDatabase *db);
+void SzArchiveDatabaseFree(CArchiveDatabase *db, void (*freeFunc)(void *));
+
+
+#endif
diff --git a/C/Archive/7z/7zMain.c b/C/Archive/7z/7zMain.c
index 0a789639..efd3624d 100755
--- a/C/Archive/7z/7zMain.c
+++ b/C/Archive/7z/7zMain.c
@@ -159,7 +159,11 @@ SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
{
LARGE_INTEGER value;
value.LowPart = (DWORD)pos;
- value.HighPart = (LONG)(pos >> 32);
+ value.HighPart = (LONG)((UInt64)pos >> 32);
+ #ifdef _SZ_FILE_SIZE_32
+ // VC 6.0 has bug with >> 32 shifts.
+ value.HighPart = 0;
+ #endif
value.LowPart = SetFilePointer(s->File, value.LowPart, &value.HighPart, FILE_BEGIN);
if (value.LowPart == 0xFFFFFFFF)
if(GetLastError() != NO_ERROR)
@@ -187,7 +191,7 @@ int main(int numargs, char *args[])
ISzAlloc allocImp;
ISzAlloc allocTempImp;
- printf("\n7z ANSI-C Decoder 4.44 Copyright (c) 1999-2006 Igor Pavlov 2006-08-27\n");
+ printf("\n7z ANSI-C Decoder 4.45 Copyright (c) 1999-2007 Igor Pavlov 2007-03-15\n");
if (numargs == 1)
{
printf(
diff --git a/C/Archive/7z/7zMethodID.h b/C/Archive/7z/7zMethodID.h
new file mode 100755
index 00000000..8eb301da
--- /dev/null
+++ b/C/Archive/7z/7zMethodID.h
@@ -0,0 +1,18 @@
+/* 7zMethodID.h */
+
+#ifndef __7Z_METHOD_ID_H
+#define __7Z_METHOD_ID_H
+
+#include "../../Types.h"
+
+#define kMethodIDSize 15
+
+typedef struct _CMethodID
+{
+ Byte ID[kMethodIDSize];
+ Byte IDSize;
+} CMethodID;
+
+int AreMethodsEqual(CMethodID *a1, CMethodID *a2);
+
+#endif
diff --git a/C/Archive/7z/7z_C.dsp b/C/Archive/7z/7z_C.dsp
index 699384ef..e53d1d0a 100755
--- a/C/Archive/7z/7z_C.dsp
+++ b/C/Archive/7z/7z_C.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 /W4 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /D "_SZ_FILE_SIZE_64" /YX /FD /c
+# ADD CPP /nologo /W4 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /YX /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -66,7 +66,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 "_LZMA_PROB32" /D "_LZMA_IN_CB" /D "_SZ_FILE_SIZE_64" /YX /FD /GZ /c
+# ADD CPP /nologo /W4 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /YX /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -109,6 +109,10 @@ SOURCE=..\..\7zCrc.c
SOURCE=..\..\7zCrc.h
# End Source File
+# Begin Source File
+
+SOURCE=..\..\Types.h
+# End Source File
# End Group
# Begin Source File
@@ -178,9 +182,5 @@ SOURCE=.\7zMethodID.c
SOURCE=.\7zMethodID.h
# End Source File
-# Begin Source File
-
-SOURCE=.\7zTypes.h
-# End Source File
# End Target
# End Project
diff --git a/C/Archive/7z/makefile b/C/Archive/7z/makefile
index 9ce2c346..d6181717 100755
--- a/C/Archive/7z/makefile
+++ b/C/Archive/7z/makefile
@@ -8,11 +8,11 @@ O=O
!ENDIF
!ENDIF
-CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -GS-
+CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -GS- -WX -Gy
CFLAGS_O1 = $(CFLAGS) -O1
CFLAGS_O2 = $(CFLAGS) -O2
-LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98
+LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98 -OPT:REF
PROGPATH = $O\$(PROG)
@@ -20,11 +20,13 @@ COMPL_O1 = $(CPP) $(CFLAGS_O1) $**
COMPL_O2 = $(CPP) $(CFLAGS_O2) $**
COMPL = $(CPP) $(CFLAGS_O1) $**
+C_OBJS = \
+ $O\7zCrc.obj \
+
7Z_OBJS = \
$O\7zAlloc.obj \
$O\7zBuffer.obj \
- $O\7zCrc.obj \
$O\7zDecode.obj \
$O\7zExtract.obj \
$O\7zHeader.obj \
@@ -36,6 +38,7 @@ COMPL = $(CPP) $(CFLAGS_O1) $**
OBJS = \
$(7Z_OBJS) \
$O\LzmaDecode.obj \
+ $(C_OBJS) \
all: $(PROGPATH)
@@ -51,5 +54,7 @@ $(PROGPATH): $O $(OBJS)
$(7Z_OBJS): $(*B).c
$(COMPL)
-$O\LzmaDecode.obj: ../../Compress/LZMA_C/$(*B).c
+$O\LzmaDecode.obj: ../../Compress/Lzma/$(*B).c
+ $(COMPL_O2)
+$(C_OBJS): ../../$(*B).c
$(COMPL_O2)
diff --git a/C/Archive/7z/makefile.gcc b/C/Archive/7z/makefile.gcc
index 21b7df47..8de50b72 100755
--- a/C/Archive/7z/makefile.gcc
+++ b/C/Archive/7z/makefile.gcc
@@ -17,8 +17,8 @@ $(PROG): $(OBJS)
7zBuffer.o: 7zBuffer.c
$(CXX) $(CFLAGS) 7zBuffer.c
-7zCrc.o: 7zCrc.c
- $(CXX) $(CFLAGS) 7zCrc.c
+7zCrc.o: ../../7zCrc.c
+ $(CXX) $(CFLAGS) ../../7zCrc.c
7zDecode.o: 7zDecode.c
$(CXX) $(CFLAGS) 7zDecode.c
@@ -41,8 +41,8 @@ $(PROG): $(OBJS)
7zMethodID.o: 7zMethodID.c
$(CXX) $(CFLAGS) 7zMethodID.c
-LzmaDecode.o: ../../Compress/LZMA_C/LzmaDecode.c
- $(CXX) $(CFLAGS) ../../Compress/LZMA_C/LzmaDecode.c
+LzmaDecode.o: ../../Compress/Lzma/LzmaDecode.c
+ $(CXX) $(CFLAGS) ../../Compress/Lzma/LzmaDecode.c
clean:
diff --git a/C/Compress/Branch/BranchARM.c b/C/Compress/Branch/BranchARM.c
index 6d4e3672..da7db261 100755
--- a/C/Compress/Branch/BranchARM.c
+++ b/C/Compress/Branch/BranchARM.c
@@ -9,9 +9,9 @@ UInt32 ARM_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
{
if (data[i + 3] == 0xEB)
{
+ UInt32 dest;
UInt32 src = (data[i + 2] << 16) | (data[i + 1] << 8) | (data[i + 0]);
src <<= 2;
- UInt32 dest;
if (encoding)
dest = nowPos + i + 8 + src;
else
diff --git a/C/Compress/Branch/BranchARMThumb.c b/C/Compress/Branch/BranchARMThumb.c
index aab9c7a1..fa30e439 100755
--- a/C/Compress/Branch/BranchARMThumb.c
+++ b/C/Compress/Branch/BranchARMThumb.c
@@ -10,6 +10,7 @@ UInt32 ARMThumb_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
if ((data[i + 1] & 0xF8) == 0xF0 &&
(data[i + 3] & 0xF8) == 0xF8)
{
+ UInt32 dest;
UInt32 src =
((data[i + 1] & 0x7) << 19) |
(data[i + 0] << 11) |
@@ -17,7 +18,6 @@ UInt32 ARMThumb_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
(data[i + 2]);
src <<= 1;
- UInt32 dest;
if (encoding)
dest = nowPos + i + 4 + src;
else
diff --git a/C/Compress/Branch/BranchIA64.c b/C/Compress/Branch/BranchIA64.c
index e7775564..009086b1 100755
--- a/C/Compress/Branch/BranchIA64.c
+++ b/C/Compress/Branch/BranchIA64.c
@@ -18,29 +18,32 @@ UInt32 IA64_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
UInt32 instrTemplate = data[i] & 0x1F;
UInt32 mask = kBranchTable[instrTemplate];
UInt32 bitPos = 5;
- for (int slot = 0; slot < 3; slot++, bitPos += 41)
+ int slot;
+ for (slot = 0; slot < 3; slot++, bitPos += 41)
{
+ UInt32 bytePos, bitRes;
+ UInt64 instruction, instNorm;
+ int j;
if (((mask >> slot) & 1) == 0)
continue;
- UInt32 bytePos = (bitPos >> 3);
- UInt32 bitRes = bitPos & 0x7;
- UInt64 instruction = 0;
- int j;
+ bytePos = (bitPos >> 3);
+ bitRes = bitPos & 0x7;
+ instruction = 0;
for (j = 0; j < 6; j++)
instruction += (UInt64)(data[i + j + bytePos]) << (8 * j);
- UInt64 instNorm = instruction >> bitRes;
+ instNorm = instruction >> bitRes;
if (((instNorm >> 37) & 0xF) == 0x5
&& ((instNorm >> 9) & 0x7) == 0
/* && (instNorm & 0x3F)== 0 */
)
{
- UInt32 src = UInt32((instNorm >> 13) & 0xFFFFF);
- src |= ((instNorm >> 36) & 1) << 20;
+ UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF);
+ UInt32 dest;
+ src |= ((UInt32)(instNorm >> 36) & 1) << 20;
src <<= 4;
- UInt32 dest;
if (encoding)
dest = nowPos + i + src;
else
@@ -48,14 +51,14 @@ UInt32 IA64_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
dest >>= 4;
- instNorm &= ~(UInt64(0x8FFFFF) << 13);
- instNorm |= (UInt64(dest & 0xFFFFF) << 13);
- instNorm |= (UInt64(dest & 0x100000) << (36 - 20));
+ instNorm &= ~((UInt64)(0x8FFFFF) << 13);
+ instNorm |= ((UInt64)(dest & 0xFFFFF) << 13);
+ instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20));
instruction &= (1 << bitRes) - 1;
instruction |= (instNorm << bitRes);
for (j = 0; j < 6; j++)
- data[i + j + bytePos] = Byte(instruction >> (8 * j));
+ data[i + j + bytePos] = (Byte)(instruction >> (8 * j));
}
}
}
diff --git a/C/Compress/Branch/BranchSPARC.c b/C/Compress/Branch/BranchSPARC.c
index c175875b..79da2ea7 100755
--- a/C/Compress/Branch/BranchSPARC.c
+++ b/C/Compress/Branch/BranchSPARC.c
@@ -15,9 +15,9 @@ UInt32 SPARC_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
((UInt32)data[i + 1] << 16) |
((UInt32)data[i + 2] << 8) |
((UInt32)data[i + 3]);
+ UInt32 dest;
src <<= 2;
- UInt32 dest;
if (encoding)
dest = nowPos + i + src;
else
diff --git a/C/Compress/Branch/BranchSPARC.h b/C/Compress/Branch/BranchSPARC.h
index fbe9e673..67f44411 100755
--- a/C/Compress/Branch/BranchSPARC.h
+++ b/C/Compress/Branch/BranchSPARC.h
@@ -5,6 +5,6 @@
#include "BranchTypes.h"
-UInt32 SPARC_B_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding);
+UInt32 SPARC_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding);
#endif
diff --git a/C/Compress/Branch/BranchTypes.h b/C/Compress/Branch/BranchTypes.h
index f7ad3abc..bdf75131 100755
--- a/C/Compress/Branch/BranchTypes.h
+++ b/C/Compress/Branch/BranchTypes.h
@@ -22,4 +22,17 @@ typedef unsigned int UInt32;
#endif
#endif
+#ifndef _7ZIP_UINT64_DEFINED
+#define _7ZIP_UINT64_DEFINED
+#ifdef _SZ_NO_INT_64
+typedef unsigned long UInt64;
+#else
+#ifdef _MSC_VER
+typedef unsigned __int64 UInt64;
+#else
+typedef unsigned long long int UInt64;
+#endif
+#endif
+#endif
+
#endif
diff --git a/C/Compress/Lz/MatchFinderMt.c b/C/Compress/Lz/MatchFinderMt.c
index 4ab90d9a..69ac686a 100755
--- a/C/Compress/Lz/MatchFinderMt.c
+++ b/C/Compress/Lz/MatchFinderMt.c
@@ -1,6 +1,6 @@
/* MatchFinderMt.c */
-#include <stdio.h>
+#include <malloc.h>
#include "../../7zCrc.h"
#include "LzHash.h"
@@ -460,7 +460,7 @@ void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc)
#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks)
static unsigned StdCall HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; }
-static unsigned StdCall BtThreadFunc2(void *p) { BtThreadFunc((CMatchFinderMt *)p); return 0; }
+static unsigned StdCall BtThreadFunc2(void *p) { alloca(0x180); BtThreadFunc((CMatchFinderMt *)p); return 0; }
HRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,
UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc)
diff --git a/C/Compress/Lz/MatchFinderMt.h b/C/Compress/Lz/MatchFinderMt.h
index a99cc45f..a9d9372f 100755
--- a/C/Compress/Lz/MatchFinderMt.h
+++ b/C/Compress/Lz/MatchFinderMt.h
@@ -6,8 +6,6 @@
#include "../../Threads.h"
#include "MatchFinder.h"
-#define _LZ_MT
-
#define kMtHashBlockSize (1 << 13)
#define kMtHashNumBlocks (1 << 3)
#define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)
diff --git a/C/Types.h b/C/Types.h
index 9052a030..a781f481 100755
--- a/C/Types.h
+++ b/C/Types.h
@@ -48,14 +48,14 @@ typedef unsigned long long int UInt64;
#endif
-/* #define _SZ_FILE_SIZE_64 */
-/* Use _SZ_FILE_SIZE_64 if you need support for files larger than 4 GB*/
+/* #define _SZ_FILE_SIZE_32 */
+/* You can define _SZ_FILE_SIZE_32, if you don't need support for files larger than 4 GB*/
#ifndef CFileSize
-#ifdef _SZ_FILE_SIZE_64
-typedef UInt64 CFileSize;
-#else
+#ifdef _SZ_FILE_SIZE_32
typedef UInt32 CFileSize;
+#else
+typedef UInt64 CFileSize;
#endif
#endif
@@ -76,7 +76,7 @@ typedef int HRes;
#ifndef RINOK
-#define RINOK(x) { int __result_ = (x); if(__result_ != 0) return __result_; }
+#define RINOK(x) { HRes __result_ = (x); if(__result_ != 0) return __result_; }
#endif
typedef int Bool;
@@ -89,4 +89,12 @@ typedef int Bool;
#define StdCall
#endif
+#if _MSC_VER >= 1300
+#define MY_FAST_CALL __declspec(noinline) __fastcall
+#elif defined( _MSC_VER)
+#define MY_FAST_CALL __fastcall
+#else
+#define MY_FAST_CALL
+#endif
+
#endif