hash/unihash.c: Replace a dynamic assertion with a static one.
[mLib] / hash / crc-mktab.1
CommitLineData
7c14e955 1.\" nroff
2.ie t \{\
3. ds ss \s8\u
4. ds se \d\s0
5.\}
6.el \{\
7. ds ss ^
8. ds se
9.\}
10.TH crc-mktab 1 "9 November 2003" "Straylight/Edgeware" "mLib utilities library"
11.SH NAME
12crc-mktab \- construct CRC tables for efficient computation
13.SH SYNOPSIS
14.B crc-mktab
3e7267bf 15.RB [ \-Ccr ]
7c14e955 16.RB [ \-s
17.IR symbol ]
18.RB [ \-t
19.IR type ]
20.RB [ \-i
21.IR header ]
22.br
23 \c
24.RB [ \-g
25.IR macro ]
26.RB [ \-b
27.IR bits ]
28.RB [ \-B
29.IR chunk ]
30.RB [ \-p
31.IR poly ]
32.br
33 \c
34.RB [ \-o
35.IR filename ]
36.SH DESCRIPTION
37The
38.B crc-mktab
39program constructs tables for efficient computation of CRC (cyclic
40redundancy check) values. It will produce the table as either an array
41defined in a C source file or as an initializer macro defined in a C
42header file.
43.SS "Options"
44The program accepts no non-option arguments. At least one of
45.B \-b
46or
47.B \-p
48must be given. The options are as follows.
49.TP
50.B "\-h, \-\-help"
51Print a help message to standard output and exit successfully.
52.TP
53.B "\-v, \-\-version"
54Print the program's version number to standard output and exit
55successfully.
56.TP
57.B "\-u, \-\-usage"
58Print a one-line usage summary to standard output and exit successfully.
59.TP
3e7267bf
MW
60.B "\-C, \-\-const"
61When producing C source (the
62.B \-c
63option), rather than a header, define the table to be
64.BR const .
7c14e955 65.B "\-c, \-\-c-source"
66Produce a C source file which exports a symbol naming the array, instead
67of a C header file.
68.TP
6f444bda 69.BI "\-s, \-\-symbol=" symbol
7c14e955 70Name the table
71.IR symbol .
72This is the name of the macro defined by a header file, or the array
73exported by a C source. The default macro name is
74.BR CRC_TAB ;
75the default array name is
76.BR crctab .
77.TP
78.BI "\-t, \-\-type=" type
79Specify the element type of the array defined by a C source output. The
d4efbcd9 80default is
7c14e955 81.B "unsigned short"
82if the polynomial has degree 16 or less, or
83.B "unsigned long"
84otherwise. This option does nothing without the
85.B \-c
86option.
87.TP
88.BI "\-i, \-\-include=" header
d4efbcd9 89Request that generated C source include the named
7c14e955 90.I header
91file. Inserts a
92line of the form
93.PP
94.nf
95.BI " #include """ header """"
96.fi
97.IP
98at the top of the generated C source. The default is not to include a
99header file. This option does nothing without the
100.B \-c
101option.
102.TP
103.BI "\-g, \-\-guard=" macro
104Use the named
105.I macro
106as a guard against multiple inclusion of the generated header file.
107Inserts a pair of lines of the form
108.PP
109.nf
110.BI " #ifndef " macro
111.BI " #define " macro
112.fi
113.IP
114at the top of the generated header, and a line
115.PP
116.nf
117.BI " #endif"
118.fi
119.IP
120at the end. The default guard macro name is built from the output file
121name specified with
122.B \-o
123by uppercasing all alphabetic characters in the name and replacing
d4efbcd9 124nonalphanumeric characters by underscores
7c14e955 125.RB ` _ '.
126This option does nothing with the
127.B \-c
128option.
129.TP
130.BI "\-b, \-\-bits=" bits
131Specifies the degree of the CRC polynomial or, equivalently, the length
132of the generated CRC. This must be an integer between 1 and 32
133inclusive. If it is not specified, the polynomial given by
134.B \-p
135is examined and an educated guess made. (Currently we choose the
136smallest multiple of 8 which is large enough.)
137.TP
138.BI "\-B, \-\-bit-chunk=" chunk
139Chunk size in which bits are taken from the input. The number of
140entries in the table is precisely
141.RI 2\*(ss chunk \*(se.
142The default chunk size is 8.
143.TP
144.BI "\-p, \-\-polynomial=" poly
145Specifies the CRC polynomial as an integer. The polynomial has a
146nonzero coefficient in its
147.IR x \*(ss i \*(se
148term if and only if bit
149.I i
150of
151.I poly
152is nonzero. Note that if you want to specify the polynomial in
153hexadecimal, you must prefix it with
154.BR 0x .
155Default polynomials of degree 16 and 32 are known.
156.TP
157.B "\-r, \-\-reverse"
158Construct the table to compensate for unusual bit-ordering. Without
159this option, you'd have to reverse the order of all input chunks and the
160output CRC.
161.SS "The table and how to use it"
162Describing in detail the contents of the table would take too long. For
163an example of use, see the header file
164.BR crc32.h .
165.SH "SEE ALSO"
166.BR crc32 (3).
167.PP
168.I A painless guide to CRC error detection algorithms
169by Ross N. Williams.
170.SH "AUTHOR"
9b5ac6ff 171Mark Wooding, <mdw@distorted.org.uk>
7c14e955 172