blob: 408af38e56366d42ef6e49b6dd986b6b12634a2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
Crc: module
{
PATH: con "/dis/lib/crc.dis";
CRCstate: adt {
crc: int;
crctab: array of int;
reg: int;
};
# setup crc table with given polynomial (if 0 default polynomial used)
# (the polynomial has an implicit top bit set)
# reg is the initial value of the CRC register
# (usually 0 but 16rfffffffrf in the CRC32 algorithm for example)
init: fn(poly: int, reg: int): ref CRCstate;
# calculate crc of first nb bytes in given array of bytes and return its value
# may be called repeatedly to calculate crc of a series of arrays of bytes
crc : fn(state: ref CRCstate, buf: array of byte, nb: int): int;
# reset crc state to its initial value
reset: fn(state: ref CRCstate);
};
|