X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/blobdiff_plain/a97855ded317db6025710edc487d337cbd5f0ad2..05b6bf30040b7d3f2219919168b4c159045a909b:/rsb-crc.c diff --git a/rsb-crc.c b/rsb-crc.c deleted file mode 100644 index 6a2bf99..0000000 --- a/rsb-crc.c +++ /dev/null @@ -1,54 +0,0 @@ -#include - -#define POLY 0x04c11db7 - -unsigned int rsb_crc(unsigned int r11_crc, unsigned char *r10_buf, unsigned int r14_len) { - unsigned int r6_pos = 0; - unsigned int r3_data; - int r5_bit; - - while (r6_pos < r14_len) { - r3_data = (*(r6_pos+r10_buf)) << 24; - r11_crc = r11_crc ^ r3_data; - - r5_bit = 8; - - do { - r3_data = r11_crc & 0x80000000; - - if (r3_data != 0) { - r3_data = r11_crc << 1; - r11_crc = r3_data ^ POLY; - } else { - r11_crc = r11_crc << 1; - } - r5_bit--; - } while (r5_bit); - - r6_pos++; - } - - return r11_crc; -} - -unsigned int rsb_crc2(unsigned char *r0_buf, unsigned int r1_buflen, unsigned int r2_magic, unsigned int *crc_out) { - unsigned int r4_len; - unsigned int file_crc; - - r4_len = *(unsigned int*)(r0_buf + 0x20); - - if (*((unsigned int*)(r0_buf + 0x24)) != r2_magic) - return 2; /* MAGIC does not match */ - - if (r1_buflen < r4_len) - return 3; /* image to small */ - - *crc_out = ~rsb_crc(~0x0, r0_buf, r4_len); - - file_crc = *((unsigned int*)(r0_buf + r4_len)); - - if (file_crc != *crc_out) - return 4; - - return 0; -}