From ea812fec1153280b94d2fff8bdefd678e86bddeb Mon Sep 17 00:00:00 2001 From: Shauren Date: Thu, 7 May 2020 14:39:40 +0200 Subject: Dep/CascLib: Update to ladislav-zezula/CascLib@0a05c59eb8a3eab1bc5471f43934cd5f992f0aca --- dep/CascLib/src/common/Common.h | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'dep/CascLib/src/common/Common.h') diff --git a/dep/CascLib/src/common/Common.h b/dep/CascLib/src/common/Common.h index ddf8e136c9b..0037293f53d 100644 --- a/dep/CascLib/src/common/Common.h +++ b/dep/CascLib/src/common/Common.h @@ -165,6 +165,14 @@ void CASC_FREE(T *& ptr) ptr = NULL; } +//----------------------------------------------------------------------------- +// 32-bit ROL + +inline DWORD Rol32(DWORD dwValue, DWORD dwRolCount) +{ + return (dwValue << dwRolCount) | (dwValue >> (32 - dwRolCount)); +} + //----------------------------------------------------------------------------- // Big endian number manipulation @@ -246,18 +254,18 @@ inline ULONGLONG ConvertBytesToInteger_5(LPBYTE ValueAsBytes) inline void ConvertIntegerToBytes_4(DWORD Value, LPBYTE ValueAsBytes) { - ValueAsBytes[0] = (Value >> 0x18) & 0xFF; - ValueAsBytes[1] = (Value >> 0x10) & 0xFF; - ValueAsBytes[2] = (Value >> 0x08) & 0xFF; - ValueAsBytes[3] = (Value >> 0x00) & 0xFF; + ValueAsBytes[0] = (BYTE)((Value >> 0x18) & 0xFF); + ValueAsBytes[1] = (BYTE)((Value >> 0x10) & 0xFF); + ValueAsBytes[2] = (BYTE)((Value >> 0x08) & 0xFF); + ValueAsBytes[3] = (BYTE)((Value >> 0x00) & 0xFF); } inline void ConvertIntegerToBytes_4_LE(DWORD Value, LPBYTE ValueAsBytes) { - ValueAsBytes[0] = (Value >> 0x00) & 0xFF; - ValueAsBytes[1] = (Value >> 0x08) & 0xFF; - ValueAsBytes[2] = (Value >> 0x10) & 0xFF; - ValueAsBytes[3] = (Value >> 0x18) & 0xFF; + ValueAsBytes[0] = (BYTE)((Value >> 0x00) & 0xFF); + ValueAsBytes[1] = (BYTE)((Value >> 0x08) & 0xFF); + ValueAsBytes[2] = (BYTE)((Value >> 0x10) & 0xFF); + ValueAsBytes[3] = (BYTE)((Value >> 0x18) & 0xFF); } // Faster than memset(Buffer, 0, 0x10) @@ -313,14 +321,17 @@ size_t CascStrPrintf(wchar_t * buffer, size_t nCount, const wchar_t * format, .. //----------------------------------------------------------------------------- // String allocation -char * CascNewStr(const char * szString, size_t nCharsToReserve = 0); +char * CascNewStr(const char * szString, size_t nCharsToReserve = 0); wchar_t * CascNewStr(const wchar_t * szString, size_t nCharsToReserve = 0); +LPSTR CascNewStrT2A(LPCTSTR szString, size_t nCharsToReserve = 0); +LPTSTR CascNewStrA2T(LPCSTR szString, size_t nCharsToReserve = 0); + size_t CombinePath(LPTSTR szBuffer, size_t nMaxChars, char chSeparator, va_list argList); size_t CombinePath(LPTSTR szBuffer, size_t nMaxChars, char chSeparator, ...); LPTSTR CombinePath(LPCTSTR szPath, LPCTSTR szSubDir); LPTSTR GetLastPathPart(LPTSTR szWorkPath); -bool CutLastPathPart(TCHAR * szWorkPath); +bool CutLastPathPart(LPTSTR szWorkPath); size_t NormalizeFileName_UpperBkSlash(char * szNormName, const char * szFileName, size_t cchMaxChars); size_t NormalizeFileName_LowerSlash(char * szNormName, const char * szFileName, size_t cchMaxChars); @@ -328,10 +339,10 @@ size_t NormalizeFileName_LowerSlash(char * szNormName, const char * szFileName, ULONGLONG CalcNormNameHash(const char * szNormName, size_t nLength); ULONGLONG CalcFileNameHash(const char * szFileName); -int ConvertDigitToInt32(const TCHAR * szString, PDWORD PtrValue); -int ConvertStringToInt08(const char * szString, PDWORD PtrValue); -int ConvertStringToInt32(const TCHAR * szString, size_t nMaxDigits, PDWORD PtrValue); -int ConvertStringToBinary(const char * szString, size_t nMaxDigits, LPBYTE pbBinary); +DWORD ConvertDigitToInt32(LPCTSTR szString, PDWORD PtrValue); +DWORD ConvertStringToInt08(LPCSTR szString, PDWORD PtrValue); +DWORD ConvertStringToInt32(LPCTSTR szString, size_t nMaxDigits, PDWORD PtrValue); +DWORD ConvertStringToBinary(LPCSTR szString, size_t nMaxDigits, LPBYTE pbBinary); //----------------------------------------------------------------------------- // Conversion from binary array to string. The caller must ensure that -- cgit v1.2.3