Charles.Forsyth20060303-partialeea662d19 years agoHistory
62 lines · 1.6 KB · Text
RawDownload
.TH CRC 2.SH NAMEcrc \- Crc module.SH SYNOPSIS.EXinclude "crc.m";crc := load Crc Crc->PATH; CRCstate: adt {	crc: int;	crctab: array of int;	reg: int;}; init: fn(poly: int, reg: int): ref CRCstate;crc: fn(state: ref CRCstate, buf: array of byte, nb: int): int;reset: fn(state: ref CRCstate);.EE.SH DESCRIPTION.B Crcprovides the routines to calculate the CRC (cyclic redundancycheck) over blocks of data..PP.B Initinitializes the module and must be called first. The parameter.I polyis the polynomial to use when calculating the CRC value. If a value of0 is given, the default polynomial 16redb88320 (8r035556101440) is used. The polynomialhas its implicit top bit set. The second parameter.I regis the number with which to initialize the CRC register. This is commonly 0 but, for example, is16rffffffff in the CRC32 algorithm. The final CRC value is also XORed with this number.The functionreturns a pointer to an adt that holds the current CRC value,the auxiliary table the algorithm uses and the initial register value. These fields should not be accesseddirectly - they are only for internal use..PP.B Crccalculates the CRC value of the first.I nbbytes of the array.I bufgiven the CRC state.I stateas returned by the .I init function. It returns the current CRC value. It may be called repeatedlyto calculate the CRC of a series of arrays of bytes, for example, whencalculating the CRC value for the bytes in a file..PP.B Resetsets the CRC state to its initial value in readiness for a new CRCcalculation. It avoids the need to call.I initagain..SH SOURCE.B /appl/lib/crc.b.SH SEE ALSO.IR sum (1)