diff options
author | George Hazan <ghazan@miranda.im> | 2019-09-06 12:34:16 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-09-06 12:34:16 +0300 |
commit | 0f6458567c38d7c6827161e0f18c115229660a7a (patch) | |
tree | c88357309b404753eb73ea60dabd6b421ce45d74 /plugins | |
parent | 16b82bf6044ef8bff1acca10b0759dc59068c498 (diff) |
PluginUpdater: copy of CRC32 calculation code isn't needed
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 56 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/stdafx.h | 7 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/unzipfile.cpp | 7 |
3 files changed, 8 insertions, 62 deletions
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 9c991c3462..1f0a35f304 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -70,59 +70,6 @@ void UnloadNetlib() hNetlibUser = nullptr;
}
-ULONG crc32_table[256];
-ULONG ulPolynomial = 0x04c11db7;
-
-//////////////////////////////////////////////////////////////
-// Reflection is a requirement for the official CRC-32 standard.
-// You can create CRCs without it, but they won't conform to the standard.
-//////////////////////////////////////////////////////////////////////////
-
-ULONG Reflect(ULONG ref, char ch)
-{
- // Used only by Init_CRC32_Table()
- ULONG value(0);
-
- // Swap bit 0 for bit 7
- // bit 1 for bit 6, etc.
- for(int i = 1; i < (ch + 1); i++)
- {
- if(ref & 1)
- value |= 1 << (ch - i);
- ref >>= 1;
- }
- return value;
-}
-
-void InitCrcTable()
-{
- // 256 values representing ASCII character codes.
- for(int i = 0; i <= 0xFF; i++)
- {
- crc32_table[i] = Reflect(i, 8) << 24;
- for (int j = 0; j < 8; j++)
- crc32_table[i] = (crc32_table[i] << 1) ^ (crc32_table[i] & (1 << 31) ? ulPolynomial : 0);
- crc32_table[i] = Reflect(crc32_table[i], 32);
- }
-}
-
-int Get_CRC(unsigned char* buffer, ULONG bufsize)
-{
- ULONG crc(0xffffffff);
- int len;
- len = bufsize;
- // Save the text in the buffer.
-
- // Perform the algorithm on each character
- // in the string, using the lookup table values.
-
- for(int i = 0; i < len; i++)
- crc = (crc >> 8) ^ crc32_table[(crc & 0xFF) ^ buffer[i]];
-
- // Exclusive OR the result with the beginning value.
- return crc^0xffffffff;
-}
-
int CompareHashes(const ServListEntry *p1, const ServListEntry *p2)
{
return _wcsicmp(p1->m_name, p2->m_name);
@@ -266,8 +213,7 @@ bool DownloadFile(FILEURL *pFileURL, HNETLIBCONN &nlc) if ((200 == pReply->resultCode) && (pReply->dataLength > 0)) {
// Check CRC sum
if (pFileURL->CRCsum) {
- InitCrcTable();
- int crc = Get_CRC((unsigned char*)pReply->pData, pReply->dataLength);
+ int crc = crc32(0, (unsigned char*)pReply->pData, pReply->dataLength);
if (crc != pFileURL->CRCsum) {
// crc check failed, try again
Netlib_LogfW(hNetlibUser,L"crc check failed for file %s",pFileURL->tszDiskPath);
diff --git a/plugins/PluginUpdater/src/stdafx.h b/plugins/PluginUpdater/src/stdafx.h index fad5955596..82ee85b081 100644 --- a/plugins/PluginUpdater/src/stdafx.h +++ b/plugins/PluginUpdater/src/stdafx.h @@ -44,6 +44,13 @@ Boston, MA 02111-1307, USA. #include <m_folders.h>
+extern "C"
+{
+ #include "../../libs/zlib/src/unzip.h"
+
+ void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def);
+}
+
#include "version.h"
#include "resource.h"
diff --git a/plugins/PluginUpdater/src/unzipfile.cpp b/plugins/PluginUpdater/src/unzipfile.cpp index f0f9406d12..50612e8218 100644 --- a/plugins/PluginUpdater/src/unzipfile.cpp +++ b/plugins/PluginUpdater/src/unzipfile.cpp @@ -19,13 +19,6 @@ Boston, MA 02111-1307, USA. #include "stdafx.h"
-extern "C"
-{
- #include "../../libs/zlib/src/unzip.h"
-
- void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def);
-}
-
static void PrepareFileName(wchar_t *dest, size_t destSize, const wchar_t *ptszPath, const wchar_t *ptszFileName)
{
mir_snwprintf(dest, destSize, L"%s\\%s", ptszPath, ptszFileName);
|