*c = 0xffff;
}
-void crc_update(unsigned short *c, unsigned char val) {
+void crc_update(unsigned short *m_crc, unsigned char val) {
int i, j;
- m_crc ^= val;
+ *m_crc ^= val;
for (i = 0; i < 8; i++) {
- j = m_crc & 1;
- m_crc >>= 1;
- if (j) m_crc ^= 0x8408;
+ j = *m_crc & 1;
+ *m_crc >>= 1;
+ if (j)
+ *m_crc ^= 0x8408;
}
}
unsigned short crc_get_full(unsigned char *data, size_t len, bool onecomp) {
unsigned short c;
crc_init(&c);
- while (bcnt--)
- crc_update(&c, *bp++);
+ while (len--)
+ crc_update(&c, *(data++));
return onecomp ? ~c : c;
}
bool crc_check(unsigned short *c, char *crc) {
- return (((c & 0xff) == crc[0]) &&
- ((c >> 8) == crc[1]));
+ return (((*c & 0xff) == crc[0]) &&
+ ((*c >> 8) == crc[1]));
}
*
*/
+#include <sys/types.h>
+#include <stdbool.h>
+
#ifndef _CRC13239_H
#define _CRC13239_H
#define CRC_OK_RESIDUE 0xf0b8
void crc_init(unsigned short *c);
-void crc_update(unsigned short *c, unsigned char *val);
+void crc_update(unsigned short *c, unsigned char val);
unsigned short crc_get_full(unsigned char *data, size_t len, bool onecomp);
bool crc_check(unsigned short *c, char *crc);