summaryrefslogtreecommitdiff
path: root/man/2/crc
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 20:52:35 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 20:52:35 +0000
commit46439007cf417cbd9ac8049bb4122c890097a0fa (patch)
tree6fdb25e5f3a2b6d5657eb23b35774b631d4d97e4 /man/2/crc
parent37da2899f40661e3e9631e497da8dc59b971cbd0 (diff)
20060303-partial
Diffstat (limited to 'man/2/crc')
-rw-r--r--man/2/crc62
1 files changed, 62 insertions, 0 deletions
diff --git a/man/2/crc b/man/2/crc
new file mode 100644
index 00000000..f3bc96c4
--- /dev/null
+++ b/man/2/crc
@@ -0,0 +1,62 @@
+.TH CRC 2
+.SH NAME
+crc \- Crc module
+.SH SYNOPSIS
+.EX
+include "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 Crc
+provides the routines to calculate the CRC (cyclic redundancy
+check) over blocks of data.
+.PP
+.B Init
+initializes the module and must be called first. The parameter
+.I poly
+is the polynomial to use when calculating the CRC value. If a value of
+0 is given, the default polynomial 16redb88320 (8r035556101440) is used. The polynomial
+has its implicit top bit set. The second parameter
+.I reg
+is the number with which to initialize the CRC register. This is commonly 0 but, for example, is
+16rffffffff in the CRC32 algorithm. The final CRC value is also XORed with this number.
+The function
+returns 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 accessed
+directly - they are only for internal use.
+.PP
+.B Crc
+calculates the CRC value of the first
+.I nb
+bytes of the array
+.I buf
+given the CRC state
+.I state
+as returned by the
+.I init
+function. It returns the current CRC value. It may be called repeatedly
+to calculate the CRC of a series of arrays of bytes, for example, when
+calculating the CRC value for the bytes in a file.
+.PP
+.B Reset
+sets the CRC state to its initial value in readiness for a new CRC
+calculation. It avoids the need to call
+.I init
+again.
+.SH SOURCE
+.B /appl/lib/crc.b
+.SH SEE ALSO
+.IR sum (1)
+
+
+