From 26833c35c9fd0e399ac21ca568c470d82251a0dc Mon Sep 17 00:00:00 2001 From: twinaphex <libretro@gmail.com> Date: Mon, 20 Oct 2014 04:28:20 +0200 Subject: [PATCH] (7z) Use stdint types - Types.h was conflicting with OSX 10.6 headers --- decompress/7zip_support.c | 40 ++-- deps/7zip/7z.h | 98 ++++----- deps/7zip/7zBuf.c | 3 +- deps/7zip/7zBuf.h | 6 +- deps/7zip/7zBuf2.c | 9 +- deps/7zip/7zCrc.c | 23 ++- deps/7zip/7zCrc.h | 6 +- deps/7zip/7zCrcOpt.c | 13 +- deps/7zip/7zDec.c | 125 +++++------ deps/7zip/7zFile.c | 13 +- deps/7zip/7zFile.h | 4 +- deps/7zip/7zIn.c | 421 +++++++++++++++++++------------------- deps/7zip/7zStream.c | 14 +- deps/7zip/Bcj2.c | 69 +++---- deps/7zip/Bcj2.h | 10 +- deps/7zip/Bra.c | 93 ++++----- deps/7zip/Bra.h | 16 +- deps/7zip/Bra86.c | 49 ++--- deps/7zip/CpuArch.c | 1 + deps/7zip/CpuArch.h | 62 +++--- deps/7zip/Lzma2Dec.c | 89 ++++---- deps/7zip/Lzma2Dec.h | 22 +- deps/7zip/LzmaDec.c | 167 +++++++-------- deps/7zip/LzmaDec.h | 55 ++--- deps/7zip/Types.h | 46 +---- 25 files changed, 707 insertions(+), 747 deletions(-) diff --git a/decompress/7zip_support.c b/decompress/7zip_support.c index d0d88626d0..af539101d8 100644 --- a/decompress/7zip_support.c +++ b/decompress/7zip_support.c @@ -47,16 +47,16 @@ static int Buf_EnsureSize(CBuf *dest, size_t size) #ifndef _WIN32 -static Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; +static uint8_t kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; -static Bool Utf16_To_Utf8(Byte *dest, size_t *destLen, - const UInt16 *src, size_t srcLen) +static Bool Utf16_To_Utf8(uint8_t *dest, size_t *destLen, + const uint16_t *src, size_t srcLen) { size_t destPos = 0, srcPos = 0; for (;;) { unsigned numAdds; - UInt32 value; + uint32_t value; if (srcPos == srcLen) { *destLen = destPos; @@ -72,7 +72,7 @@ static Bool Utf16_To_Utf8(Byte *dest, size_t *destLen, } if (value >= 0xD800 && value < 0xE000) { - UInt32 c2; + uint32_t c2; if (value >= 0xDC00 || srcPos == srcLen) break; c2 = src[srcPos++]; @@ -81,7 +81,7 @@ static Bool Utf16_To_Utf8(Byte *dest, size_t *destLen, value = (((value - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000; } for (numAdds = 1; numAdds < 5; numAdds++) - if (value < (((UInt32)1) << (numAdds * 5 + 6))) + if (value < (((uint32_t)1) << (numAdds * 5 + 6))) break; if (dest) dest[destPos] = (char)(kUtf8Limits[numAdds - 1] @@ -102,7 +102,7 @@ static Bool Utf16_To_Utf8(Byte *dest, size_t *destLen, } static SRes Utf16_To_Utf8Buf(CBuf *dest, - const UInt16 *src, size_t srcLen) + const uint16_t *src, size_t srcLen) { size_t destLen = 0; Bool res; @@ -116,7 +116,7 @@ static SRes Utf16_To_Utf8Buf(CBuf *dest, } #endif -static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s, int fileMode) +static SRes Utf16_To_Char(CBuf *buf, const uint16_t *s, int fileMode) { int len = 0; for (len = 0; s[len] != '\0'; len++); @@ -152,7 +152,7 @@ static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s, int fileMode) } -static SRes ConvertUtf16toCharString(const UInt16 *s, char *outstring) +static SRes ConvertUtf16toCharString(const uint16_t *s, char *outstring) { CBuf buf; SRes res; @@ -179,7 +179,7 @@ int read_7zip_file(const char * archive_path, SRes res; ISzAlloc allocImp; ISzAlloc allocTempImp; - UInt16 *temp = NULL; + uint16_t *temp = NULL; size_t tempSize = 0; long outsize = -1; bool file_found = false; @@ -210,9 +210,9 @@ int read_7zip_file(const char * archive_path, res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp); if (res == SZ_OK) { - UInt32 i; - UInt32 blockIndex = 0xFFFFFFFF; - Byte *outBuffer = 0; + uint32_t i; + uint32_t blockIndex = 0xFFFFFFFF; + uint8_t *outBuffer = 0; size_t outBufferSize = 0; for (i = 0; i < db.db.NumFiles; i++) @@ -233,7 +233,7 @@ int read_7zip_file(const char * archive_path, { SzFree(NULL, temp); tempSize = len; - temp = (UInt16 *)SzAlloc(NULL, tempSize * sizeof(temp[0])); + temp = (uint16_t *)SzAlloc(NULL, tempSize * sizeof(temp[0])); if (temp == 0) { res = SZ_ERROR_MEM; @@ -244,7 +244,7 @@ int read_7zip_file(const char * archive_path, char infile[PATH_MAX]; res = ConvertUtf16toCharString(temp,infile); - UInt64 filesize = f->Size; + uint64_t filesize = f->Size; (void)filesize; @@ -338,7 +338,7 @@ struct string_list *compressed_7zip_file_list_new(const char *path, SRes res; ISzAlloc allocImp; ISzAlloc allocTempImp; - UInt16 *temp = NULL; + uint16_t *temp = NULL; size_t tempSize = 0; long outsize = -1; @@ -365,9 +365,9 @@ struct string_list *compressed_7zip_file_list_new(const char *path, res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp); if (res == SZ_OK) { - UInt32 i; - UInt32 blockIndex = 0xFFFFFFFF; - Byte *outBuffer = 0; + uint32_t i; + uint32_t blockIndex = 0xFFFFFFFF; + uint8_t *outBuffer = 0; size_t outBufferSize = 0; (void)blockIndex; @@ -394,7 +394,7 @@ struct string_list *compressed_7zip_file_list_new(const char *path, { SzFree(NULL, temp); tempSize = len; - temp = (UInt16 *) SzAlloc(NULL, tempSize * sizeof(temp[0])); + temp = (uint16_t *) SzAlloc(NULL, tempSize * sizeof(temp[0])); if (temp == 0) { res = SZ_ERROR_MEM; diff --git a/deps/7zip/7z.h b/deps/7zip/7z.h index b7edd3ba53..bde452da3a 100755 --- a/deps/7zip/7z.h +++ b/deps/7zip/7z.h @@ -10,7 +10,7 @@ EXTERN_C_BEGIN #define k7zStartHeaderSize 0x20 #define k7zSignatureSize 6 -extern Byte k7zSignature[k7zSignatureSize]; +extern uint8_t k7zSignature[k7zSignatureSize]; #define k7zMajorVersion 0 enum EIdEnum @@ -45,9 +45,9 @@ enum EIdEnum typedef struct { - UInt32 NumInStreams; - UInt32 NumOutStreams; - UInt64 MethodID; + uint32_t NumInStreams; + uint32_t NumOutStreams; + uint64_t MethodID; CBuf Props; } CSzCoderInfo; @@ -56,67 +56,67 @@ void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc); typedef struct { - UInt32 InIndex; - UInt32 OutIndex; + uint32_t InIndex; + uint32_t OutIndex; } CSzBindPair; typedef struct { CSzCoderInfo *Coders; CSzBindPair *BindPairs; - UInt32 *PackStreams; - UInt64 *UnpackSizes; - UInt32 NumCoders; - UInt32 NumBindPairs; - UInt32 NumPackStreams; + uint32_t *PackStreams; + uint64_t *UnpackSizes; + uint32_t NumCoders; + uint32_t NumBindPairs; + uint32_t NumPackStreams; int UnpackCRCDefined; - UInt32 UnpackCRC; + uint32_t UnpackCRC; - UInt32 NumUnpackStreams; + uint32_t 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); +uint64_t SzFolder_GetUnpackSize(CSzFolder *p); +int SzFolder_FindBindPairForInStream(CSzFolder *p, uint32_t inStreamIndex); +uint32_t SzFolder_GetNumOutStreams(CSzFolder *p); +uint64_t SzFolder_GetUnpackSize(CSzFolder *p); -SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes, - ILookInStream *stream, UInt64 startPos, - Byte *outBuffer, size_t outSize, ISzAlloc *allocMain); +SRes SzFolder_Decode(const CSzFolder *folder, const uint64_t *packSizes, + ILookInStream *stream, uint64_t startPos, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain); typedef struct { - UInt32 Low; - UInt32 High; + uint32_t Low; + uint32_t High; } CNtfsFileTime; typedef struct { CNtfsFileTime MTime; - UInt64 Size; - UInt32 Crc; - UInt32 Attrib; - Byte HasStream; - Byte IsDir; - Byte IsAnti; - Byte CrcDefined; - Byte MTimeDefined; - Byte AttribDefined; + uint64_t Size; + uint32_t Crc; + uint32_t Attrib; + uint8_t HasStream; + uint8_t IsDir; + uint8_t IsAnti; + uint8_t CrcDefined; + uint8_t MTimeDefined; + uint8_t AttribDefined; } CSzFileItem; void SzFile_Init(CSzFileItem *p); typedef struct { - UInt64 *PackSizes; - Byte *PackCRCsDefined; - UInt32 *PackCRCs; + uint64_t *PackSizes; + uint8_t *PackCRCsDefined; + uint32_t *PackCRCs; CSzFolder *Folders; CSzFileItem *Files; - UInt32 NumPackStreams; - UInt32 NumFolders; - UInt32 NumFiles; + uint32_t NumPackStreams; + uint32_t NumFolders; + uint32_t NumFiles; } CSzAr; void SzAr_Init(CSzAr *p); @@ -147,13 +147,13 @@ typedef struct { CSzAr db; - UInt64 startPosAfterHeader; - UInt64 dataPos; + uint64_t startPosAfterHeader; + uint64_t dataPos; - UInt32 *FolderStartPackStreamIndex; - UInt64 *PackStreamStartPositions; - UInt32 *FolderStartFileIndex; - UInt32 *FileIndexToFolderIndexMap; + uint32_t *FolderStartPackStreamIndex; + uint64_t *PackStreamStartPositions; + uint32_t *FolderStartFileIndex; + uint32_t *FileIndexToFolderIndexMap; size_t *FileNameOffsets; /* in 2-byte steps */ CBuf FileNames; /* UTF-16-LE */ @@ -161,8 +161,8 @@ typedef struct 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); +uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder); +int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize); /* if dest == NULL, the return value specifies the required size of the buffer, @@ -170,14 +170,14 @@ if dest == NULL, the return value specifies the required size of the buffer, 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); +size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *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) */ + uint32_t fileIndex, /* index of file */ + uint32_t *blockIndex, /* index of solid block */ + uint8_t **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 */ diff --git a/deps/7zip/7zBuf.c b/deps/7zip/7zBuf.c index f91ae0741e..3d30bfd270 100755 --- a/deps/7zip/7zBuf.c +++ b/deps/7zip/7zBuf.c @@ -3,6 +3,7 @@ Igor Pavlov Public domain */ +#include <stdint.h> #include "7zBuf.h" void Buf_Init(CBuf *p) @@ -19,7 +20,7 @@ int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc) p->data = 0; return 1; } - p->data = (Byte *)alloc->Alloc(alloc, size); + p->data = (uint8_t *)alloc->Alloc(alloc, size); if (p->data != 0) { p->size = size; diff --git a/deps/7zip/7zBuf.h b/deps/7zip/7zBuf.h index 88ff0c2f2d..6aee7da80a 100755 --- a/deps/7zip/7zBuf.h +++ b/deps/7zip/7zBuf.h @@ -12,7 +12,7 @@ extern "C" { typedef struct { - Byte *data; + uint8_t *data; size_t size; } CBuf; @@ -22,14 +22,14 @@ void Buf_Free(CBuf *p, ISzAlloc *alloc); typedef struct { - Byte *data; + uint8_t *data; size_t size; size_t pos; } CDynBuf; void DynBuf_Construct(CDynBuf *p); void DynBuf_SeekToBeg(CDynBuf *p); -int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc); +int DynBuf_Write(CDynBuf *p, const uint8_t *buf, size_t size, ISzAlloc *alloc); void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc); #ifdef __cplusplus diff --git a/deps/7zip/7zBuf2.c b/deps/7zip/7zBuf2.c index 000be97ff2..acbe82f616 100755 --- a/deps/7zip/7zBuf2.c +++ b/deps/7zip/7zBuf2.c @@ -1,6 +1,7 @@ -/* 7zBuf2.c -- Byte Buffer +/* 7zBuf2.c -- uint8_t Buffer 2008-10-04 : Igor Pavlov : Public domain */ +#include <stdint.h> #include <string.h> #include "7zBuf.h" @@ -16,14 +17,14 @@ void DynBuf_SeekToBeg(CDynBuf *p) p->pos = 0; } -int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc) +int DynBuf_Write(CDynBuf *p, const uint8_t *buf, size_t size, ISzAlloc *alloc) { if (size > p->size - p->pos) { size_t newSize = p->pos + size; - Byte *data; + uint8_t *data; newSize += newSize / 4; - data = (Byte *)alloc->Alloc(alloc, newSize); + data = (uint8_t *)alloc->Alloc(alloc, newSize); if (data == 0) return 0; p->size = newSize; diff --git a/deps/7zip/7zCrc.c b/deps/7zip/7zCrc.c index 7bf6fb2d29..6b57e8bf59 100755 --- a/deps/7zip/7zCrc.c +++ b/deps/7zip/7zCrc.c @@ -1,6 +1,7 @@ /* 7zCrc.c -- CRC32 calculation 2009-11-23 : Igor Pavlov : Public domain */ +#include <stdint.h> #include "7zCrc.h" #include "CpuArch.h" @@ -12,18 +13,18 @@ #define CRC_NUM_TABLES 1 #endif -typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table); +typedef uint32_t (MY_FAST_CALL *CRC_FUNC)(uint32_t v, const void *data, size_t size, const uint32_t *table); static CRC_FUNC g_CrcUpdate; -UInt32 g_CrcTable[256 * CRC_NUM_TABLES]; +uint32_t g_CrcTable[256 * CRC_NUM_TABLES]; #if CRC_NUM_TABLES == 1 #define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) -static UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table) +static uint32_t MY_FAST_CALL CrcUpdateT1(uint32_t v, const void *data, size_t size, const uint32_t *table) { - const Byte *p = (const Byte *)data; + const uint8_t *p = (const uint8_t *)data; for (; size > 0; size--, p++) v = CRC_UPDATE_BYTE_2(v, *p); return v; @@ -31,27 +32,27 @@ static UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, #else -UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table); -UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table); +uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table); +uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table); #endif -UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size) +uint32_t MY_FAST_CALL CrcUpdate(uint32_t v, const void *data, size_t size) { return g_CrcUpdate(v, data, size, g_CrcTable); } -UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size) +uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size) { return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; } void MY_FAST_CALL CrcGenerateTable() { - UInt32 i; + uint32_t i; for (i = 0; i < 256; i++) { - UInt32 r = i; + uint32_t r = i; unsigned j; for (j = 0; j < 8; j++) r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); @@ -62,7 +63,7 @@ void MY_FAST_CALL CrcGenerateTable() #else for (; i < 256 * CRC_NUM_TABLES; i++) { - UInt32 r = g_CrcTable[i - 256]; + uint32_t r = g_CrcTable[i - 256]; g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); } g_CrcUpdate = CrcUpdateT4; diff --git a/deps/7zip/7zCrc.h b/deps/7zip/7zCrc.h index f745849593..5062d642c1 100755 --- a/deps/7zip/7zCrc.h +++ b/deps/7zip/7zCrc.h @@ -8,7 +8,7 @@ EXTERN_C_BEGIN -extern UInt32 g_CrcTable[]; +extern uint32_t g_CrcTable[]; /* Call CrcGenerateTable one time before other CRC functions */ void MY_FAST_CALL CrcGenerateTable(void); @@ -17,8 +17,8 @@ void MY_FAST_CALL CrcGenerateTable(void); #define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) #define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) -UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size); -UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size); +uint32_t MY_FAST_CALL CrcUpdate(uint32_t crc, const void *data, size_t size); +uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size); EXTERN_C_END diff --git a/deps/7zip/7zCrcOpt.c b/deps/7zip/7zCrcOpt.c index 4a719d2559..ba7699e54b 100755 --- a/deps/7zip/7zCrcOpt.c +++ b/deps/7zip/7zCrcOpt.c @@ -1,23 +1,24 @@ /* 7zCrcOpt.c -- CRC32 calculation : optimized version 2009-11-23 : Igor Pavlov : Public domain */ +#include <stdint.h> #include "CpuArch.h" #ifdef MY_CPU_LE #define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) -UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table); -UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table); +uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table); +uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table); -UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table) +uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table) { - const Byte *p = (const Byte *)data; + const uint8_t *p = (const uint8_t*)data; for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) v = CRC_UPDATE_BYTE_2(v, *p); for (; size >= 4; size -= 4, p += 4) { - v ^= *(const UInt32 *)p; + v ^= *(const uint32_t *)p; v = table[0x300 + (v & 0xFF)] ^ table[0x200 + ((v >> 8) & 0xFF)] ^ @@ -29,7 +30,7 @@ UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const U return v; } -UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table) +uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table) { return CrcUpdateT4(v, data, size, table); } diff --git a/deps/7zip/7zDec.c b/deps/7zip/7zDec.c index 338680747c..2bd6daad07 100755 --- a/deps/7zip/7zDec.c +++ b/deps/7zip/7zDec.c @@ -1,6 +1,7 @@ /* 7zDec.c -- Decoding from 7z folder 2010-11-02 : Igor Pavlov : Public domain */ +#include <stdint.h> #include <string.h> /* #define _7ZIP_PPMD_SUPPPORT */ @@ -32,19 +33,19 @@ typedef struct { - IByteIn p; - const Byte *cur; - const Byte *end; - const Byte *begin; - UInt64 processed; + Iuint8_tIn p; + const uint8_t *cur; + const uint8_t *end; + const uint8_t *begin; + uint64_t processed; Bool extra; SRes res; ILookInStream *inStream; -} CByteInToLook; +} Cuint8_tInToLook; -static Byte ReadByte(void *pp) +static uint8_t Readuint8_t(void *pp) { - CByteInToLook *p = (CByteInToLook *)pp; + Cuint8_tInToLook *p = (Cuint8_tInToLook *)pp; if (p->cur != p->end) return *p->cur++; if (p->res == SZ_OK) @@ -63,14 +64,14 @@ static Byte ReadByte(void *pp) return 0; } -static SRes SzDecodePpmd(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inStream, - Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain) +static SRes SzDecodePpmd(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) { CPpmd7 ppmd; - CByteInToLook s; + Cuint8_tInToLook s; SRes res = SZ_OK; - s.p.Read = ReadByte; + s.p.Read = Readuint8_t; s.inStream = inStream; s.begin = s.end = s.cur = NULL; s.extra = False; @@ -82,7 +83,7 @@ static SRes SzDecodePpmd(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inSt { unsigned order = coder->Props.data[0]; - UInt32 memSize = GetUi32(coder->Props.data + 1); + uint32_t memSize = GetUi32(coder->Props.data + 1); if (order < PPMD7_MIN_ORDER || order > PPMD7_MAX_ORDER || memSize < PPMD7_MIN_MEM_SIZE || @@ -103,13 +104,13 @@ static SRes SzDecodePpmd(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inSt res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA); else { - SizeT i; + size_t i; for (i = 0; i < outSize; i++) { int sym = Ppmd7_DecodeSymbol(&ppmd, &rc.p); if (s.extra || sym < 0) break; - outBuffer[i] = (Byte)sym; + outBuffer[i] = (uint8_t)sym; } if (i != outSize) res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA); @@ -124,8 +125,8 @@ static SRes SzDecodePpmd(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inSt #endif -static SRes SzDecodeLzma(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inStream, - Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain) +static SRes SzDecodeLzma(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) { CLzmaDec state; SRes res = SZ_OK; @@ -138,7 +139,7 @@ static SRes SzDecodeLzma(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inSt for (;;) { - Byte *inBuf = NULL; + uint8_t *inBuf = NULL; size_t lookahead = (1 << 18); if (lookahead > inSize) lookahead = (size_t)inSize; @@ -147,7 +148,7 @@ static SRes SzDecodeLzma(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inSt break; { - SizeT inProcessed = (SizeT)lookahead, dicPos = state.dicPos; + size_t inProcessed = (size_t)lookahead, dicPos = state.dicPos; ELzmaStatus status; res = LzmaDec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); lookahead -= inProcessed; @@ -172,8 +173,8 @@ static SRes SzDecodeLzma(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inSt return res; } -static SRes SzDecodeLzma2(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inStream, - Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain) +static SRes SzDecodeLzma2(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) { CLzma2Dec state; SRes res = SZ_OK; @@ -188,7 +189,7 @@ static SRes SzDecodeLzma2(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inS for (;;) { - Byte *inBuf = NULL; + uint8_t *inBuf = NULL; size_t lookahead = (1 << 18); if (lookahead > inSize) lookahead = (size_t)inSize; @@ -197,7 +198,7 @@ static SRes SzDecodeLzma2(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inS break; { - SizeT inProcessed = (SizeT)lookahead, dicPos = state.decoder.dicPos; + size_t inProcessed = (size_t)lookahead, dicPos = state.decoder.dicPos; ELzmaStatus status; res = Lzma2Dec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); lookahead -= inProcessed; @@ -221,7 +222,7 @@ static SRes SzDecodeLzma2(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inS return res; } -static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer) +static SRes SzDecodeCopy(uint64_t inSize, ILookInStream *inStream, uint8_t *outBuffer) { while (inSize > 0) { @@ -240,7 +241,7 @@ static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer return SZ_OK; } -static Bool IS_MAIN_METHOD(UInt32 m) +static Bool IS_MAIN_METHOD(uint32_t m) { switch(m) { @@ -260,8 +261,8 @@ static Bool IS_SUPPORTED_CODER(const CSzCoderInfo *c) return c->NumInStreams == 1 && c->NumOutStreams == 1 && - c->MethodID <= (UInt32)0xFFFFFFFF && - IS_MAIN_METHOD((UInt32)c->MethodID); + c->MethodID <= (uint32_t)0xFFFFFFFF && + IS_MAIN_METHOD((uint32_t)c->MethodID); } #define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumInStreams == 4 && (c)->NumOutStreams == 1) @@ -281,7 +282,7 @@ static SRes CheckSupportedFolder(const CSzFolder *f) if (f->NumCoders == 2) { CSzCoderInfo *c = &f->Coders[1]; - if (c->MethodID > (UInt32)0xFFFFFFFF || + if (c->MethodID > (uint32_t)0xFFFFFFFF || c->NumInStreams != 1 || c->NumOutStreams != 1 || f->NumPackStreams != 1 || @@ -290,7 +291,7 @@ static SRes CheckSupportedFolder(const CSzFolder *f) f->BindPairs[0].InIndex != 1 || f->BindPairs[0].OutIndex != 0) return SZ_ERROR_UNSUPPORTED; - switch ((UInt32)c->MethodID) + switch ((uint32_t)c->MethodID) { case k_BCJ: case k_ARM: @@ -321,10 +322,10 @@ static SRes CheckSupportedFolder(const CSzFolder *f) return SZ_ERROR_UNSUPPORTED; } -static UInt64 GetSum(const UInt64 *values, UInt32 index) +static uint64_t GetSum(const uint64_t *values, uint32_t index) { - UInt64 sum = 0; - UInt32 i; + uint64_t sum = 0; + uint32_t i; for (i = 0; i < index; i++) sum += values[i]; return sum; @@ -332,15 +333,15 @@ static UInt64 GetSum(const UInt64 *values, UInt32 index) #define CASE_BRA_CONV(isa) case k_ ## isa: isa ## _Convert(outBuffer, outSize, 0, 0); break; -static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes, - ILookInStream *inStream, UInt64 startPos, - Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain, - Byte *tempBuf[]) +static SRes SzFolder_Decode2(const CSzFolder *folder, const uint64_t *packSizes, + ILookInStream *inStream, uint64_t startPos, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain, + uint8_t *tempBuf[]) { - UInt32 ci; - SizeT tempSizes[3] = { 0, 0, 0}; - SizeT tempSize3 = 0; - Byte *tempBuf3 = 0; + uint32_t ci; + size_t tempSizes[3] = { 0, 0, 0}; + size_t tempSize3 = 0; + uint8_t *tempBuf3 = 0; RINOK(CheckSupportedFolder(folder)); @@ -348,25 +349,25 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes, { CSzCoderInfo *coder = &folder->Coders[ci]; - if (IS_MAIN_METHOD((UInt32)coder->MethodID)) + if (IS_MAIN_METHOD((uint32_t)coder->MethodID)) { - UInt32 si = 0; - UInt64 offset; - UInt64 inSize; - Byte *outBufCur = outBuffer; - SizeT outSizeCur = outSize; + uint32_t si = 0; + uint64_t offset; + uint64_t inSize; + uint8_t *outBufCur = outBuffer; + size_t outSizeCur = outSize; if (folder->NumCoders == 4) { - UInt32 indices[] = { 3, 2, 0 }; - UInt64 unpackSize = folder->UnpackSizes[ci]; + uint32_t indices[] = { 3, 2, 0 }; + uint64_t unpackSize = folder->UnpackSizes[ci]; si = indices[ci]; if (ci < 2) { - Byte *temp; - outSizeCur = (SizeT)unpackSize; + uint8_t *temp; + outSizeCur = (size_t)unpackSize; if (outSizeCur != unpackSize) return SZ_ERROR_MEM; - temp = (Byte *)IAlloc_Alloc(allocMain, outSizeCur); + temp = (uint8_t *)IAlloc_Alloc(allocMain, outSizeCur); if (temp == 0 && outSizeCur != 0) return SZ_ERROR_MEM; outBufCur = tempBuf[1 - ci] = temp; @@ -377,7 +378,7 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes, if (unpackSize > outSize) /* check it */ return SZ_ERROR_PARAM; tempBuf3 = outBufCur = outBuffer + (outSize - (size_t)unpackSize); - tempSize3 = outSizeCur = (SizeT)unpackSize; + tempSize3 = outSizeCur = (size_t)unpackSize; } else return SZ_ERROR_UNSUPPORTED; @@ -411,16 +412,16 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes, } else if (coder->MethodID == k_BCJ2) { - UInt64 offset = GetSum(packSizes, 1); - UInt64 s3Size = packSizes[1]; + uint64_t offset = GetSum(packSizes, 1); + uint64_t s3Size = packSizes[1]; SRes res; if (ci != 3) return SZ_ERROR_UNSUPPORTED; RINOK(LookInStream_SeekTo(inStream, startPos + offset)); - tempSizes[2] = (SizeT)s3Size; + tempSizes[2] = (size_t)s3Size; if (tempSizes[2] != s3Size) return SZ_ERROR_MEM; - tempBuf[2] = (Byte *)IAlloc_Alloc(allocMain, tempSizes[2]); + tempBuf[2] = (uint8_t *)IAlloc_Alloc(allocMain, tempSizes[2]); if (tempBuf[2] == 0 && tempSizes[2] != 0) return SZ_ERROR_MEM; res = SzDecodeCopy(s3Size, inStream, tempBuf[2]); @@ -442,7 +443,7 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes, { case k_BCJ: { - UInt32 state; + uint32_t state; x86_Convert_Init(state); x86_Convert(outBuffer, outSize, 0, &state, 0); break; @@ -456,14 +457,14 @@ static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes, return SZ_OK; } -SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes, - ILookInStream *inStream, UInt64 startPos, - Byte *outBuffer, size_t outSize, ISzAlloc *allocMain) +SRes SzFolder_Decode(const CSzFolder *folder, const uint64_t *packSizes, + ILookInStream *inStream, uint64_t startPos, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) { - Byte *tempBuf[3] = { 0, 0, 0}; + uint8_t *tempBuf[3] = { 0, 0, 0}; int i; SRes res = SzFolder_Decode2(folder, packSizes, inStream, startPos, - outBuffer, (SizeT)outSize, allocMain, tempBuf); + outBuffer, (size_t)outSize, allocMain, tempBuf); for (i = 0; i < 3; i++) IAlloc_Free(allocMain, tempBuf[i]); return res; diff --git a/deps/7zip/7zFile.c b/deps/7zip/7zFile.c index 171ea66824..29d42e00a8 100755 --- a/deps/7zip/7zFile.c +++ b/deps/7zip/7zFile.c @@ -1,6 +1,7 @@ /* 7zFile.c -- File IO 2009-11-24 : Igor Pavlov : Public domain */ +#include <stdint.h> #include "7zFile.h" #ifndef USE_WINDOWS_FILE @@ -164,14 +165,14 @@ WRes File_Write(CSzFile *p, const void *data, size_t *size) #endif } -WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin) +WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin) { #ifdef USE_WINDOWS_FILE LARGE_INTEGER value; DWORD moveMethod; value.LowPart = (DWORD)*pos; - value.HighPart = (LONG)((UInt64)*pos >> 16 >> 16); /* for case when UInt64 is 32-bit only */ + value.HighPart = (LONG)((uint64_t)*pos >> 16 >> 16); /* for case when uint64_t is 32-bit only */ switch (origin) { case SZ_SEEK_SET: moveMethod = FILE_BEGIN; break; @@ -186,7 +187,7 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin) if (res != NO_ERROR) return res; } - *pos = ((Int64)value.HighPart << 32) | value.LowPart; + *pos = ((int64_t)value.HighPart << 32) | value.LowPart; return 0; #else @@ -207,7 +208,7 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin) #endif } -WRes File_GetLength(CSzFile *p, UInt64 *length) +WRes File_GetLength(CSzFile *p, uint64_t *length) { #ifdef USE_WINDOWS_FILE @@ -219,7 +220,7 @@ WRes File_GetLength(CSzFile *p, UInt64 *length) if (res != NO_ERROR) return res; } - *length = (((UInt64)sizeHigh) << 32) + sizeLow; + *length = (((uint64_t)sizeHigh) << 32) + sizeLow; return 0; #else @@ -256,7 +257,7 @@ static SRes FileInStream_Read(void *pp, void *buf, size_t *size) return (File_Read(&p->file, buf, size) == 0) ? SZ_OK : SZ_ERROR_READ; } -static SRes FileInStream_Seek(void *pp, Int64 *pos, ESzSeek origin) +static SRes FileInStream_Seek(void *pp, int64_t *pos, ESzSeek origin) { CFileInStream *p = (CFileInStream *)pp; return File_Seek(&p->file, pos, origin); diff --git a/deps/7zip/7zFile.h b/deps/7zip/7zFile.h index 5d857879e0..77018cc4c8 100755 --- a/deps/7zip/7zFile.h +++ b/deps/7zip/7zFile.h @@ -46,8 +46,8 @@ WRes File_Read(CSzFile *p, void *data, size_t *size); /* writes *size bytes */ WRes File_Write(CSzFile *p, const void *data, size_t *size); -WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin); -WRes File_GetLength(CSzFile *p, UInt64 *length); +WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin); +WRes File_GetLength(CSzFile *p, uint64_t *length); /* ---------- FileInStream ---------- */ diff --git a/deps/7zip/7zIn.c b/deps/7zip/7zIn.c index 010f3c32ab..828b0ae342 100755 --- a/deps/7zip/7zIn.c +++ b/deps/7zip/7zIn.c @@ -1,13 +1,14 @@ /* 7zIn.c -- 7z Input functions 2010-10-29 : Igor Pavlov : Public domain */ +#include <stdint.h> #include <string.h> #include "7z.h" #include "7zCrc.h" #include "CpuArch.h" -Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; +uint8_t k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; #define RINOM(x) { if ((x) == 0) return SZ_ERROR_MEM; } @@ -15,7 +16,7 @@ Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; #define NUM_CODER_STREAMS_MAX 32 void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc); -int SzFolder_FindBindPairForOutStream(CSzFolder *p, UInt32 outStreamIndex); +int SzFolder_FindBindPairForOutStream(CSzFolder *p, uint32_t outStreamIndex); void SzCoderInfo_Init(CSzCoderInfo *p) { @@ -44,7 +45,7 @@ void SzFolder_Init(CSzFolder *p) void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc) { - UInt32 i; + uint32_t i; if (p->Coders) for (i = 0; i < p->NumCoders; i++) SzCoderInfo_Free(&p->Coders[i], alloc); @@ -55,18 +56,18 @@ void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc) SzFolder_Init(p); } -UInt32 SzFolder_GetNumOutStreams(CSzFolder *p) +uint32_t SzFolder_GetNumOutStreams(CSzFolder *p) { - UInt32 result = 0; - UInt32 i; + uint32_t result = 0; + uint32_t i; for (i = 0; i < p->NumCoders; i++) result += p->Coders[i].NumOutStreams; return result; } -int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex) +int SzFolder_FindBindPairForInStream(CSzFolder *p, uint32_t inStreamIndex) { - UInt32 i; + uint32_t i; for (i = 0; i < p->NumBindPairs; i++) if (p->BindPairs[i].InIndex == inStreamIndex) return i; @@ -74,16 +75,16 @@ int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex) } -int SzFolder_FindBindPairForOutStream(CSzFolder *p, UInt32 outStreamIndex) +int SzFolder_FindBindPairForOutStream(CSzFolder *p, uint32_t outStreamIndex) { - UInt32 i; + uint32_t i; for (i = 0; i < p->NumBindPairs; i++) if (p->BindPairs[i].OutIndex == outStreamIndex) return i; return -1; } -UInt64 SzFolder_GetUnpackSize(CSzFolder *p) +uint64_t SzFolder_GetUnpackSize(CSzFolder *p) { int i = (int)SzFolder_GetNumOutStreams(p); if (i == 0) @@ -118,7 +119,7 @@ void SzAr_Init(CSzAr *p) void SzAr_Free(CSzAr *p, ISzAlloc *alloc) { - UInt32 i; + uint32_t i; if (p->Folders) for (i = 0; i < p->NumFolders; i++) SzFolder_Free(&p->Folders[i], alloc); @@ -158,12 +159,12 @@ void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc) } /* - UInt64 GetFolderPackStreamSize(int folderIndex, int streamIndex) const + uint64_t GetFolderPackStreamSize(int folderIndex, int streamIndex) const { return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex]; } - UInt64 GetFilePackSize(int fileIndex) const + uint64_t GetFilePackSize(int fileIndex) const { int folderIndex = FileIndexToFolderIndexMap[fileIndex]; if (folderIndex >= 0) @@ -181,19 +182,19 @@ void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc) static SRes SzArEx_Fill(CSzArEx *p, ISzAlloc *alloc) { - UInt32 startPos = 0; - UInt64 startPosSize = 0; - UInt32 i; - UInt32 folderIndex = 0; - UInt32 indexInFolder = 0; - MY_ALLOC(UInt32, p->FolderStartPackStreamIndex, p->db.NumFolders, alloc); + uint32_t startPos = 0; + uint64_t startPosSize = 0; + uint32_t i; + uint32_t folderIndex = 0; + uint32_t indexInFolder = 0; + MY_ALLOC(uint32_t, p->FolderStartPackStreamIndex, p->db.NumFolders, alloc); for (i = 0; i < p->db.NumFolders; i++) { p->FolderStartPackStreamIndex[i] = startPos; startPos += p->db.Folders[i].NumPackStreams; } - MY_ALLOC(UInt64, p->PackStreamStartPositions, p->db.NumPackStreams, alloc); + MY_ALLOC(uint64_t, p->PackStreamStartPositions, p->db.NumPackStreams, alloc); for (i = 0; i < p->db.NumPackStreams; i++) { @@ -201,8 +202,8 @@ static SRes SzArEx_Fill(CSzArEx *p, ISzAlloc *alloc) startPosSize += p->db.PackSizes[i]; } - MY_ALLOC(UInt32, p->FolderStartFileIndex, p->db.NumFolders, alloc); - MY_ALLOC(UInt32, p->FileIndexToFolderIndexMap, p->db.NumFiles, alloc); + MY_ALLOC(uint32_t, p->FolderStartFileIndex, p->db.NumFolders, alloc); + MY_ALLOC(uint32_t, p->FileIndexToFolderIndexMap, p->db.NumFiles, alloc); for (i = 0; i < p->db.NumFiles; i++) { @@ -210,7 +211,7 @@ static SRes SzArEx_Fill(CSzArEx *p, ISzAlloc *alloc) int emptyStream = !file->HasStream; if (emptyStream && indexInFolder == 0) { - p->FileIndexToFolderIndexMap[i] = (UInt32)-1; + p->FileIndexToFolderIndexMap[i] = (uint32_t)-1; continue; } if (indexInFolder == 0) @@ -243,21 +244,21 @@ static SRes SzArEx_Fill(CSzArEx *p, ISzAlloc *alloc) } -UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder) +uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder) { return p->dataPos + p->PackStreamStartPositions[p->FolderStartPackStreamIndex[folderIndex] + indexInFolder]; } -int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize) +int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize) { - UInt32 packStreamIndex = p->FolderStartPackStreamIndex[folderIndex]; + uint32_t packStreamIndex = p->FolderStartPackStreamIndex[folderIndex]; CSzFolder *folder = p->db.Folders + folderIndex; - UInt64 size = 0; - UInt32 i; + uint64_t size = 0; + uint32_t i; for (i = 0; i < folder->NumPackStreams; i++) { - UInt64 t = size + p->db.PackSizes[packStreamIndex + i]; + uint64_t t = size + p->db.PackSizes[packStreamIndex + i]; if (t < size) /* check it */ return SZ_ERROR_FAIL; size = t; @@ -269,7 +270,7 @@ int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *r /* SRes SzReadTime(const CObjectVector<CBuf> &dataVector, - CObjectVector<CSzFileItem> &files, UInt64 type) + CObjectVector<CSzFileItem> &files, uint64_t type) { CBoolVector boolVector; RINOK(ReadBoolVector2(files.Size(), boolVector)) @@ -284,9 +285,9 @@ int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *r bool defined = boolVector[i]; if (defined) { - UInt32 low, high; - RINOK(SzReadUInt32(low)); - RINOK(SzReadUInt32(high)); + uint32_t low, high; + RINOK(SzReaduint32_t(low)); + RINOK(SzReaduint32_t(high)); fileTime.dwLowDateTime = low; fileTime.dwHighDateTime = high; } @@ -301,22 +302,22 @@ int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *r } */ -static int TestSignatureCandidate(Byte *testBytes) +static int TestSignatureCandidate(uint8_t *testuint8_ts) { size_t i; for (i = 0; i < k7zSignatureSize; i++) - if (testBytes[i] != k7zSignature[i]) + if (testuint8_ts[i] != k7zSignature[i]) return 0; return 1; } typedef struct _CSzState { - Byte *Data; + uint8_t *Data; size_t Size; }CSzData; -static SRes SzReadByte(CSzData *sd, Byte *b) +static SRes SzReaduint8_t(CSzData *sd, uint8_t *b) { if (sd->Size == 0) return SZ_ERROR_ARCHIVE; @@ -325,70 +326,70 @@ static SRes SzReadByte(CSzData *sd, Byte *b) return SZ_OK; } -static SRes SzReadBytes(CSzData *sd, Byte *data, size_t size) +static SRes SzReaduint8_ts(CSzData *sd, uint8_t *data, size_t size) { size_t i; for (i = 0; i < size; i++) { - RINOK(SzReadByte(sd, data + i)); + RINOK(SzReaduint8_t(sd, data + i)); } return SZ_OK; } -static SRes SzReadUInt32(CSzData *sd, UInt32 *value) +static SRes SzReaduint32_t(CSzData *sd, uint32_t *value) { int i; *value = 0; for (i = 0; i < 4; i++) { - Byte b; - RINOK(SzReadByte(sd, &b)); - *value |= ((UInt32)(b) << (8 * i)); + uint8_t b; + RINOK(SzReaduint8_t(sd, &b)); + *value |= ((uint32_t)(b) << (8 * i)); } return SZ_OK; } -static SRes SzReadNumber(CSzData *sd, UInt64 *value) +static SRes SzReadNumber(CSzData *sd, uint64_t *value) { - Byte firstByte; - Byte mask = 0x80; + uint8_t firstuint8_t; + uint8_t mask = 0x80; int i; - RINOK(SzReadByte(sd, &firstByte)); + RINOK(SzReaduint8_t(sd, &firstuint8_t)); *value = 0; for (i = 0; i < 8; i++) { - Byte b; - if ((firstByte & mask) == 0) + uint8_t b; + if ((firstuint8_t & mask) == 0) { - UInt64 highPart = firstByte & (mask - 1); + uint64_t highPart = firstuint8_t & (mask - 1); *value += (highPart << (8 * i)); return SZ_OK; } - RINOK(SzReadByte(sd, &b)); - *value |= ((UInt64)b << (8 * i)); + RINOK(SzReaduint8_t(sd, &b)); + *value |= ((uint64_t)b << (8 * i)); mask >>= 1; } return SZ_OK; } -static SRes SzReadNumber32(CSzData *sd, UInt32 *value) +static SRes SzReadNumber32(CSzData *sd, uint32_t *value) { - UInt64 value64; + uint64_t value64; RINOK(SzReadNumber(sd, &value64)); if (value64 >= 0x80000000) return SZ_ERROR_UNSUPPORTED; - if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 2))) + if (value64 >= ((uint64_t)(1) << ((sizeof(size_t) - 1) * 8 + 2))) return SZ_ERROR_UNSUPPORTED; - *value = (UInt32)value64; + *value = (uint32_t)value64; return SZ_OK; } -static SRes SzReadID(CSzData *sd, UInt64 *value) +static SRes SzReadID(CSzData *sd, uint64_t *value) { return SzReadNumber(sd, value); } -static SRes SzSkeepDataSize(CSzData *sd, UInt64 size) +static SRes SzSkeepDataSize(CSzData *sd, uint64_t size) { if (size > sd->Size) return SZ_ERROR_ARCHIVE; @@ -399,7 +400,7 @@ static SRes SzSkeepDataSize(CSzData *sd, UInt64 size) static SRes SzSkeepData(CSzData *sd) { - UInt64 size; + uint64_t size; RINOK(SzReadNumber(sd, &size)); return SzSkeepDataSize(sd, size); } @@ -408,7 +409,7 @@ static SRes SzReadArchiveProperties(CSzData *sd) { for (;;) { - UInt64 type; + uint64_t type; RINOK(SzReadID(sd, &type)); if (type == k7zIdEnd) break; @@ -417,11 +418,11 @@ static SRes SzReadArchiveProperties(CSzData *sd) return SZ_OK; } -static SRes SzWaitAttribute(CSzData *sd, UInt64 attribute) +static SRes SzWaitAttribute(CSzData *sd, uint64_t attribute) { for (;;) { - UInt64 type; + uint64_t type; RINOK(SzReadID(sd, &type)); if (type == attribute) return SZ_OK; @@ -431,33 +432,33 @@ static SRes SzWaitAttribute(CSzData *sd, UInt64 attribute) } } -static SRes SzReadBoolVector(CSzData *sd, size_t numItems, Byte **v, ISzAlloc *alloc) +static SRes SzReadBoolVector(CSzData *sd, size_t numItems, uint8_t **v, ISzAlloc *alloc) { - Byte b = 0; - Byte mask = 0; + uint8_t b = 0; + uint8_t mask = 0; size_t i; - MY_ALLOC(Byte, *v, numItems, alloc); + MY_ALLOC(uint8_t, *v, numItems, alloc); for (i = 0; i < numItems; i++) { if (mask == 0) { - RINOK(SzReadByte(sd, &b)); + RINOK(SzReaduint8_t(sd, &b)); mask = 0x80; } - (*v)[i] = (Byte)(((b & mask) != 0) ? 1 : 0); + (*v)[i] = (uint8_t)(((b & mask) != 0) ? 1 : 0); mask >>= 1; } return SZ_OK; } -static SRes SzReadBoolVector2(CSzData *sd, size_t numItems, Byte **v, ISzAlloc *alloc) +static SRes SzReadBoolVector2(CSzData *sd, size_t numItems, uint8_t **v, ISzAlloc *alloc) { - Byte allAreDefined; + uint8_t allAreDefined; size_t i; - RINOK(SzReadByte(sd, &allAreDefined)); + RINOK(SzReaduint8_t(sd, &allAreDefined)); if (allAreDefined == 0) return SzReadBoolVector(sd, numItems, v, alloc); - MY_ALLOC(Byte, *v, numItems, alloc); + MY_ALLOC(uint8_t, *v, numItems, alloc); for (i = 0; i < numItems; i++) (*v)[i] = 1; return SZ_OK; @@ -466,37 +467,37 @@ static SRes SzReadBoolVector2(CSzData *sd, size_t numItems, Byte **v, ISzAlloc * static SRes SzReadHashDigests( CSzData *sd, size_t numItems, - Byte **digestsDefined, - UInt32 **digests, + uint8_t **digestsDefined, + uint32_t **digests, ISzAlloc *alloc) { size_t i; RINOK(SzReadBoolVector2(sd, numItems, digestsDefined, alloc)); - MY_ALLOC(UInt32, *digests, numItems, alloc); + MY_ALLOC(uint32_t, *digests, numItems, alloc); for (i = 0; i < numItems; i++) if ((*digestsDefined)[i]) { - RINOK(SzReadUInt32(sd, (*digests) + i)); + RINOK(SzReaduint32_t(sd, (*digests) + i)); } return SZ_OK; } static SRes SzReadPackInfo( CSzData *sd, - UInt64 *dataOffset, - UInt32 *numPackStreams, - UInt64 **packSizes, - Byte **packCRCsDefined, - UInt32 **packCRCs, + uint64_t *dataOffset, + uint32_t *numPackStreams, + uint64_t **packSizes, + uint8_t **packCRCsDefined, + uint32_t **packCRCs, ISzAlloc *alloc) { - UInt32 i; + uint32_t i; RINOK(SzReadNumber(sd, dataOffset)); RINOK(SzReadNumber32(sd, numPackStreams)); RINOK(SzWaitAttribute(sd, k7zIdSize)); - MY_ALLOC(UInt64, *packSizes, (size_t)*numPackStreams, alloc); + MY_ALLOC(uint64_t, *packSizes, (size_t)*numPackStreams, alloc); for (i = 0; i < *numPackStreams; i++) { @@ -505,7 +506,7 @@ static SRes SzReadPackInfo( for (;;) { - UInt64 type; + uint64_t type; RINOK(SzReadID(sd, &type)); if (type == k7zIdEnd) break; @@ -518,8 +519,8 @@ static SRes SzReadPackInfo( } if (*packCRCsDefined == 0) { - MY_ALLOC(Byte, *packCRCsDefined, (size_t)*numPackStreams, alloc); - MY_ALLOC(UInt32, *packCRCs, (size_t)*numPackStreams, alloc); + MY_ALLOC(uint8_t, *packCRCsDefined, (size_t)*numPackStreams, alloc); + MY_ALLOC(uint32_t, *packCRCs, (size_t)*numPackStreams, alloc); for (i = 0; i < *numPackStreams; i++) { (*packCRCsDefined)[i] = 0; @@ -531,15 +532,15 @@ static SRes SzReadPackInfo( static SRes SzReadSwitch(CSzData *sd) { - Byte external; - RINOK(SzReadByte(sd, &external)); + uint8_t external; + RINOK(SzReaduint8_t(sd, &external)); return (external == 0) ? SZ_OK: SZ_ERROR_UNSUPPORTED; } static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) { - UInt32 numCoders, numBindPairs, numPackStreams, i; - UInt32 numInStreams = 0, numOutStreams = 0; + uint32_t numCoders, numBindPairs, numPackStreams, i; + uint32_t numInStreams = 0, numOutStreams = 0; RINOK(SzReadNumber32(sd, &numCoders)); if (numCoders > NUM_FOLDER_CODERS_MAX) @@ -553,21 +554,21 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) for (i = 0; i < numCoders; i++) { - Byte mainByte; + uint8_t mainuint8_t; CSzCoderInfo *coder = folder->Coders + i; { unsigned idSize, j; - Byte longID[15]; - RINOK(SzReadByte(sd, &mainByte)); - idSize = (unsigned)(mainByte & 0xF); - RINOK(SzReadBytes(sd, longID, idSize)); + uint8_t longID[15]; + RINOK(SzReaduint8_t(sd, &mainuint8_t)); + idSize = (unsigned)(mainuint8_t & 0xF); + RINOK(SzReaduint8_ts(sd, longID, idSize)); if (idSize > sizeof(coder->MethodID)) return SZ_ERROR_UNSUPPORTED; coder->MethodID = 0; for (j = 0; j < idSize; j++) - coder->MethodID |= (UInt64)longID[idSize - 1 - j] << (8 * j); + coder->MethodID |= (uint64_t)longID[idSize - 1 - j] << (8 * j); - if ((mainByte & 0x10) != 0) + if ((mainuint8_t & 0x10) != 0) { RINOK(SzReadNumber32(sd, &coder->NumInStreams)); RINOK(SzReadNumber32(sd, &coder->NumOutStreams)); @@ -580,28 +581,28 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) coder->NumInStreams = 1; coder->NumOutStreams = 1; } - if ((mainByte & 0x20) != 0) + if ((mainuint8_t & 0x20) != 0) { - UInt64 propertiesSize = 0; + uint64_t propertiesSize = 0; RINOK(SzReadNumber(sd, &propertiesSize)); if (!Buf_Create(&coder->Props, (size_t)propertiesSize, alloc)) return SZ_ERROR_MEM; - RINOK(SzReadBytes(sd, coder->Props.data, (size_t)propertiesSize)); + RINOK(SzReaduint8_ts(sd, coder->Props.data, (size_t)propertiesSize)); } } - while ((mainByte & 0x80) != 0) + while ((mainuint8_t & 0x80) != 0) { - RINOK(SzReadByte(sd, &mainByte)); - RINOK(SzSkeepDataSize(sd, (mainByte & 0xF))); - if ((mainByte & 0x10) != 0) + RINOK(SzReaduint8_t(sd, &mainuint8_t)); + RINOK(SzSkeepDataSize(sd, (mainuint8_t & 0xF))); + if ((mainuint8_t & 0x10) != 0) { - UInt32 n; + uint32_t n; RINOK(SzReadNumber32(sd, &n)); RINOK(SzReadNumber32(sd, &n)); } - if ((mainByte & 0x20) != 0) + if ((mainuint8_t & 0x20) != 0) { - UInt64 propertiesSize = 0; + uint64_t propertiesSize = 0; RINOK(SzReadNumber(sd, &propertiesSize)); RINOK(SzSkeepDataSize(sd, propertiesSize)); } @@ -627,7 +628,7 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) return SZ_ERROR_UNSUPPORTED; folder->NumPackStreams = numPackStreams = numInStreams - numBindPairs; - MY_ALLOC(UInt32, folder->PackStreams, (size_t)numPackStreams, alloc); + MY_ALLOC(uint32_t, folder->PackStreams, (size_t)numPackStreams, alloc); if (numPackStreams == 1) { @@ -648,12 +649,12 @@ static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) static SRes SzReadUnpackInfo( CSzData *sd, - UInt32 *numFolders, + uint32_t *numFolders, CSzFolder **folders, /* for alloc */ ISzAlloc *alloc, ISzAlloc *allocTemp) { - UInt32 i; + uint32_t i; RINOK(SzWaitAttribute(sd, k7zIdFolder)); RINOK(SzReadNumber32(sd, numFolders)); { @@ -674,11 +675,11 @@ static SRes SzReadUnpackInfo( for (i = 0; i < *numFolders; i++) { - UInt32 j; + uint32_t j; CSzFolder *folder = (*folders) + i; - UInt32 numOutStreams = SzFolder_GetNumOutStreams(folder); + uint32_t numOutStreams = SzFolder_GetNumOutStreams(folder); - MY_ALLOC(UInt64, folder->UnpackSizes, (size_t)numOutStreams, alloc); + MY_ALLOC(uint64_t, folder->UnpackSizes, (size_t)numOutStreams, alloc); for (j = 0; j < numOutStreams; j++) { @@ -688,15 +689,15 @@ static SRes SzReadUnpackInfo( for (;;) { - UInt64 type; + uint64_t type; RINOK(SzReadID(sd, &type)); if (type == k7zIdEnd) return SZ_OK; if (type == k7zIdCRC) { SRes res; - Byte *crcsDefined = 0; - UInt32 *crcs = 0; + uint8_t *crcsDefined = 0; + uint32_t *crcs = 0; res = SzReadHashDigests(sd, *numFolders, &crcsDefined, &crcs, allocTemp); if (res == SZ_OK) { @@ -718,18 +719,18 @@ static SRes SzReadUnpackInfo( static SRes SzReadSubStreamsInfo( CSzData *sd, - UInt32 numFolders, + uint32_t numFolders, CSzFolder *folders, - UInt32 *numUnpackStreams, - UInt64 **unpackSizes, - Byte **digestsDefined, - UInt32 **digests, + uint32_t *numUnpackStreams, + uint64_t **unpackSizes, + uint8_t **digestsDefined, + uint32_t **digests, ISzAlloc *allocTemp) { - UInt64 type = 0; - UInt32 i; - UInt32 si = 0; - UInt32 numDigests = 0; + uint64_t type = 0; + uint32_t i; + uint32_t si = 0; + uint32_t numDigests = 0; for (i = 0; i < numFolders; i++) folders[i].NumUnpackStreams = 1; @@ -743,7 +744,7 @@ static SRes SzReadSubStreamsInfo( *numUnpackStreams = 0; for (i = 0; i < numFolders; i++) { - UInt32 numStreams; + uint32_t numStreams; RINOK(SzReadNumber32(sd, &numStreams)); folders[i].NumUnpackStreams = numStreams; *numUnpackStreams += numStreams; @@ -765,11 +766,11 @@ static SRes SzReadSubStreamsInfo( } else { - *unpackSizes = (UInt64 *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(UInt64)); + *unpackSizes = (uint64_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint64_t)); RINOM(*unpackSizes); - *digestsDefined = (Byte *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(Byte)); + *digestsDefined = (uint8_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint8_t)); RINOM(*digestsDefined); - *digests = (UInt32 *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(UInt32)); + *digests = (uint32_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint32_t)); RINOM(*digests); } @@ -779,15 +780,15 @@ static SRes SzReadSubStreamsInfo( v3.13 incorrectly worked with empty folders v4.07: we check that folder is empty */ - UInt64 sum = 0; - UInt32 j; - UInt32 numSubstreams = folders[i].NumUnpackStreams; + uint64_t sum = 0; + uint32_t j; + uint32_t numSubstreams = folders[i].NumUnpackStreams; if (numSubstreams == 0) continue; if (type == k7zIdSize) for (j = 1; j < numSubstreams; j++) { - UInt64 size; + uint64_t size; RINOK(SzReadNumber(sd, &size)); (*unpackSizes)[si++] = size; sum += size; @@ -808,7 +809,7 @@ static SRes SzReadSubStreamsInfo( for (i = 0; i < numFolders; i++) { - UInt32 numSubstreams = folders[i].NumUnpackStreams; + uint32_t numSubstreams = folders[i].NumUnpackStreams; if (numSubstreams != 1 || !folders[i].UnpackCRCDefined) numDigests += numSubstreams; } @@ -820,15 +821,15 @@ static SRes SzReadSubStreamsInfo( if (type == k7zIdCRC) { int digestIndex = 0; - Byte *digestsDefined2 = 0; - UInt32 *digests2 = 0; + uint8_t *digestsDefined2 = 0; + uint32_t *digests2 = 0; SRes res = SzReadHashDigests(sd, numDigests, &digestsDefined2, &digests2, allocTemp); if (res == SZ_OK) { for (i = 0; i < numFolders; i++) { CSzFolder *folder = folders + i; - UInt32 numSubstreams = folder->NumUnpackStreams; + uint32_t numSubstreams = folder->NumUnpackStreams; if (numSubstreams == 1 && folder->UnpackCRCDefined) { (*digestsDefined)[si] = 1; @@ -837,7 +838,7 @@ static SRes SzReadSubStreamsInfo( } else { - UInt32 j; + uint32_t j; for (j = 0; j < numSubstreams; j++, digestIndex++) { (*digestsDefined)[si] = digestsDefined2[digestIndex]; @@ -864,20 +865,20 @@ static SRes SzReadSubStreamsInfo( static SRes SzReadStreamsInfo( CSzData *sd, - UInt64 *dataOffset, + uint64_t *dataOffset, CSzAr *p, - UInt32 *numUnpackStreams, - UInt64 **unpackSizes, /* allocTemp */ - Byte **digestsDefined, /* allocTemp */ - UInt32 **digests, /* allocTemp */ + uint32_t *numUnpackStreams, + uint64_t **unpackSizes, /* allocTemp */ + uint8_t **digestsDefined, /* allocTemp */ + uint32_t **digests, /* allocTemp */ ISzAlloc *alloc, ISzAlloc *allocTemp) { for (;;) { - UInt64 type; + uint64_t type; RINOK(SzReadID(sd, &type)); - if ((UInt64)(int)type != type) + if ((uint64_t)(int)type != type) return SZ_ERROR_UNSUPPORTED; switch((int)type) { @@ -906,22 +907,22 @@ static SRes SzReadStreamsInfo( } } -size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest) +size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *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); + const uint8_t *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(const Byte *p, size_t size, UInt32 numFiles, size_t *sizes) +static SRes SzReadFileNames(const uint8_t *p, size_t size, uint32_t numFiles, size_t *sizes) { - UInt32 i; + uint32_t i; size_t pos = 0; for (i = 0; i < numFiles; i++) { @@ -943,21 +944,21 @@ static SRes SzReadFileNames(const Byte *p, size_t size, UInt32 numFiles, size_t static SRes SzReadHeader2( CSzArEx *p, /* allocMain */ CSzData *sd, - UInt64 **unpackSizes, /* allocTemp */ - Byte **digestsDefined, /* allocTemp */ - UInt32 **digests, /* allocTemp */ - Byte **emptyStreamVector, /* allocTemp */ - Byte **emptyFileVector, /* allocTemp */ - Byte **lwtVector, /* allocTemp */ + uint64_t **unpackSizes, /* allocTemp */ + uint8_t **digestsDefined, /* allocTemp */ + uint32_t **digests, /* allocTemp */ + uint8_t **emptyStreamVector, /* allocTemp */ + uint8_t **emptyFileVector, /* allocTemp */ + uint8_t **lwtVector, /* allocTemp */ ISzAlloc *allocMain, ISzAlloc *allocTemp) { - UInt64 type; - UInt32 numUnpackStreams = 0; - UInt32 numFiles = 0; + uint64_t type; + uint32_t numUnpackStreams = 0; + uint32_t numFiles = 0; CSzFileItem *files = 0; - UInt32 numEmptyStreams = 0; - UInt32 i; + uint32_t numEmptyStreams = 0; + uint32_t i; RINOK(SzReadID(sd, &type)); @@ -997,15 +998,15 @@ static SRes SzReadHeader2( for (;;) { - UInt64 type; - UInt64 size; + uint64_t type; + uint64_t size; RINOK(SzReadID(sd, &type)); if (type == k7zIdEnd) break; RINOK(SzReadNumber(sd, &size)); if (size > sd->Size) return SZ_ERROR_ARCHIVE; - if ((UInt64)(int)type != type) + if ((uint64_t)(int)type != type) { RINOK(SzSkeepDataSize(sd, size)); } @@ -1048,12 +1049,12 @@ static SRes SzReadHeader2( for (i = 0; i < numFiles; i++) { CSzFileItem *f = &files[i]; - Byte defined = (*lwtVector)[i]; + uint8_t defined = (*lwtVector)[i]; f->AttribDefined = defined; f->Attrib = 0; if (defined) { - RINOK(SzReadUInt32(sd, &f->Attrib)); + RINOK(SzReaduint32_t(sd, &f->Attrib)); } } IAlloc_Free(allocTemp, *lwtVector); @@ -1067,13 +1068,13 @@ static SRes SzReadHeader2( for (i = 0; i < numFiles; i++) { CSzFileItem *f = &files[i]; - Byte defined = (*lwtVector)[i]; + uint8_t defined = (*lwtVector)[i]; f->MTimeDefined = defined; f->MTime.Low = f->MTime.High = 0; if (defined) { - RINOK(SzReadUInt32(sd, &f->MTime.Low)); - RINOK(SzReadUInt32(sd, &f->MTime.High)); + RINOK(SzReaduint32_t(sd, &f->MTime.Low)); + RINOK(SzReaduint32_t(sd, &f->MTime.High)); } } IAlloc_Free(allocTemp, *lwtVector); @@ -1088,8 +1089,8 @@ static SRes SzReadHeader2( } { - UInt32 emptyFileIndex = 0; - UInt32 sizeIndex = 0; + uint32_t emptyFileIndex = 0; + uint32_t sizeIndex = 0; for (i = 0; i < numFiles; i++) { CSzFileItem *file = files + i; @@ -1097,13 +1098,13 @@ static SRes SzReadHeader2( if (*emptyStreamVector == 0) file->HasStream = 1; else - file->HasStream = (Byte)((*emptyStreamVector)[i] ? 0 : 1); + file->HasStream = (uint8_t)((*emptyStreamVector)[i] ? 0 : 1); if (file->HasStream) { file->IsDir = 0; file->Size = (*unpackSizes)[sizeIndex]; file->Crc = (*digests)[sizeIndex]; - file->CrcDefined = (Byte)(*digestsDefined)[sizeIndex]; + file->CrcDefined = (uint8_t)(*digestsDefined)[sizeIndex]; sizeIndex++; } else @@ -1111,7 +1112,7 @@ static SRes SzReadHeader2( if (*emptyFileVector == 0) file->IsDir = 1; else - file->IsDir = (Byte)((*emptyFileVector)[emptyFileIndex] ? 0 : 1); + file->IsDir = (uint8_t)((*emptyFileVector)[emptyFileIndex] ? 0 : 1); emptyFileIndex++; file->Size = 0; file->Crc = 0; @@ -1128,12 +1129,12 @@ static SRes SzReadHeader( ISzAlloc *allocMain, ISzAlloc *allocTemp) { - UInt64 *unpackSizes = 0; - Byte *digestsDefined = 0; - UInt32 *digests = 0; - Byte *emptyStreamVector = 0; - Byte *emptyFileVector = 0; - Byte *lwtVector = 0; + uint64_t *unpackSizes = 0; + uint8_t *digestsDefined = 0; + uint32_t *digests = 0; + uint8_t *emptyStreamVector = 0; + uint8_t *emptyFileVector = 0; + uint8_t *lwtVector = 0; SRes res = SzReadHeader2(p, sd, &unpackSizes, &digestsDefined, &digests, &emptyStreamVector, &emptyFileVector, &lwtVector, @@ -1151,18 +1152,18 @@ static SRes SzReadAndDecodePackedStreams2( ILookInStream *inStream, CSzData *sd, CBuf *outBuffer, - UInt64 baseOffset, + uint64_t baseOffset, CSzAr *p, - UInt64 **unpackSizes, - Byte **digestsDefined, - UInt32 **digests, + uint64_t **unpackSizes, + uint8_t **digestsDefined, + uint32_t **digests, ISzAlloc *allocTemp) { - UInt32 numUnpackStreams = 0; - UInt64 dataStartPos; + uint32_t numUnpackStreams = 0; + uint64_t dataStartPos; CSzFolder *folder; - UInt64 unpackSize; + uint64_t unpackSize; SRes res; RINOK(SzReadStreamsInfo(sd, &dataStartPos, p, @@ -1195,13 +1196,13 @@ static SRes SzReadAndDecodePackedStreams( ILookInStream *inStream, CSzData *sd, CBuf *outBuffer, - UInt64 baseOffset, + uint64_t baseOffset, ISzAlloc *allocTemp) { CSzAr p; - UInt64 *unpackSizes = 0; - Byte *digestsDefined = 0; - UInt32 *digests = 0; + uint64_t *unpackSizes = 0; + uint8_t *digestsDefined = 0; + uint32_t *digests = 0; SRes res; SzAr_Init(&p); res = SzReadAndDecodePackedStreams2(inStream, sd, outBuffer, baseOffset, @@ -1220,11 +1221,11 @@ static SRes SzArEx_Open2( ISzAlloc *allocMain, ISzAlloc *allocTemp) { - Byte header[k7zStartHeaderSize]; - Int64 startArcPos; - UInt64 nextHeaderOffset, nextHeaderSize; + uint8_t header[k7zStartHeaderSize]; + int64_t startArcPos; + uint64_t nextHeaderOffset, nextHeaderSize; size_t nextHeaderSizeT; - UInt32 nextHeaderCRC; + uint32_t nextHeaderCRC; CBuf buffer; SRes res; @@ -1257,11 +1258,11 @@ static SRes SzArEx_Open2( return SZ_ERROR_NO_ARCHIVE; { - Int64 pos = 0; + int64_t pos = 0; RINOK(inStream->Seek(inStream, &pos, SZ_SEEK_END)); - if ((UInt64)pos < startArcPos + nextHeaderOffset || - (UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset || - (UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) + if ((uint64_t)pos < startArcPos + nextHeaderOffset || + (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset || + (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) return SZ_ERROR_INPUT_EOF; } @@ -1277,7 +1278,7 @@ static SRes SzArEx_Open2( if (CrcCalc(buffer.data, nextHeaderSizeT) == nextHeaderCRC) { CSzData sd; - UInt64 type; + uint64_t type; sd.Data = buffer.data; sd.Size = buffer.size; res = SzReadID(&sd, &type); @@ -1325,20 +1326,20 @@ SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAl SRes SzArEx_Extract( const CSzArEx *p, ILookInStream *inStream, - UInt32 fileIndex, - UInt32 *blockIndex, - Byte **outBuffer, + uint32_t fileIndex, + uint32_t *blockIndex, + uint8_t **outBuffer, size_t *outBufferSize, size_t *offset, size_t *outSizeProcessed, ISzAlloc *allocMain, ISzAlloc *allocTemp) { - UInt32 folderIndex = p->FileIndexToFolderIndexMap[fileIndex]; + uint32_t folderIndex = p->FileIndexToFolderIndexMap[fileIndex]; SRes res = SZ_OK; *offset = 0; *outSizeProcessed = 0; - if (folderIndex == (UInt32)-1) + if (folderIndex == (uint32_t)-1) { IAlloc_Free(allocMain, *outBuffer); *blockIndex = folderIndex; @@ -1350,9 +1351,9 @@ SRes SzArEx_Extract( if (*outBuffer == 0 || *blockIndex != folderIndex) { CSzFolder *folder = p->db.Folders + folderIndex; - UInt64 unpackSizeSpec = SzFolder_GetUnpackSize(folder); + uint64_t unpackSizeSpec = SzFolder_GetUnpackSize(folder); size_t unpackSize = (size_t)unpackSizeSpec; - UInt64 startOffset = SzArEx_GetFolderStreamPos(p, folderIndex, 0); + uint64_t startOffset = SzArEx_GetFolderStreamPos(p, folderIndex, 0); if (unpackSize != unpackSizeSpec) return SZ_ERROR_MEM; @@ -1367,7 +1368,7 @@ SRes SzArEx_Extract( *outBufferSize = unpackSize; if (unpackSize != 0) { - *outBuffer = (Byte *)IAlloc_Alloc(allocMain, unpackSize); + *outBuffer = (uint8_t *)IAlloc_Alloc(allocMain, unpackSize); if (*outBuffer == 0) res = SZ_ERROR_MEM; } @@ -1390,11 +1391,11 @@ SRes SzArEx_Extract( } if (res == SZ_OK) { - UInt32 i; + uint32_t i; CSzFileItem *fileItem = p->db.Files + fileIndex; *offset = 0; for (i = p->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) - *offset += (UInt32)p->db.Files[i].Size; + *offset += (uint32_t)p->db.Files[i].Size; *outSizeProcessed = (size_t)fileItem->Size; if (*offset + *outSizeProcessed > *outBufferSize) return SZ_ERROR_FAIL; diff --git a/deps/7zip/7zStream.c b/deps/7zip/7zStream.c index e40f6fb087..81c4a0fd23 100755 --- a/deps/7zip/7zStream.c +++ b/deps/7zip/7zStream.c @@ -1,6 +1,8 @@ /* 7zStream.c -- 7z Stream functions 2010-03-11 : Igor Pavlov : Public domain */ +#include <stdint.h> +#include <stdint.h> #include <string.h> #include "Types.h" @@ -13,7 +15,7 @@ SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorT RINOK(stream->Read(stream, buf, &processed)); if (processed == 0) return errorType; - buf = (void *)((Byte *)buf + processed); + buf = (void *)((uint8_t *)buf + processed); size -= processed; } return SZ_OK; @@ -24,16 +26,16 @@ SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size) return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); } -SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf) +SRes SeqInStream_Readuint8_t(ISeqInStream *stream, uint8_t *buf) { size_t processed = 1; RINOK(stream->Read(stream, buf, &processed)); return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; } -SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset) +SRes LookInStream_SeekTo(ILookInStream *stream, uint64_t offset) { - Int64 t = offset; + int64_t t = offset; return stream->Seek(stream, &t, SZ_SEEK_SET); } @@ -55,7 +57,7 @@ SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes erro RINOK(stream->Read(stream, buf, &processed)); if (processed == 0) return errorType; - buf = (void *)((Byte *)buf + processed); + buf = (void *)((uint8_t *)buf + processed); size -= processed; } return SZ_OK; @@ -124,7 +126,7 @@ static SRes LookToRead_Read(void *pp, void *buf, size_t *size) return SZ_OK; } -static SRes LookToRead_Seek(void *pp, Int64 *pos, ESzSeek origin) +static SRes LookToRead_Seek(void *pp, int64_t *pos, ESzSeek origin) { CLookToRead *p = (CLookToRead *)pp; p->pos = p->size = 0; diff --git a/deps/7zip/Bcj2.c b/deps/7zip/Bcj2.c index 916b90c8c6..aa0fb6968e 100755 --- a/deps/7zip/Bcj2.c +++ b/deps/7zip/Bcj2.c @@ -1,19 +1,14 @@ /* Bcj2.c -- Converter for x86 code (BCJ2) 2008-10-04 : Igor Pavlov : Public domain */ +#include <stdint.h> #include "Bcj2.h" -#ifdef _LZMA_PROB32 -#define CProb UInt32 -#else -#define CProb UInt16 -#endif - #define IsJcc(b0, b1) ((b0) == 0x0F && ((b1) & 0xF0) == 0x80) #define IsJ(b0, b1) ((b1 & 0xFE) == 0xE8 || IsJcc(b0, b1)) #define kNumTopBits 24 -#define kTopValue ((UInt32)1 << kNumTopBits) +#define kTopValue ((uint32_t)1 << kNumTopBits) #define kNumBitModelTotalBits 11 #define kBitModelTotal (1 << kNumBitModelTotalBits) @@ -27,22 +22,22 @@ #define BCJ2_NORMALIZE if (range < kTopValue) { RC_TEST; range <<= 8; code = (code << 8) | RC_READ_BYTE; } #define BCJ2_IF_BIT_0(p) ttt = *(p); bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) -#define BCJ2_UPDATE_0(p) range = bound; *(p) = (CProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); BCJ2_NORMALIZE; -#define BCJ2_UPDATE_1(p) range -= bound; code -= bound; *(p) = (CProb)(ttt - (ttt >> kNumMoveBits)); BCJ2_NORMALIZE; +#define BCJ2_UPDATE_0(p) range = bound; *(p) = (uint16_t)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); BCJ2_NORMALIZE; +#define BCJ2_UPDATE_1(p) range -= bound; code -= bound; *(p) = (uint16_t)(ttt - (ttt >> kNumMoveBits)); BCJ2_NORMALIZE; int Bcj2_Decode( - const Byte *buf0, SizeT size0, - const Byte *buf1, SizeT size1, - const Byte *buf2, SizeT size2, - const Byte *buf3, SizeT size3, - Byte *outBuf, SizeT outSize) + const uint8_t *buf0, size_t size0, + const uint8_t *buf1, size_t size1, + const uint8_t *buf2, size_t size2, + const uint8_t *buf3, size_t size3, + uint8_t *outBuf, size_t outSize) { - CProb p[256 + 2]; - SizeT inPos = 0, outPos = 0; + uint16_t p[256 + 2]; + size_t inPos = 0, outPos = 0; - const Byte *buffer, *bufferLim; - UInt32 range, code; - Byte prevByte = 0; + const uint8_t *buffer, *bufferLim; + uint32_t range, code; + uint8_t prevuint8_t = 0; unsigned int i; for (i = 0; i < sizeof(p) / sizeof(p[0]); i++) @@ -57,22 +52,22 @@ int Bcj2_Decode( for (;;) { - Byte b; - CProb *prob; - UInt32 bound; - UInt32 ttt; + uint8_t b; + uint16_t *prob; + uint32_t bound; + uint32_t ttt; - SizeT limit = size0 - inPos; + size_t limit = size0 - inPos; if (outSize - outPos < limit) limit = outSize - outPos; while (limit != 0) { - Byte b = buf0[inPos]; + uint8_t b = buf0[inPos]; outBuf[outPos++] = b; - if (IsJ(prevByte, b)) + if (IsJ(prevuint8_t, b)) break; inPos++; - prevByte = b; + prevuint8_t = b; limit--; } @@ -82,7 +77,7 @@ int Bcj2_Decode( b = buf0[inPos++]; if (b == 0xE8) - prob = p + prevByte; + prob = p + prevuint8_t; else if (b == 0xE9) prob = p + 256; else @@ -91,12 +86,12 @@ int Bcj2_Decode( BCJ2_IF_BIT_0(prob) { BCJ2_UPDATE_0(prob) - prevByte = b; + prevuint8_t = b; } else { - UInt32 dest; - const Byte *v; + uint32_t dest; + const uint8_t *v; BCJ2_UPDATE_1(prob) if (b == 0xE8) { @@ -114,18 +109,18 @@ int Bcj2_Decode( buf2 += 4; size2 -= 4; } - dest = (((UInt32)v[0] << 24) | ((UInt32)v[1] << 16) | - ((UInt32)v[2] << 8) | ((UInt32)v[3])) - ((UInt32)outPos + 4); - outBuf[outPos++] = (Byte)dest; + dest = (((uint32_t)v[0] << 24) | ((uint32_t)v[1] << 16) | + ((uint32_t)v[2] << 8) | ((uint32_t)v[3])) - ((uint32_t)outPos + 4); + outBuf[outPos++] = (uint8_t)dest; if (outPos == outSize) break; - outBuf[outPos++] = (Byte)(dest >> 8); + outBuf[outPos++] = (uint8_t)(dest >> 8); if (outPos == outSize) break; - outBuf[outPos++] = (Byte)(dest >> 16); + outBuf[outPos++] = (uint8_t)(dest >> 16); if (outPos == outSize) break; - outBuf[outPos++] = prevByte = (Byte)(dest >> 24); + outBuf[outPos++] = prevuint8_t = (uint8_t)(dest >> 24); } } return (outPos == outSize) ? SZ_OK : SZ_ERROR_DATA; diff --git a/deps/7zip/Bcj2.h b/deps/7zip/Bcj2.h index d9d857bc30..2a46b0b039 100755 --- a/deps/7zip/Bcj2.h +++ b/deps/7zip/Bcj2.h @@ -25,11 +25,11 @@ Returns: */ int Bcj2_Decode( - const Byte *buf0, SizeT size0, - const Byte *buf1, SizeT size1, - const Byte *buf2, SizeT size2, - const Byte *buf3, SizeT size3, - Byte *outBuf, SizeT outSize); + const uint8_t *buf0, size_t size0, + const uint8_t *buf1, size_t size1, + const uint8_t *buf2, size_t size2, + const uint8_t *buf3, size_t size3, + uint8_t *outBuf, size_t outSize); #ifdef __cplusplus } diff --git a/deps/7zip/Bra.c b/deps/7zip/Bra.c index 402ca474c4..40a0e5f9ed 100755 --- a/deps/7zip/Bra.c +++ b/deps/7zip/Bra.c @@ -1,11 +1,12 @@ /* Bra.c -- Converters for RISC code 2010-04-16 : Igor Pavlov : Public domain */ +#include <stdint.h> #include "Bra.h" -SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +size_t ARM_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) { - SizeT i; + size_t i; if (size < 4) return 0; size -= 4; @@ -14,25 +15,25 @@ SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) { if (data[i + 3] == 0xEB) { - UInt32 dest; - UInt32 src = ((UInt32)data[i + 2] << 16) | ((UInt32)data[i + 1] << 8) | (data[i + 0]); + uint32_t dest; + uint32_t src = ((uint32_t)data[i + 2] << 16) | ((uint32_t)data[i + 1] << 8) | (data[i + 0]); src <<= 2; if (encoding) - dest = ip + (UInt32)i + src; + dest = ip + (uint32_t)i + src; else - dest = src - (ip + (UInt32)i); + dest = src - (ip + (uint32_t)i); dest >>= 2; - data[i + 2] = (Byte)(dest >> 16); - data[i + 1] = (Byte)(dest >> 8); - data[i + 0] = (Byte)dest; + data[i + 2] = (uint8_t)(dest >> 16); + data[i + 1] = (uint8_t)(dest >> 8); + data[i + 0] = (uint8_t)dest; } } return i; } -SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +size_t ARMT_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) { - SizeT i; + size_t i; if (size < 4) return 0; size -= 4; @@ -42,33 +43,33 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) if ((data[i + 1] & 0xF8) == 0xF0 && (data[i + 3] & 0xF8) == 0xF8) { - UInt32 dest; - UInt32 src = - (((UInt32)data[i + 1] & 0x7) << 19) | - ((UInt32)data[i + 0] << 11) | - (((UInt32)data[i + 3] & 0x7) << 8) | + uint32_t dest; + uint32_t src = + (((uint32_t)data[i + 1] & 0x7) << 19) | + ((uint32_t)data[i + 0] << 11) | + (((uint32_t)data[i + 3] & 0x7) << 8) | (data[i + 2]); src <<= 1; if (encoding) - dest = ip + (UInt32)i + src; + dest = ip + (uint32_t)i + src; else - dest = src - (ip + (UInt32)i); + dest = src - (ip + (uint32_t)i); dest >>= 1; - data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7)); - data[i + 0] = (Byte)(dest >> 11); - data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7)); - data[i + 2] = (Byte)dest; + data[i + 1] = (uint8_t)(0xF0 | ((dest >> 19) & 0x7)); + data[i + 0] = (uint8_t)(dest >> 11); + data[i + 3] = (uint8_t)(0xF8 | ((dest >> 8) & 0x7)); + data[i + 2] = (uint8_t)dest; i += 2; } } return i; } -SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +size_t PPC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) { - SizeT i; + size_t i; if (size < 4) return 0; size -= 4; @@ -76,19 +77,19 @@ SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) { if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1) { - UInt32 src = ((UInt32)(data[i + 0] & 3) << 24) | - ((UInt32)data[i + 1] << 16) | - ((UInt32)data[i + 2] << 8) | - ((UInt32)data[i + 3] & (~3)); + uint32_t src = ((uint32_t)(data[i + 0] & 3) << 24) | + ((uint32_t)data[i + 1] << 16) | + ((uint32_t)data[i + 2] << 8) | + ((uint32_t)data[i + 3] & (~3)); - UInt32 dest; + uint32_t dest; if (encoding) - dest = ip + (UInt32)i + src; + dest = ip + (uint32_t)i + src; else - dest = src - (ip + (UInt32)i); - data[i + 0] = (Byte)(0x48 | ((dest >> 24) & 0x3)); - data[i + 1] = (Byte)(dest >> 16); - data[i + 2] = (Byte)(dest >> 8); + dest = src - (ip + (uint32_t)i); + data[i + 0] = (uint8_t)(0x48 | ((dest >> 24) & 0x3)); + data[i + 1] = (uint8_t)(dest >> 16); + data[i + 2] = (uint8_t)(dest >> 8); data[i + 3] &= 0x3; data[i + 3] |= dest; } @@ -96,9 +97,9 @@ SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) return i; } -SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +size_t SPARC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) { - UInt32 i; + uint32_t i; if (size < 4) return 0; size -= 4; @@ -107,12 +108,12 @@ SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) || (data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)) { - UInt32 src = - ((UInt32)data[i + 0] << 24) | - ((UInt32)data[i + 1] << 16) | - ((UInt32)data[i + 2] << 8) | - ((UInt32)data[i + 3]); - UInt32 dest; + uint32_t src = + ((uint32_t)data[i + 0] << 24) | + ((uint32_t)data[i + 1] << 16) | + ((uint32_t)data[i + 2] << 8) | + ((uint32_t)data[i + 3]); + uint32_t dest; src <<= 2; if (encoding) @@ -123,10 +124,10 @@ SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000; - data[i + 0] = (Byte)(dest >> 24); - data[i + 1] = (Byte)(dest >> 16); - data[i + 2] = (Byte)(dest >> 8); - data[i + 3] = (Byte)dest; + data[i + 0] = (uint8_t)(dest >> 24); + data[i + 1] = (uint8_t)(dest >> 16); + data[i + 2] = (uint8_t)(dest >> 8); + data[i + 3] = (uint8_t)dest; } } return i; diff --git a/deps/7zip/Bra.h b/deps/7zip/Bra.h index bb4808ddca..11eadf70fc 100755 --- a/deps/7zip/Bra.h +++ b/deps/7zip/Bra.h @@ -42,11 +42,11 @@ If (size < Alignment + LookAhead), converter returns 0. Example: -UInt32 ip = 0; +uint32_t ip = 0; for () { ; size must be >= Alignment + LookAhead, if it's not last block -SizeT processed = Convert(data, size, ip, 1); +size_t processed = Convert(data, size, ip, 1); data += processed; size -= processed; ip += processed; @@ -54,12 +54,12 @@ ip += processed; */ #define x86_Convert_Init(state) { state = 0; } -SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding); -SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); +size_t x86_Convert(uint8_t *data, size_t size, uint32_t ip, uint32_t *state, int encoding); +size_t ARM_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t ARMT_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t PPC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t SPARC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t IA64_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); #ifdef __cplusplus } diff --git a/deps/7zip/Bra86.c b/deps/7zip/Bra86.c index dae0047b20..f59d23bafd 100755 --- a/deps/7zip/Bra86.c +++ b/deps/7zip/Bra86.c @@ -1,30 +1,31 @@ /* Bra86.c -- Converter for x86 code (BCJ) 2008-10-04 : Igor Pavlov : Public domain */ +#include <stdint.h> #include "Bra.h" -#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF) +#define Test86MSuint8_t(b) ((b) == 0 || (b) == 0xFF) -const Byte kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0}; -const Byte kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3}; +const uint8_t kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0}; +const uint8_t kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3}; -SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding) +size_t x86_Convert(uint8_t *data, size_t size, uint32_t ip, uint32_t *state, int encoding) { - SizeT bufferPos = 0, prevPosT; - UInt32 prevMask = *state & 0x7; + size_t bufferPos = 0, prevPosT; + uint32_t prevMask = *state & 0x7; if (size < 5) return 0; ip += 5; - prevPosT = (SizeT)0 - 1; + prevPosT = (size_t)0 - 1; for (;;) { - Byte *p = data + bufferPos; - Byte *limit = data + size - 4; + uint8_t *p = data + bufferPos; + uint8_t *limit = data + size - 4; for (; p < limit; p++) if ((*p & 0xFE) == 0xE8) break; - bufferPos = (SizeT)(p - data); + bufferPos = (size_t)(p - data); if (p >= limit) break; prevPosT = bufferPos - prevPosT; @@ -35,8 +36,8 @@ SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7; if (prevMask != 0) { - Byte b = p[4 - kMaskToBitNumber[prevMask]]; - if (!kMaskToAllowedStatus[prevMask] || Test86MSByte(b)) + uint8_t b = p[4 - kMaskToBitNumber[prevMask]]; + if (!kMaskToAllowedStatus[prevMask] || Test86MSuint8_t(b)) { prevPosT = bufferPos; prevMask = ((prevMask << 1) & 0x7) | 1; @@ -47,30 +48,30 @@ SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding } prevPosT = bufferPos; - if (Test86MSByte(p[4])) + if (Test86MSuint8_t(p[4])) { - UInt32 src = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]); - UInt32 dest; + uint32_t src = ((uint32_t)p[4] << 24) | ((uint32_t)p[3] << 16) | ((uint32_t)p[2] << 8) | ((uint32_t)p[1]); + uint32_t dest; for (;;) { - Byte b; + uint8_t b; int index; if (encoding) - dest = (ip + (UInt32)bufferPos) + src; + dest = (ip + (uint32_t)bufferPos) + src; else - dest = src - (ip + (UInt32)bufferPos); + dest = src - (ip + (uint32_t)bufferPos); if (prevMask == 0) break; index = kMaskToBitNumber[prevMask] * 8; - b = (Byte)(dest >> (24 - index)); - if (!Test86MSByte(b)) + b = (uint8_t)(dest >> (24 - index)); + if (!Test86MSuint8_t(b)) break; src = dest ^ ((1 << (32 - index)) - 1); } - p[4] = (Byte)(~(((dest >> 24) & 1) - 1)); - p[3] = (Byte)(dest >> 16); - p[2] = (Byte)(dest >> 8); - p[1] = (Byte)dest; + p[4] = (uint8_t)(~(((dest >> 24) & 1) - 1)); + p[3] = (uint8_t)(dest >> 16); + p[2] = (uint8_t)(dest >> 8); + p[1] = (uint8_t)dest; bufferPos += 5; } else diff --git a/deps/7zip/CpuArch.c b/deps/7zip/CpuArch.c index 4490e8f401..36d5d6b48e 100755 --- a/deps/7zip/CpuArch.c +++ b/deps/7zip/CpuArch.c @@ -1,3 +1,4 @@ +#include <stdint.h> #include "CpuArch.h" Bool CPU_Is_InOrder(void); diff --git a/deps/7zip/CpuArch.h b/deps/7zip/CpuArch.h index 0cbd8a98b9..cac72b818e 100755 --- a/deps/7zip/CpuArch.h +++ b/deps/7zip/CpuArch.h @@ -62,38 +62,38 @@ Stop_Compiling_Bad_Endian #ifdef MY_CPU_LE_UNALIGN -#define GetUi16(p) (*(const UInt16 *)(p)) -#define GetUi32(p) (*(const UInt32 *)(p)) -#define GetUi64(p) (*(const UInt64 *)(p)) -#define SetUi16(p, d) *(UInt16 *)(p) = (d); -#define SetUi32(p, d) *(UInt32 *)(p) = (d); -#define SetUi64(p, d) *(UInt64 *)(p) = (d); +#define GetUi16(p) (*(const uint16_t *)(p)) +#define GetUi32(p) (*(const uint32_t *)(p)) +#define GetUi64(p) (*(const uint64_t *)(p)) +#define SetUi16(p, d) *(uint16_t *)(p) = (d); +#define SetUi32(p, d) *(uint32_t *)(p) = (d); +#define SetUi64(p, d) *(uint64_t *)(p) = (d); #else -#define GetUi16(p) (((const Byte *)(p))[0] | ((UInt16)((const Byte *)(p))[1] << 8)) +#define GetUi16(p) (((const uint8_t *)(p))[0] | ((uint16_t)((const uint8_t *)(p))[1] << 8)) #define GetUi32(p) ( \ - ((const Byte *)(p))[0] | \ - ((UInt32)((const Byte *)(p))[1] << 8) | \ - ((UInt32)((const Byte *)(p))[2] << 16) | \ - ((UInt32)((const Byte *)(p))[3] << 24)) + ((const uint8_t *)(p))[0] | \ + ((uint32_t)((const uint8_t *)(p))[1] << 8) | \ + ((uint32_t)((const uint8_t *)(p))[2] << 16) | \ + ((uint32_t)((const uint8_t *)(p))[3] << 24)) -#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32)) +#define GetUi64(p) (GetUi32(p) | ((uint64_t)GetUi32(((const uint8_t *)(p)) + 4) << 32)) -#define SetUi16(p, d) { UInt32 _x_ = (d); \ - ((Byte *)(p))[0] = (Byte)_x_; \ - ((Byte *)(p))[1] = (Byte)(_x_ >> 8); } +#define SetUi16(p, d) { uint32_t _x_ = (d); \ + ((uint8_t *)(p))[0] = (uint8_t)_x_; \ + ((uint8_t *)(p))[1] = (uint8_t)(_x_ >> 8); } -#define SetUi32(p, d) { UInt32 _x_ = (d); \ - ((Byte *)(p))[0] = (Byte)_x_; \ - ((Byte *)(p))[1] = (Byte)(_x_ >> 8); \ - ((Byte *)(p))[2] = (Byte)(_x_ >> 16); \ - ((Byte *)(p))[3] = (Byte)(_x_ >> 24); } +#define SetUi32(p, d) { uint32_t _x_ = (d); \ + ((uint8_t *)(p))[0] = (uint8_t)_x_; \ + ((uint8_t *)(p))[1] = (uint8_t)(_x_ >> 8); \ + ((uint8_t *)(p))[2] = (uint8_t)(_x_ >> 16); \ + ((uint8_t *)(p))[3] = (uint8_t)(_x_ >> 24); } -#define SetUi64(p, d) { UInt64 _x64_ = (d); \ - SetUi32(p, (UInt32)_x64_); \ - SetUi32(((Byte *)(p)) + 4, (UInt32)(_x64_ >> 32)); } +#define SetUi64(p, d) { uint64_t _x64_ = (d); \ + SetUi32(p, (uint32_t)_x64_); \ + SetUi32(((uint8_t *)(p)) + 4, (uint32_t)(_x64_ >> 32)); } #endif @@ -101,22 +101,22 @@ Stop_Compiling_Bad_Endian #pragma intrinsic(_byteswap_ulong) #pragma intrinsic(_byteswap_uint64) -#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p)) -#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p)) +#define GetBe32(p) _byteswap_ulong(*(const uint32_t *)(const uint8_t *)(p)) +#define GetBe64(p) _byteswap_uint64(*(const uint64_t *)(const uint8_t *)(p)) #else #define GetBe32(p) ( \ - ((UInt32)((const Byte *)(p))[0] << 24) | \ - ((UInt32)((const Byte *)(p))[1] << 16) | \ - ((UInt32)((const Byte *)(p))[2] << 8) | \ - ((const Byte *)(p))[3] ) + ((uint32_t)((const uint8_t *)(p))[0] << 24) | \ + ((uint32_t)((const uint8_t *)(p))[1] << 16) | \ + ((uint32_t)((const uint8_t *)(p))[2] << 8) | \ + ((const uint8_t *)(p))[3] ) -#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4)) +#define GetBe64(p) (((uint64_t)GetBe32(p) << 32) | GetBe32(((const uint8_t *)(p)) + 4)) #endif -#define GetBe16(p) (((UInt16)((const Byte *)(p))[0] << 8) | ((const Byte *)(p))[1]) +#define GetBe16(p) (((uint16_t)((const uint8_t *)(p))[0] << 8) | ((const uint8_t *)(p))[1]) Bool CPU_Is_InOrder(); diff --git a/deps/7zip/Lzma2Dec.c b/deps/7zip/Lzma2Dec.c index 7bfbc6b882..6819d6fdf3 100755 --- a/deps/7zip/Lzma2Dec.c +++ b/deps/7zip/Lzma2Dec.c @@ -1,12 +1,7 @@ /* Lzma2Dec.c -- LZMA2 Decoder 2009-05-03 : Igor Pavlov : Public domain */ -/* #define SHOW_DEBUG_INFO */ - -#ifdef SHOW_DEBUG_INFO -#include <stdio.h> -#endif - +#include <stdint.h> #include <string.h> #include "Lzma2Dec.h" @@ -36,13 +31,9 @@ #define LZMA2_IS_THERE_PROP(mode) ((mode) >= 2) #define LZMA2_LCLP_MAX 4 -#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11)) +#define LZMA2_DIC_SIZE_FROM_PROP(p) (((uint32_t)2 | ((p) & 1)) << ((p) / 2 + 11)) -#ifdef SHOW_DEBUG_INFO -#define PRF(x) x -#else #define PRF(x) -#endif typedef enum { @@ -58,30 +49,30 @@ typedef enum LZMA2_STATE_ERROR } ELzma2State; -static SRes Lzma2Dec_GetOldProps(Byte prop, Byte *props) +static SRes Lzma2Dec_GetOldProps(uint8_t prop, uint8_t *props) { - UInt32 dicSize; + uint32_t dicSize; if (prop > 40) return SZ_ERROR_UNSUPPORTED; dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop); - props[0] = (Byte)LZMA2_LCLP_MAX; - props[1] = (Byte)(dicSize); - props[2] = (Byte)(dicSize >> 8); - props[3] = (Byte)(dicSize >> 16); - props[4] = (Byte)(dicSize >> 24); + props[0] = (uint8_t)LZMA2_LCLP_MAX; + props[1] = (uint8_t)(dicSize); + props[2] = (uint8_t)(dicSize >> 8); + props[3] = (uint8_t)(dicSize >> 16); + props[4] = (uint8_t)(dicSize >> 24); return SZ_OK; } -SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAlloc *alloc) +SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) { - Byte props[LZMA_PROPS_SIZE]; + uint8_t props[LZMA_PROPS_SIZE]; RINOK(Lzma2Dec_GetOldProps(prop, props)); return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc); } -SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAlloc *alloc) +SRes Lzma2Dec_Allocate(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) { - Byte props[LZMA_PROPS_SIZE]; + uint8_t props[LZMA_PROPS_SIZE]; RINOK(Lzma2Dec_GetOldProps(prop, props)); return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc); } @@ -95,7 +86,7 @@ void Lzma2Dec_Init(CLzma2Dec *p) LzmaDec_Init(&p->decoder); } -static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b) +static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, uint8_t b) { switch(p->state) { @@ -112,25 +103,25 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b) p->unpackSize = 0; } else - p->unpackSize = (UInt32)(p->control & 0x1F) << 16; + p->unpackSize = (uint32_t)(p->control & 0x1F) << 16; return LZMA2_STATE_UNPACK0; case LZMA2_STATE_UNPACK0: - p->unpackSize |= (UInt32)b << 8; + p->unpackSize |= (uint32_t)b << 8; return LZMA2_STATE_UNPACK1; case LZMA2_STATE_UNPACK1: - p->unpackSize |= (UInt32)b; + p->unpackSize |= (uint32_t)b; p->unpackSize++; PRF(printf(" %8d", p->unpackSize)); return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; case LZMA2_STATE_PACK0: - p->packSize = (UInt32)b << 8; + p->packSize = (uint32_t)b << 8; return LZMA2_STATE_PACK1; case LZMA2_STATE_PACK1: - p->packSize |= (UInt32)b; + p->packSize |= (uint32_t)b; p->packSize++; PRF(printf(" %8d", p->packSize)); return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP: @@ -156,27 +147,27 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b) return LZMA2_STATE_ERROR; } -static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const Byte *src, SizeT size) +static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const uint8_t *src, size_t size) { memcpy(p->dic + p->dicPos, src, size); p->dicPos += size; if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size) p->checkDicSize = p->prop.dicSize; - p->processedPos += (UInt32)size; + p->processedPos += (uint32_t)size; } void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState); -SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, size_t dicLimit, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) { - SizeT inSize = *srcLen; + size_t inSize = *srcLen; *srcLen = 0; *status = LZMA_STATUS_NOT_SPECIFIED; while (p->state != LZMA2_STATE_FINISHED) { - SizeT dicPos = p->decoder.dicPos; + size_t dicPos = p->decoder.dicPos; if (p->state == LZMA2_STATE_ERROR) return SZ_ERROR_DATA; if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY) @@ -196,13 +187,13 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, continue; } { - SizeT destSizeCur = dicLimit - dicPos; - SizeT srcSizeCur = inSize - *srcLen; + size_t destSizeCur = dicLimit - dicPos; + size_t srcSizeCur = inSize - *srcLen; ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; if (p->unpackSize <= destSizeCur) { - destSizeCur = (SizeT)p->unpackSize; + destSizeCur = (size_t)p->unpackSize; curFinishMode = LZMA_FINISH_END; } @@ -235,12 +226,12 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, src += srcSizeCur; *srcLen += srcSizeCur; - p->unpackSize -= (UInt32)srcSizeCur; + p->unpackSize -= (uint32_t)srcSizeCur; p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; } else { - SizeT outSizeProcessed; + size_t outSizeProcessed; SRes res; if (p->state == LZMA2_STATE_DATA) @@ -257,16 +248,16 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, p->state = LZMA2_STATE_DATA_CONT; } if (srcSizeCur > p->packSize) - srcSizeCur = (SizeT)p->packSize; + srcSizeCur = (size_t)p->packSize; res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status); src += srcSizeCur; *srcLen += srcSizeCur; - p->packSize -= (UInt32)srcSizeCur; + p->packSize -= (uint32_t)srcSizeCur; outSizeProcessed = p->decoder.dicPos - dicPos; - p->unpackSize -= (UInt32)outSizeProcessed; + p->unpackSize -= (uint32_t)outSizeProcessed; RINOK(res); if (*status == LZMA_STATUS_NEEDS_MORE_INPUT) @@ -288,13 +279,13 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, return SZ_OK; } -SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) { - SizeT outSize = *destLen, inSize = *srcLen; + size_t outSize = *destLen, inSize = *srcLen; *srcLen = *destLen = 0; for (;;) { - SizeT srcSizeCur = inSize, outSizeCur, dicPos; + size_t srcSizeCur = inSize, outSizeCur, dicPos; ELzmaFinishMode curFinishMode; SRes res; if (p->decoder.dicPos == p->decoder.dicBufSize) @@ -327,13 +318,13 @@ SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte * } } -SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) +SRes Lzma2Decode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + uint8_t prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) { CLzma2Dec decoder; SRes res; - SizeT outSize = *destLen, inSize = *srcLen; - Byte props[LZMA_PROPS_SIZE]; + size_t outSize = *destLen, inSize = *srcLen; + uint8_t props[LZMA_PROPS_SIZE]; Lzma2Dec_Construct(&decoder); diff --git a/deps/7zip/Lzma2Dec.h b/deps/7zip/Lzma2Dec.h index 827698deeb..5affbf3fb0 100755 --- a/deps/7zip/Lzma2Dec.h +++ b/deps/7zip/Lzma2Dec.h @@ -15,10 +15,10 @@ extern "C" { typedef struct { CLzmaDec decoder; - UInt32 packSize; - UInt32 unpackSize; + uint32_t packSize; + uint32_t unpackSize; int state; - Byte control; + uint8_t control; Bool needInitDic; Bool needInitState; Bool needInitProp; @@ -28,8 +28,8 @@ typedef struct #define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc); #define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc); -SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAlloc *alloc); -SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAlloc *alloc); +SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc); +SRes Lzma2Dec_Allocate(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc); void Lzma2Dec_Init(CLzma2Dec *p); @@ -48,11 +48,11 @@ Returns: SZ_ERROR_DATA - Data error */ -SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); +SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, size_t dicLimit, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); -SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); +SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, uint8_t *dest, size_t *destLen, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); /* ---------- One Call Interface ---------- */ @@ -74,8 +74,8 @@ Returns: SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). */ -SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); +SRes Lzma2Decode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + uint8_t prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); #ifdef __cplusplus } diff --git a/deps/7zip/LzmaDec.c b/deps/7zip/LzmaDec.c index 06dc7045e5..28d726f7b8 100755 --- a/deps/7zip/LzmaDec.c +++ b/deps/7zip/LzmaDec.c @@ -1,12 +1,13 @@ /* LzmaDec.c -- LZMA Decoder 2009-09-20 : Igor Pavlov : Public domain */ +#include <stdint.h> +#include <string.h> #include "LzmaDec.h" -#include <string.h> #define kNumTopBits 24 -#define kTopValue ((UInt32)1 << kNumTopBits) +#define kTopValue ((uint32_t)1 << kNumTopBits) #define kNumBitModelTotalBits 11 #define kBitModelTotal (1 << kNumBitModelTotalBits) @@ -17,8 +18,8 @@ #define LZMADEC_NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); } #define LZMADEC_IF_BIT_0(p) ttt = *(p); LZMADEC_NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) -#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); -#define LZMADEC_UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); +#define UPDATE_0(p) range = bound; *(p) = (uint16_t)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); +#define LZMADEC_UPDATE_1(p) range -= bound; code -= bound; *(p) = (uint16_t)(ttt - (ttt >> kNumMoveBits)); #define GET_BIT2(p, i, A0, A1) LZMADEC_IF_BIT_0(p) \ { UPDATE_0(p); i = (i + i); A0; } else \ { LZMADEC_UPDATE_1(p); i = (i + i) + 1; A1; } @@ -107,7 +108,7 @@ #define LZMA_BASE_SIZE 1846 #define LZMA_LIT_SIZE 768 -#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) +#define LzmaProps_GetNumProbs(p) ((uint32_t)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) #if Literal != LZMA_BASE_SIZE StopCompilingDueBUG @@ -128,32 +129,32 @@ StopCompilingDueBUG = kMatchSpecLenStart + 2 : State Init Marker */ -static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit) +static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, size_t limit, const uint8_t *bufLimit) { - CLzmaProb *probs = p->probs; + uint16_t *probs = p->probs; unsigned state = p->state; - UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; + uint32_t rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; unsigned lc = p->prop.lc; - Byte *dic = p->dic; - SizeT dicBufSize = p->dicBufSize; - SizeT dicPos = p->dicPos; + uint8_t *dic = p->dic; + size_t dicBufSize = p->dicBufSize; + size_t dicPos = p->dicPos; - UInt32 processedPos = p->processedPos; - UInt32 checkDicSize = p->checkDicSize; + uint32_t processedPos = p->processedPos; + uint32_t checkDicSize = p->checkDicSize; unsigned len = 0; - const Byte *buf = p->buf; - UInt32 range = p->range; - UInt32 code = p->code; + const uint8_t *buf = p->buf; + uint32_t range = p->range; + uint32_t code = p->code; do { - CLzmaProb *prob; - UInt32 bound; + uint16_t *prob; + uint32_t bound; unsigned ttt; unsigned posState = processedPos & pbMask; @@ -175,22 +176,22 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte } else { - unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; + unsigned matchuint8_t = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; unsigned offs = 0x100; state -= (state < 10) ? 3 : 6; symbol = 1; do { unsigned bit; - CLzmaProb *probLit; - matchByte <<= 1; - bit = (matchByte & offs); + uint16_t *probLit; + matchuint8_t <<= 1; + bit = (matchuint8_t & offs); probLit = prob + offs + bit + symbol; GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) } while (symbol < 0x100); } - dic[dicPos++] = (Byte)symbol; + dic[dicPos++] = (uint8_t)symbol; processedPos++; continue; } @@ -227,7 +228,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte } else { - UInt32 distance; + uint32_t distance; LZMADEC_UPDATE_1(prob); prob = probs + IsRepG1 + state; LZMADEC_IF_BIT_0(prob) @@ -260,7 +261,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte } { unsigned limit, offset; - CLzmaProb *probLen = prob + LenChoice; + uint16_t *probLen = prob + LenChoice; LZMADEC_IF_BIT_0(probLen) { UPDATE_0(probLen); @@ -293,7 +294,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte if (state >= kNumStates) { - UInt32 distance; + uint32_t distance; prob = probs + PosSlot + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); TREE_6_DECODE(prob, distance); @@ -307,7 +308,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte distance <<= numDirectBits; prob = probs + SpecPos + distance - posSlot - 1; { - UInt32 mask = 1; + uint32_t mask = 1; unsigned i = 1; do { @@ -326,9 +327,9 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte range >>= 1; { - UInt32 t; + uint32_t t; code -= range; - t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */ + t = (0 - ((uint32_t)code >> 31)); /* (uint32_t)((Int32)code >> 31) */ distance = (distance << 1) + (t + 1); code += range & t; } @@ -351,7 +352,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte GET_BIT2(prob + i, i, ; , distance |= 4); GET_BIT2(prob + i, i, ; , distance |= 8); } - if (distance == (UInt32)0xFFFFFFFF) + if (distance == (uint32_t)0xFFFFFFFF) { len += kMatchSpecLenStart; state -= kNumStates; @@ -378,21 +379,21 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte if (limit == dicPos) return SZ_ERROR_DATA; { - SizeT rem = limit - dicPos; + size_t rem = limit - dicPos; unsigned curLen = ((rem < len) ? (unsigned)rem : len); - SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); + size_t pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); processedPos += curLen; len -= curLen; if (pos + curLen <= dicBufSize) { - Byte *dest = dic + dicPos; + uint8_t *dest = dic + dicPos; ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; - const Byte *lim = dest + curLen; + const uint8_t *lim = dest + curLen; dicPos += curLen; do - *(dest) = (Byte)*(dest + src); + *(dest) = (uint8_t)*(dest + src); while (++dest != lim); } else @@ -425,15 +426,15 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte return SZ_OK; } -static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) +static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, size_t limit) { if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) { - Byte *dic = p->dic; - SizeT dicPos = p->dicPos; - SizeT dicBufSize = p->dicBufSize; + uint8_t *dic = p->dic; + size_t dicPos = p->dicPos; + size_t dicBufSize = p->dicBufSize; unsigned len = p->remainLen; - UInt32 rep0 = p->reps[0]; + uint32_t rep0 = p->reps[0]; if (limit - dicPos < len) len = (unsigned)(limit - dicPos); @@ -451,14 +452,14 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) } } -static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) +static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, size_t limit, const uint8_t *bufLimit) { do { - SizeT limit2 = limit; + size_t limit2 = limit; if (p->checkDicSize == 0) { - UInt32 rem = p->prop.dicSize - p->processedPos; + uint32_t rem = p->prop.dicSize - p->processedPos; if (limit - p->dicPos > rem) limit2 = p->dicPos + rem; } @@ -484,18 +485,18 @@ typedef enum DUMMY_REP } ELzmaDummy; -static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize) +static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const uint8_t *buf, size_t inSize) { - UInt32 range = p->range; - UInt32 code = p->code; - const Byte *bufLimit = buf + inSize; - CLzmaProb *probs = p->probs; + uint32_t range = p->range; + uint32_t code = p->code; + const uint8_t *bufLimit = buf + inSize; + uint16_t *probs = p->probs; unsigned state = p->state; ELzmaDummy res; { - CLzmaProb *prob; - UInt32 bound; + uint16_t *prob; + uint32_t bound; unsigned ttt; unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); @@ -519,16 +520,16 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS } else { - unsigned matchByte = p->dic[p->dicPos - p->reps[0] + + unsigned matchuint8_t = p->dic[p->dicPos - p->reps[0] + ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; unsigned offs = 0x100; unsigned symbol = 1; do { unsigned bit; - CLzmaProb *probLit; - matchByte <<= 1; - bit = (matchByte & offs); + uint16_t *probLit; + matchuint8_t <<= 1; + bit = (matchuint8_t & offs); probLit = prob + offs + bit + symbol; GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) } @@ -596,7 +597,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS } { unsigned limit, offset; - CLzmaProb *probLen = prob + LenChoice; + uint16_t *probLen = prob + LenChoice; IF_BIT_0_CHECK(probLen) { UPDATE_0_CHECK; @@ -675,9 +676,9 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS } -static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data) +static void LzmaDec_InitRc(CLzmaDec *p, const uint8_t *data) { - p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]); + p->code = ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 8) | ((uint32_t)data[4]); p->range = 0xFFFFFFFF; p->needFlush = 0; } @@ -708,9 +709,9 @@ void LzmaDec_Init(CLzmaDec *p) static void LzmaDec_InitStateReal(CLzmaDec *p) { - UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); - UInt32 i; - CLzmaProb *probs = p->probs; + uint32_t numProbs = Literal + ((uint32_t)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); + uint32_t i; + uint16_t *probs = p->probs; for (i = 0; i < numProbs; i++) probs[i] = kBitModelTotal >> 1; p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; @@ -718,10 +719,10 @@ static void LzmaDec_InitStateReal(CLzmaDec *p) p->needInitState = 0; } -SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, +SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) { - SizeT inSize = *srcLen; + size_t inSize = *srcLen; (*srcLen) = 0; LzmaDec_WriteRem(p, dicLimit); @@ -773,8 +774,8 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr if (p->tempBufSize == 0) { - SizeT processed; - const Byte *bufLimit; + size_t processed; + const uint8_t *bufLimit; if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) { int dummyRes = LzmaDec_TryDummy(p, src, inSize); @@ -798,7 +799,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr p->buf = src; if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) return SZ_ERROR_DATA; - processed = (SizeT)(p->buf - src); + processed = (size_t)(p->buf - src); (*srcLen) += processed; src += processed; inSize -= processed; @@ -839,14 +840,14 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; } -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) { - SizeT outSize = *destLen; - SizeT inSize = *srcLen; + size_t outSize = *destLen; + size_t inSize = *srcLen; *srcLen = *destLen = 0; for (;;) { - SizeT inSizeCur = inSize, outSizeCur, dicPos; + size_t inSizeCur = inSize, outSizeCur, dicPos; ELzmaFinishMode curFinishMode; SRes res; if (p->dicPos == p->dicBufSize) @@ -897,15 +898,15 @@ void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) LzmaDec_FreeDict(p, alloc); } -SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) +SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size) { - UInt32 dicSize; - Byte d; + uint32_t dicSize; + uint8_t d; if (size < LZMA_PROPS_SIZE) return SZ_ERROR_UNSUPPORTED; else - dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); + dicSize = data[1] | ((uint32_t)data[2] << 8) | ((uint32_t)data[3] << 16) | ((uint32_t)data[4] << 24); if (dicSize < LZMA_DIC_MIN) dicSize = LZMA_DIC_MIN; @@ -925,11 +926,11 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) { - UInt32 numProbs = LzmaProps_GetNumProbs(propNew); + uint32_t numProbs = LzmaProps_GetNumProbs(propNew); if (p->probs == 0 || numProbs != p->numProbs) { LzmaDec_FreeProbs(p, alloc); - p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb)); + p->probs = (uint16_t *)alloc->Alloc(alloc, numProbs * sizeof(uint16_t)); p->numProbs = numProbs; if (p->probs == 0) return SZ_ERROR_MEM; @@ -937,7 +938,7 @@ static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAl return SZ_OK; } -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) +SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc) { CLzmaProps propNew; RINOK(LzmaProps_Decode(&propNew, props, propsSize)); @@ -946,17 +947,17 @@ SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, I return SZ_OK; } -SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) +SRes LzmaDec_Allocate(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc) { CLzmaProps propNew; - SizeT dicBufSize; + size_t dicBufSize; RINOK(LzmaProps_Decode(&propNew, props, propsSize)); RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); dicBufSize = propNew.dicSize; if (p->dic == 0 || dicBufSize != p->dicBufSize) { LzmaDec_FreeDict(p, alloc); - p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); + p->dic = (uint8_t *)alloc->Alloc(alloc, dicBufSize); if (p->dic == 0) { LzmaDec_FreeProbs(p, alloc); @@ -968,14 +969,14 @@ SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAll return SZ_OK; } -SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, +SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) { CLzmaDec p; SRes res; - SizeT inSize = *srcLen; - SizeT outSize = *destLen; + size_t inSize = *srcLen; + size_t outSize = *destLen; *srcLen = *destLen = 0; if (inSize < RC_INIT_SIZE) return SZ_ERROR_INPUT_EOF; diff --git a/deps/7zip/LzmaDec.h b/deps/7zip/LzmaDec.h index 19eaab3b90..30fd5a7da3 100755 --- a/deps/7zip/LzmaDec.h +++ b/deps/7zip/LzmaDec.h @@ -10,25 +10,14 @@ extern "C" { #endif - /* #define _LZMA_PROB32 */ - /* _LZMA_PROB32 can increase the speed on some CPUs, - but memory usage for CLzmaDec::probs will be doubled in that case */ - -#ifdef _LZMA_PROB32 -#define CLzmaProb UInt32 -#else -#define CLzmaProb UInt16 -#endif - - - /* ---------- LZMA Properties ---------- */ +/* ---------- LZMA Properties ---------- */ #define LZMA_PROPS_SIZE 5 typedef struct _CLzmaProps { unsigned lc, lp, pb; - UInt32 dicSize; + uint32_t dicSize; } CLzmaProps; /* LzmaProps_Decode - decodes properties @@ -37,7 +26,7 @@ SZ_OK SZ_ERROR_UNSUPPORTED - Unsupported properties */ - SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size); + SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size); /* ---------- LZMA Decoder state ---------- */ @@ -50,22 +39,22 @@ SZ_ERROR_UNSUPPORTED - Unsupported properties typedef struct { CLzmaProps prop; - CLzmaProb *probs; - Byte *dic; - const Byte *buf; - UInt32 range, code; - SizeT dicPos; - SizeT dicBufSize; - UInt32 processedPos; - UInt32 checkDicSize; + uint16_t *probs; + uint8_t *dic; + const uint8_t *buf; + uint32_t range, code; + size_t dicPos; + size_t dicBufSize; + uint32_t processedPos; + uint32_t checkDicSize; unsigned state; - UInt32 reps[4]; + uint32_t reps[4]; unsigned remainLen; int needFlush; int needInitState; - UInt32 numProbs; + uint32_t numProbs; unsigned tempBufSize; - Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; + uint8_t tempBuf[LZMA_REQUIRED_INPUT_MAX]; } CLzmaDec; #define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } @@ -131,10 +120,10 @@ SZ_ERROR_UNSUPPORTED - Unsupported properties SZ_ERROR_UNSUPPORTED - Unsupported properties */ - SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc); + SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc); void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); - SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc); + SRes LzmaDec_Allocate(CLzmaDec *state, const uint8_t *prop, unsigned propsSize, ISzAlloc *alloc); void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); /* ---------- Dictionary Interface ---------- */ @@ -178,8 +167,8 @@ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK SZ_ERROR_DATA - Data error */ - SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); /* ---------- Buffer Interface ---------- */ @@ -195,8 +184,8 @@ LZMA_FINISH_ANY - Decode just destLen bytes. LZMA_FINISH_END - Stream must be finished after (*destLen). */ -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); +SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); /* ---------- One Call Interface ---------- */ @@ -220,8 +209,8 @@ SZ_ERROR_UNSUPPORTED - Unsupported properties SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). */ -SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, +SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); #ifdef __cplusplus diff --git a/deps/7zip/Types.h b/deps/7zip/Types.h index 3f2ce08f2d..e29dd3eb42 100755 --- a/deps/7zip/Types.h +++ b/deps/7zip/Types.h @@ -52,46 +52,18 @@ typedef int WRes; #define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } #endif -typedef unsigned char Byte; -typedef short Int16; -typedef unsigned short UInt16; - -#ifdef _LZMA_UINT32_IS_ULONG -typedef long Int32; -typedef unsigned long UInt32; -#else -typedef int Int32; -typedef unsigned int UInt32; -#endif - #ifdef _SZ_NO_INT_64 -/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers. -NOTES: Some code will work incorrectly in that case! */ - -typedef long Int64; -typedef unsigned long UInt64; - #else #if defined(_MSC_VER) || defined(__BORLANDC__) -typedef __int64 Int64; -typedef unsigned __int64 UInt64; #define UINT64_CONST(n) n #else -typedef long long int Int64; -typedef unsigned long long int UInt64; #define UINT64_CONST(n) n ## ULL #endif #endif -#ifdef _LZMA_NO_SYSTEM_SIZE_T -typedef UInt32 SizeT; -#else -typedef size_t SizeT; -#endif - typedef int Bool; #define True 1 #define False 0 @@ -126,12 +98,12 @@ typedef int Bool; typedef struct { - Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */ + uint8_t (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */ } IByteIn; typedef struct { - void (*Write)(void *p, Byte b); + void (*Write)(void *p, uint8_t b); } IByteOut; typedef struct @@ -144,7 +116,7 @@ typedef struct /* it can return SZ_ERROR_INPUT_EOF */ SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size); SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType); -SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf); +SRes SeqInStream_ReadByte(ISeqInStream *stream, uint8_t *buf); typedef struct { @@ -163,7 +135,7 @@ typedef enum typedef struct { SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */ - SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); + SRes (*Seek)(void *p, int64_t *pos, ESzSeek origin); } ISeekInStream; typedef struct @@ -177,11 +149,11 @@ typedef struct SRes (*Read)(void *p, void *buf, size_t *size); /* reads directly (without buffer). It's same as ISeqInStream::Read */ - SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); + SRes (*Seek)(void *p, int64_t *pos, ESzSeek origin); } ILookInStream; SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size); -SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset); +SRes LookInStream_SeekTo(ILookInStream *stream, uint64_t offset); /* reads via ILookInStream::Read */ SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType); @@ -195,7 +167,7 @@ typedef struct ISeekInStream *realStream; size_t pos; size_t size; - Byte buf[LookToRead_BUF_SIZE]; + uint8_t buf[LookToRead_BUF_SIZE]; } CLookToRead; void LookToRead_CreateVTable(CLookToRead *p, int lookahead); @@ -219,9 +191,9 @@ void SecToRead_CreateVTable(CSecToRead *p); typedef struct { - SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize); + SRes (*Progress)(void *p, uint64_t inSize, uint64_t outSize); /* Returns: result. (result != SZ_OK) means break. - Value (UInt64)(Int64)-1 for size means unknown value. */ + Value (uint64_t)(int64_t)-1 for size means unknown value. */ } ICompressProgress; typedef struct