SingingCat 0
application
checksums.c
1#include "main-header.h"
2long crc32(void *adr, int size) {
3 const uint8_t *bbuf = adr;
4
5 int i;
6 uint32_t crc = 0;
7
8 for (i = 0; i < size; i++) {
9 crc = crc + bbuf[i];
10 }
11 crc = 0xFFFFFFFF - crc;
12 return crc;
13}
14
15uint32_t calc_crc32(uint8_t *buf, int len, int chksumoffset) {
16 int i;
17 uint32_t crc = 0;
18
19 for (i = 0; i < len; i++) {
20 if ((chksumoffset >= 0) && (i >= chksumoffset) && (i <= chksumoffset + 3)) {
21 continue;
22 }
23 crc = crc + buf[i];
24 }
25 crc = 0xFFFFFFFF - crc;
26 return crc;
27}