aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLadislav Zezula <zezula@volny.cz>2020-11-23 12:56:00 +0100
committerLadislav Zezula <zezula@volny.cz>2020-11-23 12:56:00 +0100
commitb6102b2600f792f159320439686a872a72d20c70 (patch)
treea9cfacadc0c28b3cfde908d2a4511b6605a648a0 /src
parent809005c7f025bcc55bfa4ede78cb4cc45d3c0e6c (diff)
Removed trailing whitespace
Diffstat (limited to 'src')
-rw-r--r--src/DllMain.def16
-rw-r--r--src/DllMain.rc6
-rw-r--r--src/FileStream.cpp48
-rw-r--r--src/FileStream.h2
-rw-r--r--src/SBaseCommon.cpp124
-rw-r--r--src/SBaseDumpData.cpp10
-rw-r--r--src/SBaseFileTable.cpp56
-rw-r--r--src/SBaseSubTypes.cpp34
-rw-r--r--src/SCompression.cpp34
-rw-r--r--src/SFileAddFile.cpp40
-rw-r--r--src/SFileAttributes.cpp6
-rw-r--r--src/SFileCompactArchive.cpp10
-rw-r--r--src/SFileCreateArchive.cpp4
-rw-r--r--src/SFileFindFile.cpp4
-rw-r--r--src/SFileGetFileInfo.cpp6
-rw-r--r--src/SFileListFile.cpp12
-rw-r--r--src/SFileOpenArchive.cpp4
-rw-r--r--src/SFileOpenFileEx.cpp10
-rw-r--r--src/SFilePatchArchives.cpp40
-rw-r--r--src/SFileReadFile.cpp18
-rw-r--r--src/SFileVerify.cpp14
-rw-r--r--src/StormCommon.h2
-rw-r--r--src/StormLib.h58
-rw-r--r--src/adpcm/adpcm.cpp10
-rw-r--r--src/huffman/huff.cpp84
-rw-r--r--src/huffman/huff.h26
-rw-r--r--src/pklib/explode.c22
-rw-r--r--src/pklib/implode.c24
-rw-r--r--src/pklib/pklib.h20
-rw-r--r--src/resource.h2
-rw-r--r--src/sparse/sparse.cpp12
31 files changed, 379 insertions, 379 deletions
diff --git a/src/DllMain.def b/src/DllMain.def
index 440b3e0..bce2877 100644
--- a/src/DllMain.def
+++ b/src/DllMain.def
@@ -21,23 +21,23 @@ EXPORTS
SFileSetCompactCallback
SFileCompactArchive
-
+
SFileGetMaxFileCount
- SFileSetMaxFileCount
-
+ SFileSetMaxFileCount
+
SFileGetAttributes
SFileSetAttributes
SFileUpdateFileAttributes
SFileOpenPatchArchive
SFileIsPatchedArchive
-
+
SFileOpenFileEx
SFileGetFileSize
SFileSetFilePointer
SFileReadFile
SFileCloseFile
-
+
SFileHasFile
SFileGetFileName
SFileGetFileInfo
@@ -57,7 +57,7 @@ EXPORTS
SListFileFindClose
SFileEnumLocales
-
+
SFileCreateFile
SFileWriteFile
SFileFinishFile
@@ -72,8 +72,8 @@ EXPORTS
SCompImplode
SCompExplode
- SCompCompress
- SCompDecompress
+ SCompCompress
+ SCompDecompress
GetLastError=Kernel32.GetLastError
SetLastError=Kernel32.SetLastError
diff --git a/src/DllMain.rc b/src/DllMain.rc
index ddfe3c3..27f43e2 100644
--- a/src/DllMain.rc
+++ b/src/DllMain.rc
@@ -78,19 +78,19 @@ LANGUAGE LANG_CZECH, SUBLANG_DEFAULT
// TEXTINCLUDE
//
-2 TEXTINCLUDE
+2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
-3 TEXTINCLUDE
+3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
-1 TEXTINCLUDE
+1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
diff --git a/src/FileStream.cpp b/src/FileStream.cpp
index 06f7627..a7b3e6a 100644
--- a/src/FileStream.cpp
+++ b/src/FileStream.cpp
@@ -108,14 +108,14 @@ static bool BaseFile_Create(TFileStream * pStream)
#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
{
intptr_t handle;
-
+
handle = open(pStream->szFileName, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if(handle == -1)
{
nLastError = errno;
return false;
}
-
+
pStream->Base.File.hFile = (HANDLE)handle;
}
#endif
@@ -244,7 +244,7 @@ static bool BaseFile_Read(
nLastError = errno;
return false;
}
-
+
dwBytesRead = (DWORD)(size_t)bytes_read;
}
}
@@ -313,7 +313,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const
nLastError = errno;
return false;
}
-
+
dwBytesWritten = (DWORD)(size_t)bytes_written;
}
#endif
@@ -360,7 +360,7 @@ static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize)
return bResult;
}
#endif
-
+
#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) || defined(STORMLIB_HAIKU)
{
if(ftruncate64((intptr_t)pStream->Base.File.hFile, (off64_t)NewFileSize) == -1)
@@ -368,7 +368,7 @@ static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize)
nLastError = errno;
return false;
}
-
+
pStream->Base.File.FileSize = NewFileSize;
return true;
}
@@ -412,7 +412,7 @@ static bool BaseFile_Replace(TFileStream * pStream, TFileStream * pNewStream)
nLastError = errno;
return false;
}
-
+
return true;
#endif
}
@@ -472,7 +472,7 @@ static bool RetrieveFileMappingSize(HANDLE hSection, ULARGE_INTEGER & RefFileSiz
NTQUERYSECTION PfnQuerySection;
HMODULE hNtdll;
SIZE_T ReturnLength = 0;
-
+
if((hNtdll = GetModuleHandle(_T("ntdll.dll"))) != NULL)
{
PfnQuerySection = (NTQUERYSECTION)GetProcAddress(hNtdll, "NtQuerySection");
@@ -817,7 +817,7 @@ static bool BaseHttp_Read(
// Add range request to the HTTP headers
// http://www.clevercomponents.com/articles/article015/resuming.asp
wsprintf(szRangeRequest, _T("Range: bytes=%u-%u"), (unsigned int)dwStartOffset, (unsigned int)dwEndOffset);
- HttpAddRequestHeaders(hRequest, szRangeRequest, 0xFFFFFFFF, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
+ HttpAddRequestHeaders(hRequest, szRangeRequest, 0xFFFFFFFF, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
// Send the request to the server
if(HttpSendRequest(hRequest, NULL, 0, NULL, 0))
@@ -1070,7 +1070,7 @@ static void BlockStream_Close(TBlockStream * pStream)
static STREAM_INIT StreamBaseInit[4] =
{
BaseFile_Init,
- BaseMap_Init,
+ BaseMap_Init,
BaseHttp_Init,
BaseNone_Init
};
@@ -1109,7 +1109,7 @@ static TFileStream * AllocateFileStream(
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
-
+
// Open the master file
pMaster = FileStream_OpenFile(szNextFile + 1, STREAM_FLAG_READ_ONLY);
}
@@ -1167,7 +1167,7 @@ static DWORD FlatStream_CheckFile(TBlockStream * pStream)
static bool FlatStream_LoadBitmap(TBlockStream * pStream)
{
FILE_BITMAP_FOOTER Footer;
- ULONGLONG ByteOffset;
+ ULONGLONG ByteOffset;
LPBYTE FileBitmap;
DWORD BlockCount;
DWORD BitmapSize;
@@ -1275,7 +1275,7 @@ static bool FlatStream_BlockCheck(
// Sanity checks
assert((BlockOffset & (pStream->BlockSize - 1)) == 0);
assert(FileBitmap != NULL);
-
+
// Calculate the index of the block
BlockIndex = (DWORD)(BlockOffset / pStream->BlockSize);
BitMask = (BYTE)(1 << (BlockIndex & 0x07));
@@ -1336,7 +1336,7 @@ static void FlatStream_Close(TBlockStream * pStream)
{
// Write the file bitmap
pStream->BaseWrite(pStream, &pStream->StreamSize, pStream->FileBitmap, pStream->BitmapSize);
-
+
// Prepare and write the file footer
Footer.Signature = ID_FILE_BITMAP_FOOTER;
Footer.Version = 3;
@@ -1431,7 +1431,7 @@ static bool FlatStream_CreateMirror(TBlockStream * pStream)
static TFileStream * FlatStream_Open(const TCHAR * szFileName, DWORD dwStreamFlags)
{
- TBlockStream * pStream;
+ TBlockStream * pStream;
ULONGLONG ByteOffset = 0;
// Create new empty stream
@@ -1655,7 +1655,7 @@ static bool PartStream_BlockCheck(
// Sanity checks
assert((BlockOffset & (pStream->BlockSize - 1)) == 0);
assert(pStream->FileBitmap != NULL);
-
+
// Calculate the block map entry
FileBitmap = (PPART_FILE_MAP_ENTRY)pStream->FileBitmap + (BlockOffset / pStream->BlockSize);
@@ -1751,7 +1751,7 @@ static void PartStream_Close(TBlockStream * pStream)
PartHeader.FileSizeHi = (DWORD)(pStream->StreamSize >> 0x20);
PartHeader.FileSizeLo = (DWORD)(pStream->StreamSize & 0xFFFFFFFF);
PartHeader.BlockSize = pStream->BlockSize;
-
+
// Make sure that the header is properly BSWAPed
BSWAP_ARRAY32_UNSIGNED(&PartHeader, sizeof(PART_FILE_HEADER));
IntToString(PartHeader.GameBuildNumber, _countof(PartHeader.GameBuildNumber), pStream->BuildNumber);
@@ -1916,7 +1916,7 @@ static const char * AuthCodeArray[] =
"S48B6CDTN5XEQAKQDJNDLJBJ73FDFM3U", // SC2 Heart of the Swarm-all : "expand 32-byte kQAKQ0000FM3UN5XE000073FD6CDT0000LJBJS48B0000DJND"
// Diablo III: Agent.exe (1.0.0.954)
- // Address of decryption routine: 00502b00
+ // Address of decryption routine: 00502b00
// Pointer to decryptor object: ECX
// Pointer to key: ECX+0x5C
// Authentication code URL: http://dist.blizzard.com/mediakey/d3-authenticationcode-enGB.txt
@@ -2022,7 +2022,7 @@ static void DecryptFileChunk(
KeyShuffled[0x04] = KeyMirror[0x0D];
KeyShuffled[0x01] = KeyMirror[0x0E];
KeyShuffled[0x00] = KeyMirror[0x0F];
-
+
// Shuffle the key - part 2
for(DWORD i = 0; i < RoundCount; i += 2)
{
@@ -2113,7 +2113,7 @@ static bool MpqeStream_DetectFileKey(TEncryptedStream * pStream)
// Prepare they decryption key from game serial number
CreateKeyFromAuthCode(pStream->Key, AuthCodeArray[i]);
- // Try to decrypt with the given key
+ // Try to decrypt with the given key
memcpy(FileHeader, EncryptedHeader, MPQE_CHUNK_SIZE);
DecryptFileChunk((LPDWORD)FileHeader, pStream->Key, ByteOffset, MPQE_CHUNK_SIZE);
@@ -2368,8 +2368,8 @@ static TFileStream * Block4Stream_Open(const TCHAR * szFileName, DWORD dwStreamF
assert(FileSize <= BLOCK4_MAX_FSIZE);
RemainderBlock = FileSize % (BLOCK4_BLOCK_SIZE + BLOCK4_HASH_SIZE);
BlockCount = FileSize / (BLOCK4_BLOCK_SIZE + BLOCK4_HASH_SIZE);
-
- // Increment the stream size and number of blocks
+
+ // Increment the stream size and number of blocks
pStream->StreamSize += (BlockCount * BLOCK4_BLOCK_SIZE);
pStream->BlockCount += (DWORD)BlockCount;
@@ -2586,7 +2586,7 @@ size_t FileStream_Prefix(const TCHAR * szFileName, DWORD * pdwProvider)
dwProvider |= BASE_PROVIDER_MAP;
nPrefixLength2 = 4;
}
-
+
else if(!_tcsnicmp(szFileName+nPrefixLength1, _T("http:"), 5))
{
dwProvider |= BASE_PROVIDER_HTTP;
@@ -2794,7 +2794,7 @@ bool FileStream_GetSize(TFileStream * pStream, ULONGLONG * pFileSize)
* \a NewFileSize File size to set
*/
bool FileStream_SetSize(TFileStream * pStream, ULONGLONG NewFileSize)
-{
+{
if(pStream->dwFlags & STREAM_FLAG_READ_ONLY)
{
SetLastError(ERROR_ACCESS_DENIED);
diff --git a/src/FileStream.h b/src/FileStream.h
index 44beeed..2bc118b 100644
--- a/src/FileStream.h
+++ b/src/FileStream.h
@@ -202,7 +202,7 @@ struct TBlockStream : public TFileStream
DWORD BlockCount; // Number of data blocks in the file
DWORD IsComplete; // If nonzero, no blocks are missing
DWORD IsModified; // nonzero if the bitmap has been modified
-};
+};
//-----------------------------------------------------------------------------
// Structure for encrypted stream
diff --git a/src/SBaseCommon.cpp b/src/SBaseCommon.cpp
index 97ebc59..28dc701 100644
--- a/src/SBaseCommon.cpp
+++ b/src/SBaseCommon.cpp
@@ -28,66 +28,66 @@ USHORT wPlatform = 0; // File platform
// Converts ASCII characters to lowercase
// Converts slash (0x2F) to backslash (0x5C)
-unsigned char AsciiToLowerTable[256] =
+unsigned char AsciiToLowerTable[256] =
{
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x10, 0x11, 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, 0x9E, 0x9F,
+ 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
+ 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
+ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
+ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
};
// Converts ASCII characters to uppercase
// Converts slash (0x2F) to backslash (0x5C)
-unsigned char AsciiToUpperTable[256] =
+unsigned char AsciiToUpperTable[256] =
{
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x5C,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D,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0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
+ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
};
// Converts ASCII characters to uppercase
// Does NOT convert slash (0x2F) to backslash (0x5C)
-unsigned char AsciiToUpperTable_Slash[256] =
+unsigned char AsciiToUpperTable_Slash[256] =
{
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
- 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
- 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
- 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0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E9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
};
@@ -105,7 +105,7 @@ char * StringCopy(char * szTarget, size_t cchTarget, const char * szSource)
if(cchSource >= cchTarget)
cchSource = cchTarget - 1;
-
+
memcpy(szTarget, szSource, cchSource);
szTarget[cchSource] = 0;
}
@@ -158,7 +158,7 @@ void StringCopy(TCHAR * szTarget, size_t cchTarget, const char * szSource)
if(cchSource >= cchTarget)
cchSource = cchTarget - 1;
-
+
mbstowcs(szTarget, szSource, cchSource);
szTarget[cchSource] = 0;
}
@@ -172,7 +172,7 @@ void StringCopy(char * szTarget, size_t cchTarget, const TCHAR * szSource)
if(cchSource >= cchTarget)
cchSource = cchTarget - 1;
-
+
wcstombs(szTarget, szSource, cchSource);
szTarget[cchSource] = 0;
}
@@ -186,7 +186,7 @@ void StringCopy(TCHAR * szTarget, size_t cchTarget, const TCHAR * szSource)
if(cchSource >= cchTarget)
cchSource = cchTarget - 1;
-
+
memcpy(szTarget, szSource, cchSource * sizeof(TCHAR));
szTarget[cchSource] = 0;
}
@@ -246,7 +246,7 @@ void InitializeMpqCryptography()
register_hash(&sha1_desc);
// Use LibTomMath as support math library for LibTomCrypt
- ltc_mp = ltm_desc;
+ ltc_mp = ltm_desc;
// Don't do that again
bMpqCryptographyInitialized = true;
@@ -255,7 +255,7 @@ void InitializeMpqCryptography()
//
// Note: Implementation of this function in WorldEdit.exe and storm.dll
-// incorrectly treats the character as signed, which leads to the
+// incorrectly treats the character as signed, which leads to the
// a buffer underflow if the character in the file name >= 0x80:
// The following steps happen when *pbKey == 0xBF and dwHashType == 0x0000
// (calculating hash index)
@@ -268,7 +268,7 @@ void InitializeMpqCryptography()
// As result, MPQs containing files with non-ANSI characters will not work between
// various game versions and localizations. Even WorldEdit, after importing a file
// with Korean characters in the name, cannot open the file back.
-//
+//
DWORD HashString(const char * szFileName, DWORD dwHashType)
{
LPBYTE pbKey = (BYTE *)szFileName;
@@ -448,7 +448,7 @@ void DecryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey1)
{
// Modify the second key
dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)];
-
+
DataBlock[i] = DataBlock[i] ^ (dwKey1 + dwKey2);
dwValue32 = DataBlock[i];
@@ -629,7 +629,7 @@ DWORD DecryptFileKey(
TMPQArchive * IsValidMpqHandle(HANDLE hMpq)
{
TMPQArchive * ha = (TMPQArchive *)hMpq;
-
+
return (ha != NULL && ha->pHeader != NULL && ha->pHeader->dwID == ID_MPQ) ? ha : NULL;
}
@@ -879,7 +879,7 @@ TMPQFile * CreateWritableHandle(TMPQArchive * ha, DWORD dwFileSize)
{
TempPos = FreeMpqSpace +
dwFileSize +
- (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)) +
+ (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)) +
(ha->dwFileTableSize * sizeof(TMPQBlock));
if((TempPos >> 32) != 0)
{
@@ -955,7 +955,7 @@ void * LoadMpqTable(
// Fill the extra data with zeros
dwBytesToRead = (DWORD)(FileSize - ByteOffset);
memset(pbMpqTable + dwBytesToRead, 0, (dwTableSize - dwBytesToRead));
-
+
// Give the caller information that the table was cut
if(pbTableIsCut != NULL)
pbTableIsCut[0] = true;
@@ -1145,7 +1145,7 @@ int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile)
// Calculate the number of file sectors
dwSectorOffsLen = (hf->dwSectorCount + 1) * sizeof(DWORD);
-
+
// If MPQ_FILE_SECTOR_CRC flag is set, there will either be extra DWORD
// or an array of MD5's. Either way, we read at least 4 bytes more
// in order to save additional read from the file.
@@ -1251,7 +1251,7 @@ int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile)
//
// These extra values are, however, include in the dwCmpSize in the file
// table. We cannot ignore them, because compacting archive would fail
- //
+ //
if(hf->SectorOffsets[0] > dwSectorOffsLen)
{
@@ -1298,7 +1298,7 @@ int AllocateSectorChecksums(TMPQFile * hf, bool bLoadFromFile)
// Caller must ensure that we are only called when we have sector checksums
assert(pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC);
- //
+ //
// Older MPQs store an array of CRC32's after
// the raw file data in the MPQ.
//
@@ -1338,7 +1338,7 @@ int AllocateSectorChecksums(TMPQFile * hf, bool bLoadFromFile)
// Calculate offset of the CRC table
dwCrcSize = hf->dwSectorCount * sizeof(DWORD);
dwCrcOffset = hf->SectorOffsets[hf->dwSectorCount];
- RawFilePos = CalculateRawSectorOffset(hf, dwCrcOffset);
+ RawFilePos = CalculateRawSectorOffset(hf, dwCrcOffset);
// Now read the table from the MPQ
hf->SectorChksums = (DWORD *)LoadMpqTable(ha, RawFilePos, dwCompressedSize, dwCrcSize, 0, NULL);
@@ -1394,7 +1394,7 @@ int WriteSectorOffsets(TMPQFile * hf)
// Write sector offsets to the archive
if(!FileStream_Write(ha->pStream, &RawFilePos, hf->SectorOffsets, dwSectorOffsLen))
return GetLastError();
-
+
// Not necessary, as the sector checksums
// are going to be freed when this is done.
// BSWAP_ARRAY32_UNSIGNED(hf->SectorOffsets, dwSectorOffsLen);
@@ -1452,7 +1452,7 @@ int WriteSectorChecksums(TMPQFile * hf)
// are going to be freed when this is done.
// BSWAP_ARRAY32_UNSIGNED(hf->SectorChksums, dwCrcSize);
- // Store the sector CRCs
+ // Store the sector CRCs
hf->SectorOffsets[hf->dwSectorCount + 1] = hf->SectorOffsets[hf->dwSectorCount] + dwCompressedSize;
pFileEntry->dwCmpSize += dwCompressedSize;
STORM_FREE(pbCompressed);
diff --git a/src/SBaseDumpData.cpp b/src/SBaseDumpData.cpp
index 2454f22..b08796a 100644
--- a/src/SBaseDumpData.cpp
+++ b/src/SBaseDumpData.cpp
@@ -69,14 +69,14 @@ void DumpHetAndBetTable(TMPQHetTable * pHetTable, TMPQBetTable * pBetTable)
return;
printf("== HET Header =================================\n");
- printf("ULONGLONG AndMask64 = %016llX\n", pHetTable->AndMask64);
- printf("ULONGLONG OrMask64 = %016llX\n", pHetTable->OrMask64);
+ printf("ULONGLONG AndMask64 = %016llX\n", pHetTable->AndMask64);
+ printf("ULONGLONG OrMask64 = %016llX\n", pHetTable->OrMask64);
printf("DWORD dwEntryCount = %08X\n", pHetTable->dwEntryCount);
printf("DWORD dwTotalCount = %08X\n", pHetTable->dwTotalCount);
printf("DWORD dwNameHashBitSize = %08X\n", pHetTable->dwNameHashBitSize);
printf("DWORD dwIndexSizeTotal = %08X\n", pHetTable->dwIndexSizeTotal);
printf("DWORD dwIndexSizeExtra = %08X\n", pHetTable->dwIndexSizeExtra);
- printf("DWORD dwIndexSize = %08X\n", pHetTable->dwIndexSize);
+ printf("DWORD dwIndexSize = %08X\n", pHetTable->dwIndexSize);
printf("-----------------------------------------------\n\n");
printf("== BET Header =================================\n");
@@ -89,7 +89,7 @@ void DumpHetAndBetTable(TMPQHetTable * pHetTable, TMPQBetTable * pBetTable)
printf("DWORD dwBitCount_FilePos = %08X\n", pBetTable->dwBitCount_FilePos);
printf("DWORD dwBitCount_FileSize = %08X\n", pBetTable->dwBitCount_FileSize);
printf("DWORD dwBitCount_CmpSize = %08X\n", pBetTable->dwBitCount_CmpSize);
- printf("DWORD dwBitCount_FlagIndex = %08X\n", pBetTable->dwBitCount_FlagIndex);
+ printf("DWORD dwBitCount_FlagIndex = %08X\n", pBetTable->dwBitCount_FlagIndex);
printf("DWORD dwBitCount_Unknown = %08X\n", pBetTable->dwBitCount_Unknown);
printf("DWORD dwBitTotal_NameHash2 = %08X\n", pBetTable->dwBitTotal_NameHash2);
printf("DWORD dwBitExtra_NameHash2 = %08X\n", pBetTable->dwBitExtra_NameHash2);
@@ -114,7 +114,7 @@ void DumpHetAndBetTable(TMPQHetTable * pHetTable, TMPQBetTable * pBetTable)
GetMPQBits(pHetTable->pBetIndexes, i * pHetTable->dwIndexSizeTotal,
pHetTable->dwIndexSize,
&dwBetIndex, 4);
-
+
if(dwBetIndex < pHetTable->dwTotalCount)
{
DWORD dwEntryIndex = pBetTable->dwTableEntrySize * dwBetIndex;
diff --git a/src/SBaseFileTable.cpp b/src/SBaseFileTable.cpp
index 7fe1042..98d8e44 100644
--- a/src/SBaseFileTable.cpp
+++ b/src/SBaseFileTable.cpp
@@ -52,7 +52,7 @@ static DWORD GetNecessaryBitCount(ULONGLONG MaxValue)
MaxValue >>= 1;
dwBitCount++;
}
-
+
return dwBitCount;
}
@@ -119,7 +119,7 @@ void TMPQBits::GetBits(
#ifndef STORMLIB_LITTLE_ENDIAN
// Adjust the buffer pointer for big endian platforms
pbBuffer += (nResultByteSize - 1);
-#endif
+#endif
// Copy whole bytes, if any
while(nByteLength > 0)
@@ -178,7 +178,7 @@ void TMPQBits::SetBits(
#ifndef STORMLIB_LITTLE_ENDIAN
// Adjust the buffer pointer for big endian platforms
pbBuffer += (nResultByteSize - 1);
-#endif
+#endif
// Copy whole bytes, if any
while(nBitLength > 8)
@@ -392,7 +392,7 @@ ULONGLONG CalculateRawSectorOffset(
// Must be used for files within a MPQ
assert(hf->ha != NULL);
assert(hf->ha->pHeader != NULL);
-
+
//
// Some MPQ protectors place the sector offset table after the actual file data.
// Sector offsets in the sector offset table are negative. When added
@@ -476,7 +476,7 @@ int ConvertMpqHeaderToFormat4(
pHeader->BlockTableSize64 = pHeader->dwBlockTableSize * sizeof(TMPQBlock);
pHeader->HashTableSize64 = pHeader->dwHashTableSize * sizeof(TMPQHash);
pHeader->ArchiveSize64 = pHeader->dwArchiveSize;
-
+
// Block table position must be calculated as 32-bit value
// Note: BOBA protector puts block table before the MPQ header, so it is negative
BlockTablePos64 = (ULONGLONG)((DWORD)MpqOffset + pHeader->dwBlockTablePos);
@@ -626,7 +626,7 @@ int ConvertMpqHeaderToFormat4(
pHeader->HetTableSize64 = ByteOffset - pHeader->HetTablePos64;
// ByteOffset = pHeader->HetTablePos64;
}
-
+
// Add the MPQ Offset
BlockTablePos64 += MpqOffset;
break;
@@ -697,14 +697,14 @@ int ConvertMpqHeaderToFormat4(
bool IsValidHashEntry(TMPQArchive * ha, TMPQHash * pHash)
{
TFileEntry * pFileEntry = ha->pFileTable + MPQ_BLOCK_INDEX(pHash);
-
+
return ((MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) && (pFileEntry->dwFlags & MPQ_FILE_EXISTS)) ? true : false;
}
// Hash entry verification when the file table does not exist yet
static bool IsValidHashEntry1(TMPQArchive * ha, TMPQHash * pHash, TMPQBlock * pBlockTable)
{
- ULONGLONG ByteOffset;
+ ULONGLONG ByteOffset;
TMPQBlock * pBlock;
// The block index is considered valid if it's less than block table size
@@ -758,7 +758,7 @@ static TMPQHash * GetHashEntryLocale(TMPQArchive * ha, const char * szFileName,
}
// Get the next hash entry for that file
- pHash = GetNextHashEntry(ha, pFirstHash, pHash);
+ pHash = GetNextHashEntry(ha, pFirstHash, pHash);
}
// At the end, return neutral hash (if found), otherwise NULL
@@ -779,9 +779,9 @@ static TMPQHash * GetHashEntryExact(TMPQArchive * ha, const char * szFileName, L
// If the locales match, return it
if(pHash->lcLocale == lcLocale)
return pHash;
-
+
// Get the next hash entry for that file
- pHash = GetNextHashEntry(ha, pFirstHash, pHash);
+ pHash = GetNextHashEntry(ha, pFirstHash, pHash);
}
// Not found
@@ -1361,7 +1361,7 @@ TMPQHetTable * CreateHetTable(DWORD dwEntryCount, DWORD dwTotalCount, DWORD dwNa
// Copy the file indexes
memcpy(pHetTable->pBetIndexes->Elements, pbSrcData + dwTotalCount, pHetTable->pBetIndexes->NumberOfBytes);
}
-
+
// Return the result HET table
return pHetTable;
}
@@ -1445,7 +1445,7 @@ static TMPQHetTable * TranslateHetTable(TMPQHetHeader * pHetHeader)
// The size of index table (in entries) is expected
// to be the same like the hash table size (in bytes)
assert(((pHetHeader->dwTotalCount * pHetHeader->dwIndexSizeTotal) + 7) / 8 == pHetHeader->dwIndexTableSize);
-
+
// Create translated table
pHetTable = CreateHetTable(pHetHeader->dwEntryCount, pHetHeader->dwTotalCount, pHetHeader->dwNameHashBitSize, pbSrcData);
if(pHetTable != NULL)
@@ -1761,7 +1761,7 @@ static TMPQBetTable * TranslateBetTable(
pBetTable->dwBitTotal_NameHash2 = pBetHeader->dwBitTotal_NameHash2;
pBetTable->dwBitExtra_NameHash2 = pBetHeader->dwBitExtra_NameHash2;
pBetTable->dwBitCount_NameHash2 = pBetHeader->dwBitCount_NameHash2;
-
+
// Create and load the array of BET hashes
pBetTable->pNameHashes = TMPQBits::Create(pBetTable->dwBitTotal_NameHash2 * pBetHeader->dwEntryCount, 0);
if(pBetTable->pNameHashes != NULL)
@@ -1875,7 +1875,7 @@ TMPQExtHeader * TranslateBetTable(
BetHeader.dwBitCount_NameHash2,
&pFileEntry->FileNameHash,
8);
-
+
assert(dwFileIndex < BetHeader.dwEntryCount);
dwFileIndex++;
}
@@ -1983,7 +1983,7 @@ TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID l
return ha->pFileTable + dwFileIndex;
}
}
-
+
// Not found
return NULL;
}
@@ -2045,7 +2045,7 @@ TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID l
if(pFreeEntry == NULL)
pFreeEntry = pFileEntry;
dwFreeCount++;
-
+
// If the number of free items is greater than number
// of reserved items, We can add the file
if(dwFreeCount > dwReservedFiles)
@@ -2173,7 +2173,7 @@ int DeleteFileEntry(TMPQArchive * ha, TMPQFile * hf)
pFileEntry->dwFlags &= ~MPQ_FILE_EXISTS;
pFileEntry->FileNameHash = 0;
- return ERROR_SUCCESS;
+ return ERROR_SUCCESS;
}
DWORD InvalidateInternalFile(TMPQArchive * ha, const char * szFileName, DWORD dwFlagNone, DWORD dwFlagNew, DWORD dwForceAddTheFile = 0)
@@ -2206,7 +2206,7 @@ DWORD InvalidateInternalFile(TMPQArchive * ha, const char * szFileName, DWORD dw
else
{
ha->dwFlags |= dwFlagNone;
- dwFileFlags = 0;
+ dwFileFlags = 0;
}
// Return the intended file flags
@@ -2220,7 +2220,7 @@ void InvalidateInternalFiles(TMPQArchive * ha)
{
//
// We clear the file entries for (listfile), (attributes) and (signature)
- // For each internal file cleared, we increment the number
+ // For each internal file cleared, we increment the number
// of reserved entries in the file table.
//
@@ -2366,7 +2366,7 @@ TMPQBlock * LoadBlockTable(TMPQArchive * ha, bool /* bDontFixEntries */)
// Read, decrypt and uncompress the block table
pBlockTable = (TMPQBlock * )LoadMpqTable(ha, ByteOffset, dwCmpSize, dwTableSize, MPQ_KEY_BLOCK_TABLE, &bBlockTableIsCut);
-
+
// If the block table was cut, we need to remember it
if(pBlockTable != NULL && bBlockTableIsCut)
ha->dwFlags |= (MPQ_FLAG_MALFORMED | MPQ_FLAG_BLOCK_TABLE_CUT);
@@ -2551,7 +2551,7 @@ static int BuildFileTable_HetBet(TMPQArchive * ha)
FreeBetTable(pBetTable);
return ERROR_FILE_CORRUPT;
}
-
+
// Step one: Fill the name indexes
for(i = 0; i < pHetTable->dwTotalCount; i++)
{
@@ -2586,7 +2586,7 @@ static int BuildFileTable_HetBet(TMPQArchive * ha)
// Go through the entire BET table and convert it to the file table.
pFileEntry = ha->pFileTable;
- pBitArray = pBetTable->pFileTable;
+ pBitArray = pBetTable->pFileTable;
for(i = 0; i < pBetTable->dwEntryCount; i++)
{
DWORD dwFlagIndex = 0;
@@ -2697,7 +2697,7 @@ void UpdateBlockTableSize(TMPQArchive * ha)
// Calculate the number of files
for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++)
{
- // If the source table entry is valid,
+ // If the source table entry is valid,
if(pFileEntry->dwFlags & MPQ_FILE_EXISTS)
dwBlockTableSize = (DWORD)(pFileEntry - ha->pFileTable) + 1;
}
@@ -2728,7 +2728,7 @@ int DefragmentFileTable(TMPQArchive * ha)
// Parse the entire file table and defragment it
for(; pSource < pFileTableEnd; pSource++)
{
- // If the source table entry is valid,
+ // If the source table entry is valid,
if(pSource->dwFlags & MPQ_FILE_EXISTS)
{
// Remember the index conversion
@@ -2920,7 +2920,7 @@ int SaveMPQTables(TMPQArchive * ha)
// We expect this function to be called only when tables have been changed
assert(ha->dwFlags & MPQ_FLAG_CHANGED);
- // Find the space where the MPQ tables will be saved
+ // Find the space where the MPQ tables will be saved
TablePos = FindFreeMpqSpace(ha);
// If the MPQ has HET table, we prepare a ready-to-save version
@@ -3011,7 +3011,7 @@ int SaveMPQTables(TMPQArchive * ha)
pHeader->HiBlockTableSize64 = HiBlockTableSize64;
pHeader->HiBlockTablePos64 = TablePos;
BSWAP_ARRAY16_UNSIGNED(pHiBlockTable, HiBlockTableSize64);
-
+
if(!FileStream_Write(ha->pStream, &ByteOffset, pHiBlockTable, (DWORD)HiBlockTableSize64))
nError = GetLastError();
TablePos += HiBlockTableSize64;
@@ -3034,7 +3034,7 @@ int SaveMPQTables(TMPQArchive * ha)
// Update the size of the archive
pHeader->ArchiveSize64 = TablePos;
pHeader->dwArchiveSize = (DWORD)TablePos;
-
+
// Update the MD5 of the archive header
CalculateDataBlockHash(pHeader, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE, pHeader->MD5_MpqHeader);
diff --git a/src/SBaseSubTypes.cpp b/src/SBaseSubTypes.cpp
index 47c205e..6ac5279 100644
--- a/src/SBaseSubTypes.cpp
+++ b/src/SBaseSubTypes.cpp
@@ -21,24 +21,24 @@
typedef struct _TSQPHeader
{
// The ID_MPQ ('MPQ\x1A') signature
- DWORD dwID;
+ DWORD dwID;
// Size of the archive header
- DWORD dwHeaderSize;
+ DWORD dwHeaderSize;
// 32-bit size of MPQ archive
DWORD dwArchiveSize;
// Offset to the beginning of the hash table, relative to the beginning of the archive.
DWORD dwHashTablePos;
-
+
// Offset to the beginning of the block table, relative to the beginning of the archive.
DWORD dwBlockTablePos;
-
+
// Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for
// the original MoPaQ format, or less than 2^20 for the Burning Crusade format.
DWORD dwHashTableSize;
-
+
// Number of entries in the block table
DWORD dwBlockTableSize;
@@ -66,7 +66,7 @@ typedef struct _TSQPHash
// The hash of the file path, using method A.
DWORD dwName1;
-
+
// The hash of the file path, using method B.
DWORD dwName2;
@@ -76,16 +76,16 @@ typedef struct _TSQPBlock
{
// Offset of the beginning of the file, relative to the beginning of the archive.
DWORD dwFilePos;
-
+
// Flags for the file. See MPQ_FILE_XXXX constants
- DWORD dwFlags;
+ DWORD dwFlags;
// Compressed file size
DWORD dwCSize;
-
+
// Uncompressed file size
- DWORD dwFSize;
-
+ DWORD dwFSize;
+
} TSQPBlock;
//-----------------------------------------------------------------------------
@@ -143,7 +143,7 @@ int ConvertSqpHeaderToFormat4(
// Copy the converted MPQ header back
memcpy(ha->HeaderData, &Header, sizeof(TMPQHeader));
-
+
// Mark this file as SQP file
ha->pfnHashString = HashStringSlash;
ha->dwFlags |= MPQ_FLAG_READ_ONLY;
@@ -292,13 +292,13 @@ typedef struct _TMPKHeader
{
// The ID_MPK ('MPK\x1A') signature
DWORD dwID;
-
+
// Contains '2000'
DWORD dwVersion;
-
+
// 32-bit size of the archive
DWORD dwArchiveSize;
-
+
// Size of the archive header
DWORD dwHeaderSize;
@@ -315,7 +315,7 @@ typedef struct _TMPKHash
{
// The hash of the file path, using method A.
DWORD dwName1;
-
+
// The hash of the file path, using method B.
DWORD dwName2;
@@ -334,7 +334,7 @@ typedef struct _TMPKHash
typedef struct _TMPKBlock
{
- DWORD dwFlags; // 0x1121 - Compressed , 0x1120 - Not compressed
+ DWORD dwFlags; // 0x1121 - Compressed , 0x1120 - Not compressed
DWORD dwFilePos; // Offset of the beginning of the file, relative to the beginning of the archive.
DWORD dwFSize; // Uncompressed file size
DWORD dwCSize; // Compressed file size
diff --git a/src/SCompression.cpp b/src/SCompression.cpp
index d706a6f..93f80e1 100644
--- a/src/SCompression.cpp
+++ b/src/SCompression.cpp
@@ -2,7 +2,7 @@
/* SCompression.cpp Copyright (c) Ladislav Zezula 2003 */
/*---------------------------------------------------------------------------*/
/* This module serves as a bridge between StormLib code and (de)compression */
-/* functions. All (de)compression calls go (and should only go) through this */
+/* functions. All (de)compression calls go (and should only go) through this */
/* module. No system headers should be included in this module to prevent */
/* compile-time problems. */
/*---------------------------------------------------------------------------*/
@@ -45,11 +45,11 @@ typedef int (*DECOMPRESS)(
void * pvOutBuffer, // [out] Pointer to the buffer where to store decompressed data
int * pcbOutBuffer, // [in] Pointer to total size of the buffer pointed by pvOutBuffer
// [out] Contains length of the decompressed data
- void * pvInBuffer, // [in] Pointer to data to be decompressed
+ void * pvInBuffer, // [in] Pointer to data to be decompressed
int cbInBuffer); // [in] Length of the data to be decompressed
// Table of compression functions
-typedef struct
+typedef struct
{
unsigned long uMask; // Compression mask
COMPRESS Compress; // Compression function
@@ -76,7 +76,7 @@ void Compress_huff(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, in
STORMLIB_UNUSED(nCmpLevel);
*pcbOutBuffer = ht.Compress(&os, pvInBuffer, cbInBuffer, *pCmpType);
-}
+}
int Decompress_huff(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer)
{
@@ -144,7 +144,7 @@ void Compress_ZLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, in
{
// Call zlib to compress the data
nResult = deflate(&z, Z_FINISH);
-
+
if(nResult == Z_OK || nResult == Z_STREAM_END)
*pcbOutBuffer = z.total_out;
@@ -187,7 +187,7 @@ int Decompress_ZLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i
// Function loads data from the input buffer. Used by Pklib's "implode"
// and "explode" function as user-defined callback
// Returns number of bytes loaded
-//
+//
// char * buf - Pointer to a buffer where to store loaded data
// unsigned int * size - Max. number of bytes to read
// void * param - Custom pointer, parameter of implode/explode
@@ -201,7 +201,7 @@ static unsigned int ReadInputData(char * buf, unsigned int * size, void * param)
// Check the case when not enough data available
if(nToRead > nMaxAvail)
nToRead = nMaxAvail;
-
+
// Load data and increment offsets
memcpy(buf, pInfo->pbInBuff, nToRead);
pInfo->pbInBuff += nToRead;
@@ -211,7 +211,7 @@ static unsigned int ReadInputData(char * buf, unsigned int * size, void * param)
// Function for store output data. Used by Pklib's "implode" and "explode"
// as user-defined callback
-//
+//
// char * buf - Pointer to data to be written
// unsigned int * size - Number of bytes to write
// void * param - Custom pointer, parameter of implode/explode
@@ -293,7 +293,7 @@ static int Decompress_PKLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInB
// Do the decompression
explode(ReadInputData, WriteOutputData, work_buf, &Info);
-
+
// If PKLIB is unable to decompress the data, return 0;
if(Info.pbOutBuff == pvOutBuffer)
{
@@ -376,8 +376,8 @@ static int Decompress_BZIP2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInB
while(nResult != BZ_STREAM_END)
{
nResult = BZ2_bzDecompress(&strm);
-
- // If any error there, break the loop
+
+ // If any error there, break the loop
if(nResult < BZ_OK)
break;
}
@@ -510,7 +510,7 @@ static int Decompress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu
SRes nResult;
// There must be at least 0x0E bytes in the buffer
- if(srcLen <= LZMA_HEADER_SIZE)
+ if(srcLen <= LZMA_HEADER_SIZE)
return 0;
// We only accept blocks that have no filter used
@@ -527,7 +527,7 @@ static int Decompress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu
&destLen,
srcBuffer + LZMA_HEADER_SIZE,
&srcLen,
- srcBuffer + 1,
+ srcBuffer + 1,
LZMA_PROPS_SIZE,
LZMA_FINISH_END,
&LzmaStatus,
@@ -568,7 +568,7 @@ static int Decompress_LZMA_MPK(void * pvOutBuffer, int * pcbOutBuffer, void * pv
&destLen,
srcBuffer + sizeof(LZMA_Props),
&srcLen,
- srcBuffer,
+ srcBuffer,
sizeof(LZMA_Props),
LZMA_FINISH_END,
&LzmaStatus,
@@ -728,7 +728,7 @@ int WINAPI SCompExplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffe
memcpy(pvOutBuffer, pvInBuffer, cbInBuffer);
return 1;
}
-
+
// Perform decompression
if(!Decompress_PKLIB(pvOutBuffer, &cbOutBuffer, pvInBuffer, cbInBuffer))
{
@@ -992,7 +992,7 @@ int WINAPI SCompDecompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu
// Get the correct output buffer
pbOutput = (nCompressIndex & 1) ? pbWorkBuffer : pbOutBuffer;
nCompressIndex--;
-
+
// Perform the decompression
cbOutBuffer = *pcbOutBuffer;
nResult = dcmp_table[i].Decompress(pbOutput, &cbOutBuffer, pbInput, cbInLength);
@@ -1140,6 +1140,6 @@ int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInB
int SCompDecompressMpk(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer)
{
- return Decompress_LZMA_MPK(pvOutBuffer, pcbOutBuffer, pvInBuffer, cbInBuffer);
+ return Decompress_LZMA_MPK(pvOutBuffer, pcbOutBuffer, pvInBuffer, cbInBuffer);
}
diff --git a/src/SFileAddFile.cpp b/src/SFileAddFile.cpp
index e756781..31f052a 100644
--- a/src/SFileAddFile.cpp
+++ b/src/SFileAddFile.cpp
@@ -36,8 +36,8 @@ typedef struct _WAVE_FILE_HEADER
DWORD dwChunkId; // 0x52494646 ("RIFF")
DWORD dwChunkSize; // Size of that chunk, in bytes
DWORD dwFormat; // Must be 0x57415645 ("WAVE")
-
- // Format sub-chunk
+
+ // Format sub-chunk
DWORD dwSubChunk1Id; // 0x666d7420 ("fmt ")
DWORD dwSubChunk1Size; // 0x16 for PCM
USHORT wAudioFormat; // 1 = PCM. Other value means some sort of compression
@@ -150,11 +150,11 @@ static int WriteDataToMpqFile(
DWORD dwSectorIndex = hf->dwFilePos / hf->dwSectorSize;
DWORD dwBytesToCopy;
- // Process all data.
+ // Process all data.
while(dwDataSize != 0)
{
dwBytesToCopy = dwDataSize;
-
+
// Check for sector overflow
if(dwBytesToCopy > (hf->dwSectorSize - dwBytesInSector))
dwBytesToCopy = (hf->dwSectorSize - dwBytesInSector);
@@ -214,7 +214,7 @@ static int WriteDataToMpqFile(
// by the first sector compression. This is because the entire sector must
// be compressed by the same compression.
//
- // Test case:
+ // Test case:
//
// WRITE_FILE(hFile, pvBuffer, 0x10, MPQ_COMPRESSION_PKWARE) // Write 0x10 bytes (sector 0)
// WRITE_FILE(hFile, pvBuffer, 0x10, MPQ_COMPRESSION_ADPCM_MONO) // Write 0x10 bytes (still sector 0)
@@ -370,7 +370,7 @@ static int RecryptFileData(
}
// If necessary, re-encrypt the sector
- // Note: Recompression is not necessary here. Unlike encryption,
+ // Note: Recompression is not necessary here. Unlike encryption,
// the compression does not depend on the position of the file in MPQ.
BSWAP_ARRAY32_UNSIGNED(hf->pbFileSector, dwRawDataInSector);
DecryptMpqBlock(hf->pbFileSector, dwRawDataInSector, dwOldKey + dwSector);
@@ -422,7 +422,7 @@ int SFileAddFile_Init(
// Sector CRC is not allowed if the file is not compressed
if(!(dwFlags & MPQ_FILE_COMPRESS_MASK))
dwFlags &= ~MPQ_FILE_SECTOR_CRC;
-
+
// Fix Key is not allowed if the file is not enrypted
if(!(dwFlags & MPQ_FILE_ENCRYPTED))
dwFlags &= ~MPQ_FILE_FIX_KEY;
@@ -456,7 +456,7 @@ int SFileAddFile_Init(
if(pFileEntry != NULL)
InvalidateInternalFiles(ha);
else
- nError = ERROR_DISK_FULL;
+ nError = ERROR_DISK_FULL;
}
// Set the file entry to the file structure
@@ -621,7 +621,7 @@ int SFileAddFile_Write(TMPQFile * hf, const void * pvData, DWORD dwSize, DWORD d
{
if(!FileStream_Write(ha->pStream, &RawFilePos, hf->pPatchInfo, hf->pPatchInfo->dwLength))
nError = GetLastError();
-
+
pFileEntry->dwCmpSize += hf->pPatchInfo->dwLength;
RawFilePos += hf->pPatchInfo->dwLength;
}
@@ -754,7 +754,7 @@ int SFileAddFile_Finish(TMPQFile * hf)
}
//-----------------------------------------------------------------------------
-// Adds data as file to the archive
+// Adds data as file to the archive
bool WINAPI SFileCreateFile(
HANDLE hMpq,
@@ -775,7 +775,7 @@ bool WINAPI SFileCreateFile(
nError = ERROR_INVALID_PARAMETER;
if(phFile == NULL)
nError = ERROR_INVALID_PARAMETER;
-
+
// Don't allow to add file if the MPQ is open for read only
if(nError == ERROR_SUCCESS)
{
@@ -841,7 +841,7 @@ bool WINAPI SFileWriteFile(
//
// if(dwFlags & MPQ_FILE_ENCRYPTED)
// nError = ERROR_INVALID_PARAMETER;
-
+
// Lossy compression is not allowed on single unit files
if(dwCompression & MPQ_LOSSY_COMPRESSION_MASK)
nError = ERROR_INVALID_PARAMETER;
@@ -851,7 +851,7 @@ bool WINAPI SFileWriteFile(
// Write the data to the file
if(nError == ERROR_SUCCESS)
nError = SFileAddFile_Write(hf, pvData, dwSize, dwCompression);
-
+
// Deal with errors
if(nError != ERROR_SUCCESS)
SetLastError(nError);
@@ -872,7 +872,7 @@ bool WINAPI SFileFinishFile(HANDLE hFile)
// Finish the file
if(nError == ERROR_SUCCESS)
nError = SFileAddFile_Finish(hf);
-
+
// Deal with errors
if(nError != ERROR_SUCCESS)
SetLastError(nError);
@@ -880,7 +880,7 @@ bool WINAPI SFileFinishFile(HANDLE hFile)
}
//-----------------------------------------------------------------------------
-// Adds a file to the archive
+// Adds a file to the archive
bool WINAPI SFileAddFileEx(
HANDLE hMpq,
@@ -937,7 +937,7 @@ bool WINAPI SFileAddFileEx(
// we will copy the compression for the first sector
if(dwCompressionNext == MPQ_COMPRESSION_NEXT_SAME)
dwCompressionNext = dwCompression;
-
+
// If the caller wants ADPCM compression, we make sure
// that the first sector is not compressed with lossy compression
if(dwCompressionNext & (MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO))
@@ -946,7 +946,7 @@ bool WINAPI SFileAddFileEx(
// in order not to corrupt the headers
if(dwCompression & (MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO))
dwCompression = MPQ_COMPRESSION_PKWARE;
-
+
// Remove both flag mono and stereo flags.
// They will be re-added according to WAVE type
dwCompressionNext &= ~(MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO);
@@ -1020,7 +1020,7 @@ bool WINAPI SFileAddFileEx(
SetLastError(nError);
return (nError == ERROR_SUCCESS);
}
-
+
// Adds a data file into the archive
bool WINAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags)
{
@@ -1047,7 +1047,7 @@ bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szA
// Starcraft files are packed as Mono (0x41) on medium quality.
// Because this compression is not used anymore, our compression functions
// will default to WaveCompressionLevel = 4 when using ADPCM compression
- //
+ //
// Convert quality to data compression
switch(dwQuality)
@@ -1190,7 +1190,7 @@ bool WINAPI SFileRenameFile(HANDLE hMpq, const char * szFileName, const char * s
{
// Recrypt the file data in the MPQ
nError = RecryptFileData(ha, hf, szFileName, szNewFileName);
-
+
// Update the MD5 of the raw block
if(nError == ERROR_SUCCESS && ha->pHeader->dwRawChunkSize != 0)
{
diff --git a/src/SFileAttributes.cpp b/src/SFileAttributes.cpp
index f57f62c..77464f0 100644
--- a/src/SFileAttributes.cpp
+++ b/src/SFileAttributes.cpp
@@ -151,7 +151,7 @@ static int LoadAttributesFile(TMPQArchive * ha, LPBYTE pbAttrFile, DWORD cbAttrF
if((pbAttrPtr + sizeof(MPQ_ATTRIBUTES_HEADER)) <= pbAttrFileEnd)
{
PMPQ_ATTRIBUTES_HEADER pAttrHeader = (PMPQ_ATTRIBUTES_HEADER)pbAttrPtr;
-
+
// Verify the header version
BSWAP_ARRAY32_UNSIGNED(pAttrHeader, sizeof(MPQ_ATTRIBUTES_HEADER));
if(pAttrHeader->dwVersion != MPQ_ATTRIBUTES_V1)
@@ -378,7 +378,7 @@ int SAttrLoadAttributes(TMPQArchive * ha)
{
// Retrieve and check size of the (attributes) file
cbAttrFile = SFileGetFileSize(hFile, NULL);
-
+
// Integer overflow check
if((cbAttrFile + 1) > cbAttrFile)
{
@@ -461,7 +461,7 @@ int SAttrFileSaveToMpq(TMPQArchive * ha)
nError = (cbAttrFile == 0) ? ERROR_SUCCESS : ERROR_NOT_ENOUGH_MEMORY;
}
}
-
+
return nError;
}
diff --git a/src/SFileCompactArchive.cpp b/src/SFileCompactArchive.cpp
index ff7b25b..1fed524 100644
--- a/src/SFileCompactArchive.cpp
+++ b/src/SFileCompactArchive.cpp
@@ -158,7 +158,7 @@ static int CopyMpqFileSectors(
DWORD dwCmpSize = 0; // Compressed file size, including patch header
int nError = ERROR_SUCCESS;
- // Resolve decryption keys. Note that the file key given
+ // Resolve decryption keys. Note that the file key given
// in the TMPQFile structure also includes the key adjustment
if(nError == ERROR_SUCCESS && (pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED))
{
@@ -240,7 +240,7 @@ static int CopyMpqFileSectors(
// Calculate the raw file offset of the file sector
RawFilePos = CalculateRawSectorOffset(hf, dwRawByteOffset);
-
+
// Read the file sector
if(!FileStream_Read(ha->pStream, &RawFilePos, hf->pbFileSector, dwRawDataInSector))
{
@@ -249,7 +249,7 @@ static int CopyMpqFileSectors(
}
// If necessary, re-encrypt the sector
- // Note: Recompression is not necessary here. Unlike encryption,
+ // Note: Recompression is not necessary here. Unlike encryption,
// the compression does not depend on the position of the file in MPQ.
if((pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) && dwFileKey1 != dwFileKey2)
{
@@ -337,7 +337,7 @@ static int CopyMpqFileSectors(
// Write the MD5's of the raw file data, if needed
if(nError == ERROR_SUCCESS && ha->pHeader->dwRawChunkSize != 0)
{
- nError = WriteMpqDataMD5(pNewStream,
+ nError = WriteMpqDataMD5(pNewStream,
ha->MpqPos + MpqFilePos,
pFileEntry->dwCmpSize,
ha->pHeader->dwRawChunkSize);
@@ -349,7 +349,7 @@ static int CopyMpqFileSectors(
// At this point, number of bytes written should be exactly
// the same like the compressed file size. If it isn't,
// there's something wrong (an unknown archive version, MPQ malformation, ...)
- //
+ //
// Note: Diablo savegames have very weird layout, and the file "hero"
// seems to have improper compressed size. Instead of real compressed size,
// the "dwCmpSize" member of the block table entry contains
diff --git a/src/SFileCreateArchive.cpp b/src/SFileCreateArchive.cpp
index de4ab36..7c24491 100644
--- a/src/SFileCreateArchive.cpp
+++ b/src/SFileCreateArchive.cpp
@@ -186,7 +186,7 @@ bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCrea
if(!FileStream_SetSize(pStream, MpqPos))
nError = GetLastError();
-#ifdef _DEBUG
+#ifdef _DEBUG
// Debug code, used for testing StormLib
// dwBlockTableSize = dwHashTableSize * 2;
#endif
@@ -267,7 +267,7 @@ bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCrea
SetLastError(nError);
ha = NULL;
}
-
+
// Return the values
*phMpq = (HANDLE)ha;
return (nError == ERROR_SUCCESS);
diff --git a/src/SFileFindFile.cpp b/src/SFileFindFile.cpp
index 6a4cecd..3dbb2f8 100644
--- a/src/SFileFindFile.cpp
+++ b/src/SFileFindFile.cpp
@@ -345,7 +345,7 @@ static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData)
// Start searching with base MPQ
while(ha != NULL)
- {
+ {
// If the archive has hash table, we need to use hash table
// in order to catch hash table index and file locale.
// Note: If multiple hash table entries, point to the same block entry,
@@ -445,7 +445,7 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DA
FreeMPQSearch(hs);
SetLastError(nError);
}
-
+
// Return the result value
return (HANDLE)hs;
}
diff --git a/src/SFileGetFileInfo.cpp b/src/SFileGetFileInfo.cpp
index 4ec05e2..44cbf4a 100644
--- a/src/SFileGetFileInfo.cpp
+++ b/src/SFileGetFileInfo.cpp
@@ -475,7 +475,7 @@ struct TFileHeader2Ext
const char * szExt; // Supplied extension, if the condition is true
};
-static TFileHeader2Ext data2ext[] =
+static TFileHeader2Ext data2ext[] =
{
{0x00005A4D, 0x0000FFFF, 0x00000000, 0x00000000, "exe"}, // EXE files
{0x00000006, 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, "dc6"}, // EXE files
@@ -506,7 +506,7 @@ static TFileHeader2Ext data2ext[] =
{0x5733504D, 0xFFFFFFFF, 0x00000000, 0x00000000, "wpm"}, // Warcraft III pathing map files
{0x21475457, 0xFFFFFFFF, 0x00000000, 0x00000000, "wtg"}, // Warcraft III trigger files
{0x00000000, 0x00000000, 0x00000000, 0x00000000, "xxx"}, // Default extension
- {0, 0, 0, 0, NULL} // Terminator
+ {0, 0, 0, 0, NULL} // Terminator
};
static int CreatePseudoFileName(HANDLE hFile, TFileEntry * pFileEntry, char * szFileName)
@@ -518,7 +518,7 @@ static int CreatePseudoFileName(HANDLE hFile, TFileEntry * pFileEntry, char * sz
char szPseudoName[20];
// Read the first 2 DWORDs bytes from the file
- dwFilePos = SFileSetFilePointer(hFile, 0, NULL, FILE_CURRENT);
+ dwFilePos = SFileSetFilePointer(hFile, 0, NULL, FILE_CURRENT);
SFileReadFile(hFile, FirstBytes, sizeof(FirstBytes), &dwBytesRead, NULL);
SFileSetFilePointer(hFile, dwFilePos, NULL, FILE_BEGIN);
diff --git a/src/SFileListFile.cpp b/src/SFileListFile.cpp
index fe9bc69..6fcd736 100644
--- a/src/SFileListFile.cpp
+++ b/src/SFileListFile.cpp
@@ -115,7 +115,7 @@ static TListFileCache * CreateListFileCache(
pCache->szWildCard = (char *)(pCache + 1);
memcpy(pCache->szWildCard, szWildCard, cchWildCard);
}
-
+
// Fill-in the rest of the cache pointers
pCache->pBegin = (LPBYTE)(pCache + 1) + cchWildCard;
@@ -272,11 +272,11 @@ static char * ReadListFileLine(TListFileCache * pCache, size_t * PtrLength)
{
LPBYTE pbLineBegin;
LPBYTE pbLineEnd;
-
+
// Skip newlines. Keep spaces and tabs, as they can be a legal part of the file name
while(pCache->pPos < pCache->pEnd && (pCache->pPos[0] == 0x0A || pCache->pPos[0] == 0x0D))
pCache->pPos++;
-
+
// Set the line begin and end
if(pCache->pPos >= pCache->pEnd)
return NULL;
@@ -296,7 +296,7 @@ static char * ReadListFileLine(TListFileCache * pCache, size_t * PtrLength)
return (char *)pbLineBegin;
}
-static int STORMLIB_CDECL CompareFileNodes(const void * p1, const void * p2)
+static int STORMLIB_CDECL CompareFileNodes(const void * p1, const void * p2)
{
char * szFileName1 = *(char **)p1;
char * szFileName2 = *(char **)p2;
@@ -526,7 +526,7 @@ static int SFileAddArbitraryListFile(
// Delete the cache
FreeListFileCache(pCache);
}
-
+
return (pCache != NULL) ? ERROR_SUCCESS : ERROR_FILE_CORRUPT;
}
@@ -550,7 +550,7 @@ static int SFileAddInternalListFile(
pFirstHash = pHash = GetFirstHashEntry(ha, LISTFILE_NAME);
while(nError == ERROR_SUCCESS && pHash != NULL)
- {
+ {
// Set the prefered locale to that from list file
SFileSetLocale(pHash->lcLocale);
diff --git a/src/SFileOpenArchive.cpp b/src/SFileOpenArchive.cpp
index 3e333a9..7dfb851 100644
--- a/src/SFileOpenArchive.cpp
+++ b/src/SFileOpenArchive.cpp
@@ -187,7 +187,7 @@ bool WINAPI SFileOpenArchive(
LPBYTE pbHeaderBuffer = NULL; // Buffer for searching MPQ header
DWORD dwStreamFlags = (dwFlags & STREAM_FLAGS_MASK);
MTYPE MapType = MapTypeNotRecognized;
- int nError = ERROR_SUCCESS;
+ int nError = ERROR_SUCCESS;
// Verify the parameters
if(szMpqName == NULL || *szMpqName == 0 || phMpq == NULL)
@@ -255,7 +255,7 @@ bool WINAPI SFileOpenArchive(
// Also remember if this MPQ is a patch
ha->dwFlags |= (dwFlags & MPQ_OPEN_PATCH) ? MPQ_FLAG_PATCH : 0;
-
+
// Limit the header searching to about 130 MB of data
if(EndOfSearch > 0x08000000)
EndOfSearch = 0x08000000;
diff --git a/src/SFileOpenFileEx.cpp b/src/SFileOpenFileEx.cpp
index d66c369..5b7933a 100644
--- a/src/SFileOpenFileEx.cpp
+++ b/src/SFileOpenFileEx.cpp
@@ -168,7 +168,7 @@ bool OpenPatchedFile(HANDLE hMpq, const char * szFileName, HANDLE * PtrFile)
/*****************************************************************************/
//-----------------------------------------------------------------------------
-// SFileEnumLocales enums all locale versions within MPQ.
+// SFileEnumLocales enums all locale versions within MPQ.
// Functions fills all available language identifiers on a file into the buffer
// pointed by plcLocales. There must be enough entries to copy the localed,
// otherwise the function returns ERROR_INSUFFICIENT_BUFFER.
@@ -198,7 +198,7 @@ int WINAPI SFileEnumLocales(
return ERROR_INVALID_PARAMETER;
if(IsPseudoFileName(szFileName, &dwFileIndex))
return ERROR_INVALID_PARAMETER;
-
+
// Keep compiler happy
dwMaxLocales = PtrMaxLocales[0];
dwSearchScope = dwSearchScope;
@@ -259,7 +259,7 @@ bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearch
case SFILE_OPEN_FROM_MPQ:
case SFILE_OPEN_BASE_FILE:
case SFILE_OPEN_CHECK_EXISTS:
-
+
// If this MPQ has no patches, open the file from this MPQ directly
if(ha->haPatch == NULL || dwSearchScope == SFILE_OPEN_BASE_FILE)
{
@@ -284,7 +284,7 @@ bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearch
case SFILE_OPEN_LOCAL_FILE:
// Open a local file
- return OpenLocalFile(szFileName, PtrFile);
+ return OpenLocalFile(szFileName, PtrFile);
default:
@@ -405,7 +405,7 @@ bool WINAPI SFileHasFile(HANDLE hMpq, const char * szFileName)
bool WINAPI SFileCloseFile(HANDLE hFile)
{
TMPQFile * hf = (TMPQFile *)hFile;
-
+
if(!IsValidFileHandle(hFile))
{
SetLastError(ERROR_INVALID_HANDLE);
diff --git a/src/SFilePatchArchives.cpp b/src/SFilePatchArchives.cpp
index 37b4612..83cb501 100644
--- a/src/SFilePatchArchives.cpp
+++ b/src/SFilePatchArchives.cpp
@@ -31,7 +31,7 @@ typedef struct _MPQ_PATCH_HEADER
DWORD dwSizeOfPatchData; // Size of the entire patch (decompressed)
DWORD dwSizeBeforePatch; // Size of the file before patch
DWORD dwSizeAfterPatch; // Size of file after patch
-
+
//-- MD5 block --------------------------------------
DWORD dwMD5; // 'MD5_'
DWORD dwMd5BlockSize; // Size of the MD5 block, including the signature and size itself
@@ -78,14 +78,14 @@ static const char * LanguageList = "baseteenenUSenGBenCNenTWdeDEesESesMXfrFRitIT
// List of localized MPQs for World of Warcraft
static LOCALIZED_MPQ_INFO LocaleMpqs_WoW[] =
{
- {"expansion1-locale-####", 18, 22},
- {"expansion1-speech-####", 18, 22},
- {"expansion2-locale-####", 18, 22},
- {"expansion2-speech-####", 18, 22},
- {"expansion3-locale-####", 18, 22},
- {"expansion3-speech-####", 18, 22},
- {"locale-####", 7, 11},
- {"speech-####", 7, 11},
+ {"expansion1-locale-####", 18, 22},
+ {"expansion1-speech-####", 18, 22},
+ {"expansion2-locale-####", 18, 22},
+ {"expansion2-speech-####", 18, 22},
+ {"expansion3-locale-####", 18, 22},
+ {"expansion3-speech-####", 18, 22},
+ {"locale-####", 7, 11},
+ {"speech-####", 7, 11},
{NULL, 0, 0}
};
@@ -113,7 +113,7 @@ static void Decompress_RLE(LPBYTE pbDecompressed, DWORD cbDecompressed, LPBYTE p
{
LPBYTE pbDecompressedEnd = pbDecompressed + cbDecompressed;
LPBYTE pbCompressedEnd = pbCompressed + cbCompressed;
- BYTE RepeatCount;
+ BYTE RepeatCount;
BYTE OneByte;
// Cut the initial DWORD from the compressed chunk
@@ -126,7 +126,7 @@ static void Decompress_RLE(LPBYTE pbDecompressed, DWORD cbDecompressed, LPBYTE p
while(pbCompressed < pbCompressedEnd && pbDecompressed < pbDecompressedEnd)
{
OneByte = *pbCompressed++;
-
+
// Is it a repetition byte ?
if(OneByte & 0x80)
{
@@ -285,8 +285,8 @@ static int ApplyFilePatch_BSD0(
// Now combine the patch data with the original file
for(i = 0; i < dwCombineSize; i++)
pbNewData[dwNewOffset + i] = pbNewData[dwNewOffset + i] + pbOldData[dwOldOffset + i];
-
- // Move the offsets
+
+ // Move the offsets
dwNewOffset += dwAddDataLength;
dwOldOffset += dwAddDataLength;
@@ -399,7 +399,7 @@ static int ApplyFilePatch(
// Verify the patched file
if(!VerifyDataBlockHash(pbTarget, pFullPatch->dwSizeAfterPatch, pFullPatch->md5_after_patch))
nError = ERROR_FILE_CORRUPT;
-
+
// Copy the MD5 of the new block
memcpy(pPatcher->this_md5, pFullPatch->md5_after_patch, MD5_DIGEST_SIZE);
}
@@ -491,7 +491,7 @@ static bool IsMatchingPatchFile(
{
// TODO: How to match it if it's not an incremental patch?
// Example: StarCraft II\Updates\enGB\s2-update-enGB-23258.MPQ:
- // Mods\Core.SC2Mod\enGB.SC2Assets\StreamingBuckets.txt"
+ // Mods\Core.SC2Mod\enGB.SC2Assets\StreamingBuckets.txt"
bResult = false;
}
@@ -697,7 +697,7 @@ static bool ExtractPatchPrefixFromFile(const TCHAR * szHelperFile, char * szPatc
{
char * szLinePtr = szFileData + 11;
char * szLineEnd;
-
+
// Skip spaces or '='
while(szLinePtr[0] == ' ' || szLinePtr[0] == '=')
szLinePtr++;
@@ -867,8 +867,8 @@ static bool FindPatchPrefix_SC2(TMPQArchive * haBase, TMPQArchive * haPatch, TFi
// Example 3:
// Main MPQ: %GAME%\Battle.net\Battle.net.MPQ
// Patch MPQ: s2-update-base-26147.MPQ
-// File in main MPQ: Battle.net\i18n\deDE\String\CLIENT_ACHIEVEMENTS.xml
-// File in patch MPQ: Battle.net\Battle.net.MPQ\Battle.net\i18n\deDE\String\CLIENT_ACHIEVEMENTS.xml
+// File in main MPQ: Battle.net\i18n\deDE\String\CLIENT_ACHIEVEMENTS.xml
+// File in patch MPQ: Battle.net\Battle.net.MPQ\Battle.net\i18n\deDE\String\CLIENT_ACHIEVEMENTS.xml
// Path prefix: Battle.net\Battle.net.MPQ
//
// Example 4:
@@ -894,7 +894,7 @@ static bool FindPatchPrefix(TMPQArchive * haBase, TMPQArchive * haPatch, const c
return FindPatchPrefix_WoW_13164_13623(haBase, haPatch);
// Updates for Starcraft II
- // Match: LocalizedData\GameHotkeys.txt <==> Campaigns\Liberty.SC2Campaign\enGB.SC2Data\LocalizedData\GameHotkeys.txt
+ // Match: LocalizedData\GameHotkeys.txt <==> Campaigns\Liberty.SC2Campaign\enGB.SC2Data\LocalizedData\GameHotkeys.txt
// All Starcraft II base archives seem to have the file "StreamingBuckets.txt" present
pFileEntry = GetFileEntryLocale(haBase, "StreamingBuckets.txt", 0);
if(pFileEntry != NULL)
@@ -1076,7 +1076,7 @@ void Patch_Finalize(TMPQPatcher * pPatcher)
STORM_FREE(pPatcher->pbFileData1);
if(pPatcher->pbFileData2 != NULL)
STORM_FREE(pPatcher->pbFileData2);
-
+
memset(pPatcher, 0, sizeof(TMPQPatcher));
}
}
diff --git a/src/SFileReadFile.cpp b/src/SFileReadFile.cpp
index 0320677..a9d070f 100644
--- a/src/SFileReadFile.cpp
+++ b/src/SFileReadFile.cpp
@@ -212,10 +212,10 @@ static int ReadMpqSectors(TMPQFile * hf, LPBYTE pbBuffer, DWORD dwByteOffset, DW
// Free all used buffers
if(pbRawSector != NULL)
STORM_FREE(pbRawSector);
-
+
// Give the caller thenumber of bytes read
*pdwBytesRead = dwBytesRead;
- return nError;
+ return nError;
}
static int ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwToRead, LPDWORD pdwBytesRead)
@@ -252,7 +252,7 @@ static int ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos
return ERROR_NOT_ENOUGH_MEMORY;
pbRawData = pbCompressed;
}
-
+
// Load the raw (compressed, encrypted) data
if(!FileStream_Read(ha->pStream, &RawFilePos, pbRawData, pFileEntry->dwCmpSize))
{
@@ -285,7 +285,7 @@ static int ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos
// -------------------------------------- ---------- -------- -------- ---------------
// esES\DBFilesClient\LightSkyBox.dbc 0xBE->0xA2 0xBC 0xBC Yes
// deDE\DBFilesClient\MountCapability.dbc 0x93->0x77 0x77 0x77 No
- //
+ //
if(pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE)
cbInBuffer = cbInBuffer - sizeof(TPatchInfo);
@@ -383,7 +383,7 @@ static int ReadMpkFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos
return ERROR_NOT_ENOUGH_MEMORY;
pbRawData = pbCompressed;
}
-
+
// Load the raw (compressed, encrypted) data
if(!FileStream_Read(ha->pStream, &RawFilePos, pbRawData, pFileEntry->dwCmpSize))
{
@@ -485,7 +485,7 @@ static int ReadMpqFileSectorFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos
{
DWORD dwBytesInSector = ha->dwSectorSize;
DWORD dwBufferOffs = dwFilePos & dwSectorSizeMask;
- DWORD dwToCopy;
+ DWORD dwToCopy;
// Is the file sector already loaded ?
if(hf->dwSectorOffs != dwFileSectorPos)
@@ -559,7 +559,7 @@ static int ReadMpqFileSectorFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos
// Copy the data from the cached last sector to the caller's buffer
memcpy(pbBuffer, hf->pbFileSector, dwToCopy);
-
+
// Update pointers
dwTotalBytesRead += dwToCopy;
}
@@ -717,7 +717,7 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD
nError = ReadMpkFileSingleUnit(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead);
}
- // If the file is single unit file, redirect it to read file
+ // If the file is single unit file, redirect it to read file
else if(hf->pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT)
{
nError = ReadMpqFileSingleUnit(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead);
@@ -837,7 +837,7 @@ DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHi
break;
case FILE_CURRENT:
-
+
// Retrieve the current file position
if(hf->pStream != NULL)
{
diff --git a/src/SFileVerify.cpp b/src/SFileVerify.cpp
index 3ceecb9..7e8848f 100644
--- a/src/SFileVerify.cpp
+++ b/src/SFileVerify.cpp
@@ -216,7 +216,7 @@ static bool CalculateMpqHashMd5(
if(dwToRead == 0)
break;
- // Read the next chunk
+ // Read the next chunk
if(!FileStream_Read(ha->pStream, &BeginBuffer, pbDigestBuffer, dwToRead))
{
STORM_FREE(pbDigestBuffer);
@@ -312,7 +312,7 @@ static bool CalculateMpqHashSha1(
if(dwToRead == 0)
break;
- // Read the next chunk
+ // Read the next chunk
if(!FileStream_Read(ha->pStream, &BeginBuffer, pbDigestBuffer, dwToRead))
{
STORM_FREE(pbDigestBuffer);
@@ -482,7 +482,7 @@ static DWORD VerifyStrongSignatureWithKey(
// Verify the signature
if(rsa_verify_simple(reversed_signature, MPQ_STRONG_SIGNATURE_SIZE, padded_digest, MPQ_STRONG_SIGNATURE_SIZE, &result, &key) != CRYPT_OK)
return ERROR_VERIFY_FAILED;
-
+
// Free the key and return result
rsa_free(&key);
return result ? ERROR_STRONG_SIGNATURE_OK : ERROR_STRONG_SIGNATURE_ERROR;
@@ -639,7 +639,7 @@ static DWORD VerifyFile(
// Update CRC32 value
if(dwFlags & SFILE_VERIFY_FILE_CRC)
dwCrc32 = crc32(dwCrc32, Buffer, dwBytesRead);
-
+
// Update MD5 value
if(dwFlags & SFILE_VERIFY_FILE_MD5)
md5_process(&md5_state, Buffer, dwBytesRead);
@@ -714,7 +714,7 @@ static DWORD VerifyFile(
if(pdwCrc32 != NULL)
*pdwCrc32 = dwCrc32;
if(pMD5 != NULL)
- memcpy(pMD5, md5, MD5_DIGEST_SIZE);
+ memcpy(pMD5, md5, MD5_DIGEST_SIZE);
return dwVerifyResult;
}
@@ -853,7 +853,7 @@ int SSignFileFinish(TMPQArchive * ha)
// Sign the hash
memset(WeakSignature, 0, sizeof(WeakSignature));
rsa_sign_hash_ex(Md5Digest, sizeof(Md5Digest), WeakSignature + 8, &signature_len, LTC_LTC_PKCS_1_V1_5, 0, 0, hash_idx, 0, &key);
- memrev(WeakSignature + 8, MPQ_WEAK_SIGNATURE_SIZE);
+ memrev(WeakSignature + 8, MPQ_WEAK_SIGNATURE_SIZE);
rsa_free(&key);
// Write the signature to the MPQ. Don't use SFile* functions, but write the hash directly
@@ -922,7 +922,7 @@ int WINAPI SFileVerifyRawData(HANDLE hMpq, DWORD dwWhatToVerify, const char * sz
switch(dwWhatToVerify)
{
case SFILE_VERIFY_MPQ_HEADER:
-
+
// Only if the header is of version 4 or newer
if(pHeader->dwHeaderSize >= (MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE))
return VerifyRawMpqData(ha, 0, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE);
diff --git a/src/StormCommon.h b/src/StormCommon.h
index 2d51d92..1167d29 100644
--- a/src/StormCommon.h
+++ b/src/StormCommon.h
@@ -86,7 +86,7 @@ typedef enum _MTYPE
// Size of each signature type
#define MPQ_WEAK_SIGNATURE_SIZE 64
-#define MPQ_STRONG_SIGNATURE_SIZE 256
+#define MPQ_STRONG_SIGNATURE_SIZE 256
#define MPQ_STRONG_SIGNATURE_ID 0x5349474E // ID of the strong signature ("NGIS")
#define MPQ_SIGNATURE_FILE_SIZE (MPQ_WEAK_SIGNATURE_SIZE + 8)
diff --git a/src/StormLib.h b/src/StormLib.h
index f254290..4d9066d 100644
--- a/src/StormLib.h
+++ b/src/StormLib.h
@@ -79,9 +79,9 @@
#define __STORMLIB_H__
#ifdef _MSC_VER
-#pragma warning(disable:4668) // 'XXX' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
+#pragma warning(disable:4668) // 'XXX' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
#pragma warning(disable:4820) // 'XXX' : '2' bytes padding added after data member 'XXX::yyy'
-#endif
+#endif
#include "StormPort.h"
@@ -94,7 +94,7 @@ extern "C" {
//
// The library type is encoded in the library name as the following
// StormLibXYZ.lib
-//
+//
// X - D for Debug version, R for Release version
// Y - A for ANSI version, U for Unicode version
// Z - S for static-linked CRT library, D for multithreaded DLL CRT library
@@ -107,30 +107,30 @@ extern "C" {
#if defined(_MSC_VER) && !defined(STORMLIB_NO_AUTO_LINK)
#ifndef WDK_BUILD
#ifdef _DEBUG // DEBUG VERSIONS
- #ifndef _UNICODE
- #ifdef _DLL
+ #ifndef _UNICODE
+ #ifdef _DLL
#pragma comment(lib, "StormLibDAD.lib") // Debug Ansi CRT-DLL version
- #else
+ #else
#pragma comment(lib, "StormLibDAS.lib") // Debug Ansi CRT-LIB version
#endif
#else
- #ifdef _DLL
+ #ifdef _DLL
#pragma comment(lib, "StormLibDUD.lib") // Debug Unicode CRT-DLL version
- #else
+ #else
#pragma comment(lib, "StormLibDUS.lib") // Debug Unicode CRT-LIB version
#endif
#endif
#else // RELEASE VERSIONS
- #ifndef _UNICODE
+ #ifndef _UNICODE
#ifdef _DLL
#pragma comment(lib, "StormLibRAD.lib") // Release Ansi CRT-DLL version
- #else
+ #else
#pragma comment(lib, "StormLibRAS.lib") // Release Ansi CRT-LIB version
#endif
#else
#ifdef _DLL
#pragma comment(lib, "StormLibRUD.lib") // Release Unicode CRT-DLL version
- #else
+ #else
#pragma comment(lib, "StormLibRUS.lib") // Release Unicode CRT-LIB version
#endif
#endif
@@ -215,7 +215,7 @@ extern "C" {
// Flags for SFileAddFile
#define MPQ_FILE_IMPLODE 0x00000100 // Implode method (By PKWARE Data Compression Library)
#define MPQ_FILE_COMPRESS 0x00000200 // Compress methods (By multiple methods)
-#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted
+#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted
#define MPQ_FILE_FIX_KEY 0x00020000 // File decryption key has to be fixed
#define MPQ_FILE_PATCH_FILE 0x00100000 // The file is a patch file. Raw file data begin with TPatchInfo structure
#define MPQ_FILE_SINGLE_UNIT 0x01000000 // File is stored as a single unit, rather than split into sectors (Thx, Quantam)
@@ -287,7 +287,7 @@ extern "C" {
#define PATCH_METADATA_NAME "(patch_metadata)"
#define MPQ_FORMAT_VERSION_1 0 // Up to The Burning Crusade
-#define MPQ_FORMAT_VERSION_2 1 // The Burning Crusade and newer
+#define MPQ_FORMAT_VERSION_2 1 // The Burning Crusade and newer
#define MPQ_FORMAT_VERSION_3 2 // WoW Cataclysm Beta
#define MPQ_FORMAT_VERSION_4 3 // WoW Cataclysm and newer
@@ -382,7 +382,7 @@ extern "C" {
#define ERROR_WEAK_SIGNATURE_ERROR 3 // There is a weak signature but sign check failed
#define ERROR_STRONG_SIGNATURE_OK 4 // There is a strong signature and sign check passed
#define ERROR_STRONG_SIGNATURE_ERROR 5 // There is a strong signature but sign check failed
-
+
#ifndef MD5_DIGEST_SIZE
#define MD5_DIGEST_SIZE 0x10
#endif
@@ -474,7 +474,7 @@ typedef enum _SFileInfoClass
#define CCB_COPYING_NON_MPQ_DATA 3 // Copying non-MPQ data: No params used
#define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total)
#define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used
-
+
typedef void (WINAPI * SFILE_DOWNLOAD_CALLBACK)(void * pvUserData, ULONGLONG ByteOffset, DWORD dwTotalBytes);
typedef void (WINAPI * SFILE_ADDFILE_CALLBACK)(void * pvUserData, DWORD dwBytesWritten, DWORD dwTotalBytes, bool bFinalCall);
typedef void (WINAPI * SFILE_COMPACT_CALLBACK)(void * pvUserData, DWORD dwWorkType, ULONGLONG BytesProcessed, ULONGLONG TotalBytes);
@@ -545,14 +545,14 @@ typedef struct _TMPQHeader
// Offset to the beginning of the hash table, relative to the beginning of the archive.
DWORD dwHashTablePos;
-
+
// Offset to the beginning of the block table, relative to the beginning of the archive.
DWORD dwBlockTablePos;
-
+
// Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for
// the original MoPaQ format, or less than 2^20 for the Burning Crusade format.
DWORD dwHashTableSize;
-
+
// Number of entries in the block table
DWORD dwBlockTableSize;
@@ -597,7 +597,7 @@ typedef struct _TMPQHeader
// Size of raw data chunk to calculate MD5.
// MD5 of each data chunk follows the raw file data.
- DWORD dwRawChunkSize;
+ DWORD dwRawChunkSize;
// MD5 of MPQ tables
unsigned char MD5_BlockTable[MD5_DIGEST_SIZE]; // MD5 of the block table before decryption
@@ -614,7 +614,7 @@ typedef struct _TMPQHash
{
// The hash of the file path, using method A.
DWORD dwName1;
-
+
// The hash of the file path, using method B.
DWORD dwName2;
@@ -651,16 +651,16 @@ typedef struct _TMPQBlock
{
// Offset of the beginning of the file, relative to the beginning of the archive.
DWORD dwFilePos;
-
+
// Compressed file size
DWORD dwCSize;
-
+
// Only valid if the block is a file; otherwise meaningless, and should be 0.
// If the file is compressed, this is the size of the uncompressed file data.
- DWORD dwFSize;
-
+ DWORD dwFSize;
+
// Flags for the file. See MPQ_FILE_XXXX constants
- DWORD dwFlags;
+ DWORD dwFlags;
} TMPQBlock;
// Patch file information, preceding the sector offset table
@@ -825,7 +825,7 @@ typedef struct _TMPQArchive
TMPQHetTable * pHetTable; // HET table
TFileEntry * pFileTable; // File table
HASH_STRING pfnHashString; // Hashing function that will convert the file name into hash
-
+
TMPQUserData UserData; // MPQ user data. Valid only when ID_MPQ_USERDATA has been found
DWORD HeaderData[MPQ_HEADER_DWORDS]; // Storage for MPQ header
@@ -849,7 +849,7 @@ typedef struct _TMPQArchive
ULONGLONG CompactBytesProcessed; // Amount of bytes that have been processed during a particular compact call
ULONGLONG CompactTotalBytes; // Total amount of bytes to be compacted
void * pvCompactUserData; // User data thats passed to the callback
-} TMPQArchive;
+} TMPQArchive;
// File handle structure
typedef struct _TMPQFile
@@ -1075,8 +1075,8 @@ bool WINAPI SFileWriteFile(HANDLE hFile, const void * pvData, DWORD dwSize, DW
bool WINAPI SFileFinishFile(HANDLE hFile);
bool WINAPI SFileAddFileEx(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwCompression, DWORD dwCompressionNext = MPQ_COMPRESSION_NEXT_SAME);
-bool WINAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags);
-bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality);
+bool WINAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags);
+bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality);
bool WINAPI SFileRemoveFile(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope);
bool WINAPI SFileRenameFile(HANDLE hMpq, const char * szOldFileName, const char * szNewFileName);
bool WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale);
diff --git a/src/adpcm/adpcm.cpp b/src/adpcm/adpcm.cpp
index c8086ab..fb0efbf 100644
--- a/src/adpcm/adpcm.cpp
+++ b/src/adpcm/adpcm.cpp
@@ -108,7 +108,7 @@ class TADPCMStream
unsigned char * pbBufferEnd;
unsigned char * pbBuffer;
-};
+};
//----------------------------------------------------------------------------
// Local functions
@@ -215,7 +215,7 @@ int CompressADPCM(void * pvOutBuffer, int cbOutBuffer, void * pvInBuffer, int cb
// Get the initial index
ChannelIndex = ChannelCount - 1;
-
+
// Now keep reading the input data as long as there is something in the input buffer
while(is.ReadWordSample(InputSample))
{
@@ -240,7 +240,7 @@ int CompressADPCM(void * pvOutBuffer, int cbOutBuffer, void * pvInBuffer, int cb
{
if(StepIndexes[ChannelIndex] != 0)
StepIndexes[ChannelIndex]--;
-
+
os.WriteByteSample(0x80);
}
else
@@ -284,7 +284,7 @@ int CompressADPCM(void * pvOutBuffer, int cbOutBuffer, void * pvInBuffer, int cb
// Write the encoded sample to the output stream
if(!os.WriteByteSample((unsigned char)EncodedSample))
break;
-
+
// Calculates the step index to use for the next encode
StepIndexes[ChannelIndex] = GetNextStepIndex(StepIndexes[ChannelIndex], EncodedSample);
}
@@ -377,7 +377,7 @@ int DecompressADPCM(void * pvOutBuffer, int cbOutBuffer, void * pvInBuffer, int
// Encode one sample
PredictedSamples[ChannelIndex] = (short)DecodeSample(PredictedSamples[ChannelIndex],
- EncodedSample,
+ EncodedSample,
StepSize,
StepSize >> BitShift);
diff --git a/src/huffman/huff.cpp b/src/huffman/huff.cpp
index fa0964d..6930354 100644
--- a/src/huffman/huff.cpp
+++ b/src/huffman/huff.cpp
@@ -15,10 +15,10 @@
/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */
/* 09.01.13 3.00 Lad Refactored, beautified, documented :-) */
/*****************************************************************************/
-
+
#include <assert.h>
#include <string.h>
-
+
#include "huff.h"
//-----------------------------------------------------------------------------
@@ -67,7 +67,7 @@ static unsigned char ByteToWeight_01[] =
0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x4B,
0x00, 0x00
};
-
+
// Data for compression type 0x02
static unsigned char ByteToWeight_02[] =
{
@@ -89,7 +89,7 @@ static unsigned char ByteToWeight_02[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
-
+
// Data for compression type 0x03
static unsigned char ByteToWeight_03[] =
{
@@ -111,7 +111,7 @@ static unsigned char ByteToWeight_03[] =
0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11,
0x00, 0x00
};
-
+
// Data for compression type 0x04
static unsigned char ByteToWeight_04[] =
{
@@ -133,7 +133,7 @@ static unsigned char ByteToWeight_04[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
-
+
// Data for compression type 0x05
static unsigned char ByteToWeight_05[] =
{
@@ -155,7 +155,7 @@ static unsigned char ByteToWeight_05[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
-
+
// Data for compression type 0x06
static unsigned char ByteToWeight_06[] =
{
@@ -177,7 +177,7 @@ static unsigned char ByteToWeight_06[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
-
+
// Data for compression type 0x07
static unsigned char ByteToWeight_07[] =
{
@@ -199,7 +199,7 @@ static unsigned char ByteToWeight_07[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
-
+
// Data for compression type 0x08
static unsigned char ByteToWeight_08[] =
{
@@ -235,7 +235,7 @@ static unsigned char * WeightTables[0x09] =
ByteToWeight_08
};
-//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
// Debug/diagnostics
#ifdef _DEBUG
@@ -306,7 +306,7 @@ unsigned int TInputStream::Get1Bit()
BitCount--;
return OneBit;
-}
+}
// Gets the whole byte from the input stream.
unsigned int TInputStream::Get8Bits()
@@ -363,13 +363,13 @@ void TOutputStream::PutBits(unsigned int dwValue, unsigned int nBitCount)
{
BitBuffer |= (dwValue << BitCount);
BitCount += nBitCount;
-
+
// Flush completed bytes
while(BitCount >= 8)
{
if(pbOutBuffer < pbOutBufferEnd)
*pbOutBuffer++ = (unsigned char)BitBuffer;
-
+
BitBuffer >>= 8;
BitCount -= 8;
}
@@ -402,7 +402,7 @@ void THTreeItem::RemoveItem()
//-----------------------------------------------------------------------------
// THuffmannTree class functions
-
+
THuffmannTree::THuffmannTree(bool bCompression)
{
pFirst = pLast = LIST_HEAD();
@@ -439,7 +439,7 @@ void THuffmannTree::InsertItem(THTreeItem * pNewItem, TInsertPoint InsertPoint,
{
// Remove the item from the tree
pNewItem->RemoveItem();
-
+
if(pInsertPoint == NULL)
pInsertPoint = LIST_HEAD();
@@ -448,7 +448,7 @@ void THuffmannTree::InsertItem(THTreeItem * pNewItem, TInsertPoint InsertPoint,
case InsertAfter:
LinkTwoItems(pInsertPoint, pNewItem);
return;
-
+
case InsertBefore:
pNewItem->pNext = pInsertPoint; // Set next item (or pointer to pointer to first item)
pNewItem->pPrev = pInsertPoint->pPrev; // Set prev item (or last item in the tree)
@@ -495,7 +495,7 @@ THTreeItem * THuffmannTree::CreateNewItem(unsigned int DecompressedValue, unsign
pNewItem->pParent = NULL;
pNewItem->pChildLo = NULL;
}
-
+
return pNewItem;
}
@@ -529,16 +529,16 @@ bool THuffmannTree::BuildTree(unsigned int CompressionType)
THTreeItem * pChildHi;
unsigned char * WeightTable;
unsigned int MaxWeight; // [ESP+10] - The greatest character found in table
-
+
// Clear all pointers in HTree item array
memset(ItemsByByte, 0, sizeof(ItemsByByte));
MaxWeight = 0;
-
+
// Ensure that the compression type is in range
if((CompressionType & 0x0F) > 0x08)
return false;
WeightTable = WeightTables[CompressionType & 0x0F];
-
+
// Build the linear list of entries that is sorted by byte weight
for(unsigned int i = 0; i < 0x100; i++)
{
@@ -552,11 +552,11 @@ bool THuffmannTree::BuildTree(unsigned int CompressionType)
MaxWeight = FixupItemPosByWeight(pNewItem, MaxWeight);
}
}
-
+
// Insert termination entries at the end of the list
ItemsByByte[0x100] = CreateNewItem(0x100, 1, InsertBefore);
ItemsByByte[0x101] = CreateNewItem(0x101, 1, InsertBefore);
-
+
// Now we need to build the tree. We start at the last entry
// and go backwards to the first one
pChildLo = pLast;
@@ -598,7 +598,7 @@ void THuffmannTree::IncWeightsAndRebalance(THTreeItem * pItem)
THTreeItem * pChildHi; // The higher-weight child
THTreeItem * pChildLo; // The lower-weight child
THTreeItem * pParent;
-
+
// Climb up the tree and increment weight of each tree item
for(; pItem != NULL; pItem = pItem->pParent)
{
@@ -615,11 +615,11 @@ void THuffmannTree::IncWeightsAndRebalance(THTreeItem * pItem)
// Move the previous item to the RIGHT from the given item
pChildHi->RemoveItem();
LinkTwoItems(pItem, pChildHi);
-
+
// Move the given item AFTER the greater-weight tree item
pItem->RemoveItem();
LinkTwoItems(pHigherItem, pItem);
-
+
// We need to maintain the tree so that pChildHi->Weight is >= pChildLo->Weight.
// Rebalance the tree accordingly.
pChildLo = pChildHi->pParent->pChildLo;
@@ -703,7 +703,7 @@ unsigned int THuffmannTree::DecodeOneByte(TInputStream * is)
// Get the eventual quick-link index
ItemLinkIndex = is->Peek7Bits();
-
+
// Is the quick-link item valid?
if(QuickLinks[ItemLinkIndex].ValidValue > MinValidValue)
{
@@ -783,14 +783,14 @@ unsigned int THuffmannTree::Compress(TOutputStream * os, void * pvInBuffer, int
unsigned char * pbInBuffer = (unsigned char *)pvInBuffer;
unsigned char * pbOutBuff = os->pbOutBuffer;
unsigned char InputByte;
-
+
if(!BuildTree(CompressionType))
return 0;
bIsCmp0 = (CompressionType == 0);
// Store the compression type into output buffer
os->PutBits(CompressionType, 8);
-
+
// Process the entire input buffer
while(pbInBuffer < pbInBufferEnd)
{
@@ -802,10 +802,10 @@ unsigned int THuffmannTree::Compress(TOutputStream * os, void * pvInBuffer, int
{
// Encode the relationship
EncodeOneByte(os, ItemsByByte[0x101]);
-
+
// Store the loaded byte into output stream
os->PutBits(InputByte, 8);
-
+
if(!InsertNewBranchAndRebalance(pLast->DecompressedValue, InputByte))
return 0;
@@ -814,28 +814,28 @@ unsigned int THuffmannTree::Compress(TOutputStream * os, void * pvInBuffer, int
IncWeightsAndRebalance(ItemsByByte[InputByte]);
continue;
}
-
+
IncWeightsAndRebalance(ItemsByByte[InputByte]);
}
else
{
EncodeOneByte(os, ItemsByByte[InputByte]);
}
-
+
if(bIsCmp0)
{
IncWeightsAndRebalance(ItemsByByte[InputByte]);
}
}
-
+
// Put the termination mark to the compressed stream
EncodeOneByte(os, ItemsByByte[0x100]);
-
+
// Flush the remaining bits
os->Flush();
return (unsigned int)(os->pbOutBuffer - pbOutBuff);
}
-
+
// Decompression using Huffman tree (1500E450)
unsigned int THuffmannTree::Decompress(void * pvOutBuffer, unsigned int cbOutLength, TInputStream * is)
{
@@ -843,19 +843,19 @@ unsigned int THuffmannTree::Decompress(void * pvOutBuffer, unsigned int cbOutLen
unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer;
unsigned int DecompressedValue = 0;
unsigned int CompressionType = 0;
-
+
// Test the output length. Must not be NULL.
if(cbOutLength == 0)
return 0;
-
+
// Get the compression type from the input stream
CompressionType = is->Get8Bits();
bIsCmp0 = (CompressionType == 0) ? 1 : 0;
-
+
// Build the Huffman tree
if(!BuildTree(CompressionType))
return 0;
-
+
// Process the entire input buffer until end of the stream
while((DecompressedValue = DecodeOneByte(is)) != 0x100)
{
@@ -875,18 +875,18 @@ unsigned int THuffmannTree::Decompress(void * pvOutBuffer, unsigned int cbOutLen
if(bIsCmp0 == 0)
IncWeightsAndRebalance(ItemsByByte[DecompressedValue]);
}
-
+
// A byte successfully decoded - store it in the output stream
*pbOutBuffer++ = (unsigned char)DecompressedValue;
if(pbOutBuffer >= pbOutBufferEnd)
break;
-
+
if(bIsCmp0)
{
IncWeightsAndRebalance(ItemsByByte[DecompressedValue]);
}
}
-
+
return (unsigned int)(pbOutBuffer - (unsigned char *)pvOutBuffer);
}
diff --git a/src/huffman/huff.h b/src/huffman/huff.h
index d2c3e3e..b75acbb 100644
--- a/src/huffman/huff.h
+++ b/src/huffman/huff.h
@@ -9,13 +9,13 @@
/* 03.05.03 2.00 Lad Added compression */
/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */
/*****************************************************************************/
-
+
#ifndef __HUFFMAN_H__
#define __HUFFMAN_H__
//-----------------------------------------------------------------------------
// Defines
-
+
#define HUFF_ITEM_COUNT 0x203 // Number of items in the item pool
#define LINK_ITEM_COUNT 0x80 // Maximum number of quick-link items
@@ -32,23 +32,23 @@ class TInputStream
unsigned int Peek7Bits();
unsigned int Get8Bits();
void SkipBits(unsigned int BitCount);
-
+
unsigned char * pbInBufferEnd; // End position in the the input buffer
unsigned char * pbInBuffer; // Current position in the the input buffer
unsigned int BitBuffer; // Input bit buffer
unsigned int BitCount; // Number of bits remaining in 'dwBitBuff'
};
-
+
// Output stream for Huffmann compression
class TOutputStream
{
public:
-
+
TOutputStream(void * pvOutBuffer, size_t cbOutLength);
void PutBits(unsigned int dwValue, unsigned int nBitCount);
void Flush();
-
+
unsigned char * pbOutBufferEnd; // End position in the output buffer
unsigned char * pbOutBuffer; // Current position in the output buffer
unsigned int BitBuffer; // Bit buffer
@@ -72,7 +72,7 @@ struct THTreeItem
void RemoveItem();
// void RemoveEntry();
-
+
THTreeItem * pNext; // Pointer to lower-weight tree item
THTreeItem * pPrev; // Pointer to higher-weight item
unsigned int DecompressedValue; // 08 - Decompressed byte value (also index in the array)
@@ -87,7 +87,7 @@ struct THTreeItem
// decompressing a bit faster. Sometimes it can even get the decompressed
// byte directly.
struct TQuickLink
-{
+{
unsigned int ValidValue; // If greater than THuffmannTree::MinValidValue, the entry is valid
unsigned int ValidBits; // Number of bits that are valid for this item link
union
@@ -96,7 +96,7 @@ struct TQuickLink
unsigned int DecompressedValue; // Value for direct decompression
};
};
-
+
// Structure for Huffman tree (Size 0x3674 bytes). Because I'm not expert
// for the decompression, I do not know actually if the class is really a Hufmann
@@ -104,7 +104,7 @@ struct TQuickLink
class THuffmannTree
{
public:
-
+
THuffmannTree(bool bCompression);
~THuffmannTree();
@@ -125,17 +125,17 @@ class THuffmannTree
unsigned int Compress(TOutputStream * os, void * pvInBuffer, int cbInBuffer, int nCmpType);
unsigned int Decompress(void * pvOutBuffer, unsigned int cbOutLength, TInputStream * is);
-
+
THTreeItem ItemBuffer[HUFF_ITEM_COUNT]; // Buffer for tree items. No memory allocation is needed
unsigned int ItemsUsed; // Number of tree items used from ItemBuffer
-
+
// Head of the linear item list
THTreeItem * pFirst; // Pointer to the highest weight item
THTreeItem * pLast; // Pointer to the lowest weight item
THTreeItem * ItemsByByte[0x102]; // Array of item pointers, one for each possible byte value
TQuickLink QuickLinks[LINK_ITEM_COUNT]; // Array of quick-link items
-
+
unsigned int MinValidValue; // A minimum value of TQDecompress::ValidValue to be considered valid
unsigned int bIsCmp0; // 1 if compression type 0
};
diff --git a/src/pklib/explode.c b/src/pklib/explode.c
index 7d63687..0f551d8 100644
--- a/src/pklib/explode.c
+++ b/src/pklib/explode.c
@@ -16,7 +16,7 @@
#include "pklib.h"
-#define PKDCL_OK 0
+#define PKDCL_OK 0
#define PKDCL_STREAM_END 1 // All data from the input stream is read
#define PKDCL_NEED_DICT 2 // Need more data (dictionary)
#define PKDCL_CONTINUE 10 // Internal flag, not returned to user
@@ -31,7 +31,7 @@ char CopyrightPkware[] = "PKWARE Data Compression Library for Win32\r\n"
//-----------------------------------------------------------------------------
// Tables
-unsigned char DistBits[0x40] =
+unsigned char DistBits[0x40] =
{
0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
@@ -39,7 +39,7 @@ unsigned char DistBits[0x40] =
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08
};
-unsigned char DistCode[0x40] =
+unsigned char DistCode[0x40] =
{
0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A,
0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C,
@@ -88,7 +88,7 @@ unsigned char ChBitsAsc[0x100] =
0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D
};
-unsigned short ChCodeAsc[0x100] =
+unsigned short ChCodeAsc[0x100] =
{
0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0,
0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0,
@@ -121,7 +121,7 @@ unsigned short ChCodeAsc[0x100] =
0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900,
0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600,
0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200,
- 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000
+ 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000
};
//-----------------------------------------------------------------------------
@@ -278,11 +278,11 @@ static unsigned int DecodeLit(TDcmpStruct * pWork)
{
// Remove one bit from the input data
if(WasteBits(pWork, 1))
- return 0x306;
-
+ return 0x306;
+
// The next 8 bits hold the index to the length code table
length_code = pWork->LengthCodes[pWork->bit_buff & 0xFF];
-
+
// Remove the apropriate number of bits
if(WasteBits(pWork, pWork->LenBits[length_code]))
return 0x306;
@@ -442,7 +442,7 @@ static unsigned int Expand(TDcmpStruct * pWork)
{
pWork->out_buff[pWork->outputPos++] = (unsigned char)next_literal;
}
-
+
// Flush the output buffer, if number of extracted bytes has reached the end
if(pWork->outputPos >= 0x2000)
{
@@ -495,7 +495,7 @@ unsigned int PKEXPORT explode(
pWork->in_pos = 3; // Position in input buffer
// Test for the valid dictionary size
- if(4 > pWork->dsize_bits || pWork->dsize_bits > 6)
+ if(4 > pWork->dsize_bits || pWork->dsize_bits > 6)
return CMP_INVALID_DICTSIZE;
pWork->dsize_mask = 0xFFFF >> (0x10 - pWork->dsize_bits); // Shifted by 'sar' instruction
@@ -517,6 +517,6 @@ unsigned int PKEXPORT explode(
GenDecodeTabs(pWork->DistPosCodes, DistCode, pWork->DistBits, sizeof(pWork->DistBits));
if(Expand(pWork) != 0x306)
return CMP_NO_ERROR;
-
+
return CMP_ABORT;
}
diff --git a/src/pklib/implode.c b/src/pklib/implode.c
index f34eb22..90cb482 100644
--- a/src/pklib/implode.c
+++ b/src/pklib/implode.c
@@ -50,7 +50,7 @@ static void SortBuffer(TCmpStruct * pWork, unsigned char * buffer_begin, unsigne
// Zero the entire "phash_to_index" table
memset(pWork->phash_to_index, 0, sizeof(pWork->phash_to_index));
-
+
// Step 1: Count amount of each PAIR_HASH in the input buffer
// The table will look like this:
// offs 0x000: Number of occurences of PAIR_HASH 0
@@ -60,7 +60,7 @@ static void SortBuffer(TCmpStruct * pWork, unsigned char * buffer_begin, unsigne
for(buffer_ptr = buffer_begin; buffer_ptr < buffer_end; buffer_ptr++)
pWork->phash_to_index[BYTE_PAIR_HASH(buffer_ptr)]++;
- // Step 2: Convert the table to the array of PAIR_HASH amounts.
+ // Step 2: Convert the table to the array of PAIR_HASH amounts.
// Each element contains count of PAIR_HASHes that is less or equal
// to element index
// The table will look like this:
@@ -128,7 +128,7 @@ static void OutputBits(TCmpStruct * pWork, unsigned int nbits, unsigned long bit
{
pWork->out_bytes++;
bit_buff >>= (8 - out_bits);
-
+
pWork->out_buff[pWork->out_bytes] = (unsigned char)bit_buff;
pWork->out_bits &= 7;
}
@@ -146,7 +146,7 @@ static void OutputBits(TCmpStruct * pWork, unsigned int nbits, unsigned long bit
// This function searches for a repetition
// (a previous occurence of the current byte sequence)
-// Returns length of the repetition, and stores the backward distance
+// Returns length of the repetition, and stores the backward distance
// to pWork structure.
static unsigned int FindRep(TCmpStruct * pWork, unsigned char * input_data)
{
@@ -187,7 +187,7 @@ static unsigned int FindRep(TCmpStruct * pWork, unsigned char * input_data)
phash_offs = pWork->phash_offs + phash_offs_index;
prev_repetition = pWork->work_buff + phash_offs[0];
repetition_limit = input_data - 1;
-
+
// If the current PAIR_HASH was not encountered before,
// we haven't found a repetition.
if(prev_repetition >= repetition_limit)
@@ -213,7 +213,7 @@ static unsigned int FindRep(TCmpStruct * pWork, unsigned char * input_data)
{
prev_repetition++;
input_data_ptr++;
-
+
// Are the bytes different ?
if(*prev_repetition != *input_data_ptr)
break;
@@ -309,7 +309,7 @@ static unsigned int FindRep(TCmpStruct * pWork, unsigned char * input_data)
pWork->offs09BC[++offs_in_rep] = ++di_val;
}
- //
+ //
// Now go through all the repetitions from the first found one
// to the current input data, and check if any of them migh be
// a start of a greater sequence match.
@@ -318,7 +318,7 @@ static unsigned int FindRep(TCmpStruct * pWork, unsigned char * input_data)
prev_repetition = pWork->work_buff + phash_offs[0];
prev_rep_end = prev_repetition + rep_length;
rep_length2 = rep_length;
-
+
for(;;)
{
rep_length2 = pWork->offs09BC[rep_length2];
@@ -412,7 +412,7 @@ static void WriteCmpData(TCmpStruct * pWork)
unsigned int save_rep_length; // Saved length of current repetition
unsigned int save_distance = 0; // Saved distance of current repetition
unsigned int rep_length; // Length of the found repetition
- unsigned int phase = 0; //
+ unsigned int phase = 0; //
// Store the compression type and dictionary size
pWork->out_buff[0] = (char)pWork->ctype;
@@ -452,12 +452,12 @@ static void WriteCmpData(TCmpStruct * pWork)
input_data_end = pWork->work_buff + pWork->dsize_bytes + total_loaded;
if(input_data_ended)
input_data_end += 0x204;
-
+
//
// Warning: The end of the buffer passed to "SortBuffer" is actually 2 bytes beyond
// valid data. It is questionable if this is actually a bug or not,
// but it might cause the compressed data output to be dependent on random bytes
- // that are in the buffer.
+ // that are in the buffer.
// To prevent that, the calling application must always zero the compression
// buffer before passing it to "implode"
//
@@ -466,7 +466,7 @@ static void WriteCmpData(TCmpStruct * pWork)
// previously compressed data, if any.
switch(phase)
{
- case 0:
+ case 0:
SortBuffer(pWork, input_data, input_data_end + 1);
phase++;
if(pWork->dsize_bytes != 0x1000)
diff --git a/src/pklib/pklib.h b/src/pklib/pklib.h
index 6f7e933..d9b2a70 100644
--- a/src/pklib/pklib.h
+++ b/src/pklib/pklib.h
@@ -32,7 +32,7 @@
#ifndef PKEXPORT
#ifdef WIN32
-#define PKEXPORT __cdecl // Use for normal __cdecl calling
+#define PKEXPORT __cdecl // Use for normal __cdecl calling
#else
#define PKEXPORT
#endif
@@ -45,7 +45,7 @@
typedef struct
{
unsigned int distance; // 0000: Backward distance of the currently found repetition, decreased by 1
- unsigned int out_bytes; // 0004: # bytes available in out_buff
+ unsigned int out_bytes; // 0004: # bytes available in out_buff
unsigned int out_bits; // 0008: # of bits available in the last out byte
unsigned int dsize_bits; // 000C: Number of bits needed for dictionary size. 4 = 0x400, 5 = 0x800, 6 = 0x1000
unsigned int dsize_mask; // 0010: Bit mask for dictionary. 0x0F = 0x400, 0x1F = 0x800, 0x3F = 0x1000
@@ -55,14 +55,14 @@ typedef struct
unsigned char dist_codes[0x40]; // 005C: Distance codes
unsigned char nChBits[0x306]; // 009C: Table of literal bit lengths to be put to the output stream
unsigned short nChCodes[0x306]; // 03A2: Table of literal codes to be put to the output stream
- unsigned short offs09AE; // 09AE:
+ unsigned short offs09AE; // 09AE:
void * param; // 09B0: User parameter
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 9B4
void (*write_buf)(char *buf, unsigned int *size, void *param); // 9B8
unsigned short offs09BC[0x204]; // 09BC:
- unsigned long offs0DC4; // 0DC4:
+ unsigned long offs0DC4; // 0DC4:
unsigned short phash_to_index[0x900]; // 0DC8: Array of indexes (one for each PAIR_HASH) to the "pair_hash_offsets" table
unsigned short phash_to_index_end; // 1FC8: End marker for "phash_to_index" table
char out_buff[0x802]; // 1FCA: Compressed data
@@ -99,15 +99,15 @@ typedef struct
unsigned char in_buff[0x800]; // 2234: Buffer for data to be decompressed
unsigned char DistPosCodes[0x100]; // 2A34: Table of distance position codes
unsigned char LengthCodes[0x100]; // 2B34: Table of length codes
- unsigned char offs2C34[0x100]; // 2C34: Buffer for
- unsigned char offs2D34[0x100]; // 2D34: Buffer for
- unsigned char offs2E34[0x80]; // 2E34: Buffer for
- unsigned char offs2EB4[0x100]; // 2EB4: Buffer for
- unsigned char ChBitsAsc[0x100]; // 2FB4: Buffer for
+ unsigned char offs2C34[0x100]; // 2C34: Buffer for
+ unsigned char offs2D34[0x100]; // 2D34: Buffer for
+ unsigned char offs2E34[0x80]; // 2E34: Buffer for
+ unsigned char offs2EB4[0x100]; // 2EB4: Buffer for
+ unsigned char ChBitsAsc[0x100]; // 2FB4: Buffer for
unsigned char DistBits[0x40]; // 30B4: Numbers of bytes to skip copied block length
unsigned char LenBits[0x10]; // 30F4: Numbers of bits for skip copied block length
unsigned char ExLenBits[0x10]; // 3104: Number of valid bits for copied block
- unsigned short LenBase[0x10]; // 3114: Buffer for
+ unsigned short LenBase[0x10]; // 3114: Buffer for
} TDcmpStruct;
#define EXP_BUFFER_SIZE sizeof(TDcmpStruct) // Size of decompression structure
diff --git a/src/resource.h b/src/resource.h
index c94b06b..8821947 100644
--- a/src/resource.h
+++ b/src/resource.h
@@ -4,7 +4,7 @@
//
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/sparse/sparse.cpp b/src/sparse/sparse.cpp
index 4fe0981..6d1b621 100644
--- a/src/sparse/sparse.cpp
+++ b/src/sparse/sparse.cpp
@@ -14,10 +14,10 @@
/* 19.11.03 1.01 Dan Big endian handling */
/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */
/*****************************************************************************/
-
+
#include <assert.h>
#include <string.h>
-
+
#include "sparse.h"
//-----------------------------------------------------------------------------
@@ -88,7 +88,7 @@ void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i
// Put marker that means "0x80 of nonzeros"
*pbOutBuffer++ = 0xFF;
memcpy(pbOutBuffer, pbInBuffer, 0x80);
-
+
// Adjust counter of nonzeros and both pointers
NumberOfNonZeros -= 0x80;
pbOutBuffer += 0x80;
@@ -108,7 +108,7 @@ void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i
// Put marker that means "1 nonzero byte"
*pbOutBuffer++ = 0x80;
memcpy(pbOutBuffer, pbInBuffer, 1);
-
+
// Adjust counter of nonzeros and both pointers
NumberOfNonZeros--;
pbOutBuffer++;
@@ -171,7 +171,7 @@ void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i
// Put marker that means "Several zeros"
*pbOutBuffer++ = (unsigned char)(NumberOfZeros - 3);
-
+
// Adjust pointer
pbInBuffer += NumberOfZeros;
}
@@ -196,7 +196,7 @@ void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, i
// Terminate with a marker that means "0x80 of nonzeros"
*pbOutBuffer++ = 0xFF;
memcpy(pbOutBuffer, pbInBuffer, NumberOfNonZeros);
-
+
// Adjust pointer
pbOutBuffer += NumberOfNonZeros;
break;