.\" nroff .\" .\" Manual for CRC table generator .\" .\" (c) 2003, 2005, 2007, 2009, 2019, 2024 Straylight/Edgeware .\" . .\"----- Licensing notice --------------------------------------------------- .\" .\" This file is part of the mLib utilities library. .\" .\" mLib is free software: you can redistribute it and/or modify it under .\" the terms of the GNU Library General Public License as published by .\" the Free Software Foundation; either version 2 of the License, or (at .\" your option) any later version. .\" .\" mLib is distributed in the hope that it will be useful, but WITHOUT .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public .\" License for more details. .\" .\" You should have received a copy of the GNU Library General Public .\" License along with mLib. If not, write to the Free Software .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, .\" USA. . .\"-------------------------------------------------------------------------- .so ../defs.man \" @@@PRE@@@ . .\"-------------------------------------------------------------------------- .TH crc-mktab 1 "9 November 2003" "Straylight/Edgeware" "mLib utilities library" . .\"-------------------------------------------------------------------------- .SH NAME crc-mktab \- construct CRC tables for efficient computation . .\"-------------------------------------------------------------------------- .SH SYNOPSIS . .B crc-mktab .RB [ \-Ccr ] .RB [ \-s .IR symbol ] .RB [ \-t .IR type ] .RB [ \-i .IR header ] .br \c .RB [ \-g .IR macro ] .RB [ \-b .IR bits ] .RB [ \-B .IR chunk ] .RB [ \-p .IR poly ] .br \c .RB [ \-o .IR filename ] . .\"-------------------------------------------------------------------------- .SH DESCRIPTION . The .B crc-mktab program constructs tables for efficient computation of CRC (cyclic redundancy check) values. It will produce the table as either an array defined in a C source file or as an initializer macro defined in a C header file. .SS "Options" The program accepts no non-option arguments. At least one of .B \-b or .B \-p must be given. The options are as follows. .TP .B "\-h, \-\-help" Print a help message to standard output and exit successfully. .TP .B "\-v, \-\-version" Print the program's version number to standard output and exit successfully. .TP .B "\-u, \-\-usage" Print a one-line usage summary to standard output and exit successfully. .TP .B "\-C, \-\-const" When producing C source (the .B \-c option), rather than a header, define the table to be .BR const . .B "\-c, \-\-c-source" Produce a C source file which exports a symbol naming the array, instead of a C header file. .TP .BI "\-s, \-\-symbol=" symbol Name the table .IR symbol . This is the name of the macro defined by a header file, or the array exported by a C source. The default macro name is .BR CRC_TAB ; the default array name is .BR crctab . .TP .BI "\-t, \-\-type=" type Specify the element type of the array defined by a C source output. The default is .B "unsigned short" if the polynomial has degree 16 or less, or .B "unsigned long" otherwise. This option does nothing without the .B \-c option. .TP .BI "\-i, \-\-include=" header .RS Request that generated C source include the named .I header file. Inserts a line of the form .IP .BI "#include """ header """" .PP at the top of the generated C source. The default is not to include a header file. This option does nothing without the .B \-c option. .RE .TP .BI "\-g, \-\-guard=" macro .RS Use the named .I macro as a guard against multiple inclusion of the generated header file. Inserts a pair of lines of the form .IP .nf .BI "#ifndef " macro .BI "#define " macro .fi .PP at the top of the generated header, and a line .IP .BI "#endif" .PP at the end. The default guard macro name is built from the output file name specified with .B \-o by uppercasing all alphabetic characters in the name and replacing nonalphanumeric characters by underscores .RB ` _ '. This option does nothing with the .B \-c option. .RE .TP .BI "\-b, \-\-bits=" bits Specifies the degree of the CRC polynomial or, equivalently, the length of the generated CRC. This must be an integer between 1 and 32 inclusive. If it is not specified, the polynomial given by .B \-p is examined and an educated guess made. (Currently we choose the smallest multiple of 8 which is large enough.) .TP .BI "\-B, \-\-bit-chunk=" chunk Chunk size in which bits are taken from the input. The number of entries in the table is precisely .RI 2\*(ss chunk \*(se. The default chunk size is 8. .TP .BI "\-p, \-\-polynomial=" poly Specifies the CRC polynomial as an integer. The polynomial has a nonzero coefficient in its .IR x \*(ss i \*(se term if and only if bit .I i of .I poly is nonzero. Note that if you want to specify the polynomial in hexadecimal, you must prefix it with .BR 0x . Default polynomials of degree 16 and 32 are known. .TP .B "\-r, \-\-reverse" Construct the table to compensate for unusual bit-ordering. Without this option, you'd have to reverse the order of all input chunks and the output CRC. .SS "The table and how to use it" Describing in detail the contents of the table would take too long. For an example of use, see the header file .BR crc32.h . . .\"-------------------------------------------------------------------------- .SH "SEE ALSO" . .BR crc32 (3). .PP .I A painless guide to CRC error detection algorithms by Ross N. Williams. . .\"-------------------------------------------------------------------------- .SH "AUTHOR" . Mark Wooding, . .\"----- That's all, folks --------------------------------------------------