summaryrefslogtreecommitdiff
path: root/plugins/FileAsMessage/src/crc32.cpp
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-07-18 06:59:36 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-07-18 06:59:36 +0000
commit3634576b3903f8316b1dcdc396a70f40fa43f5f5 (patch)
tree55f87e6fccf45c3b2e5b7adf12a1e959f2d6f12e /plugins/FileAsMessage/src/crc32.cpp
parent7a65cbd15d4f808f973d782deea2a5e1a02accd6 (diff)
ExtraIcon, Favcontacts, FileAsMessage, FingerPrintModPlus: changed folder structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@1006 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/FileAsMessage/src/crc32.cpp')
-rw-r--r--plugins/FileAsMessage/src/crc32.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/plugins/FileAsMessage/src/crc32.cpp b/plugins/FileAsMessage/src/crc32.cpp
new file mode 100644
index 0000000000..ab34393f8d
--- /dev/null
+++ b/plugins/FileAsMessage/src/crc32.cpp
@@ -0,0 +1,31 @@
+#include "main.h"
+
+const ulong CRCPoly = 0xEDB88320;
+ulong CRC32Table[256];
+
+void InitCRC32()
+{
+ for (UINT32 i = 0; i < 256; i++)
+ {
+ UINT32 r = i;
+ for (int j = 0; j < 8; j++)
+ if (r & 1)
+ r = (r >> 1) ^ CRCPoly;
+ else
+ r >>= 1;
+ CRC32Table[i] = r;
+ }
+}
+
+const ulong INITCRC = -1L;
+
+inline ulong UpdateCRC32(uchar val, ulong crc)
+{
+ return CRC32Table[(uchar)crc^val] ^ (crc>>8);
+}
+
+ulong memcrc32(uchar *ptr, int size, ulong crc )
+{
+ while(size--) crc = UpdateCRC32(*ptr++, crc);
+ return crc;
+}