diff options
author | Shauren <shauren.trinity@gmail.com> | 2020-05-07 14:39:40 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-05-07 14:39:40 +0200 |
commit | ea812fec1153280b94d2fff8bdefd678e86bddeb (patch) | |
tree | cd7d75fc98ab6cc2c975fe4db9be67ccb87f40c1 /dep/CascLib/src/common/Common.h | |
parent | dfdabdb97bdd776da4add3cd4f19cf5793160abf (diff) |
Dep/CascLib: Update to ladislav-zezula/CascLib@0a05c59eb8a3eab1bc5471f43934cd5f992f0aca
Diffstat (limited to 'dep/CascLib/src/common/Common.h')
-rw-r--r-- | dep/CascLib/src/common/Common.h | 39 |
1 files changed, 25 insertions, 14 deletions
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 @@ -166,6 +166,14 @@ void CASC_FREE(T *& ptr) } //----------------------------------------------------------------------------- +// 32-bit ROL + +inline DWORD Rol32(DWORD dwValue, DWORD dwRolCount) +{ + return (dwValue << dwRolCount) | (dwValue >> (32 - dwRolCount)); +} + +//----------------------------------------------------------------------------- // Big endian number manipulation inline DWORD ConvertBytesToInteger_2(LPBYTE ValueAsBytes) @@ -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 |