Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-12-17 02:41:17

0001 #ifndef FWCore_Utilities_calculateCRC32_h
0002 #define FWCore_Utilities_calculateCRC32_h
0003 
0004 /*
0005 Code to calculate a CRC32 checksum on a string.  This code is based
0006 on code copied from the web in the public domain.  The code was modified
0007 quite a bit to provide the interface we need, remove extraneous code
0008 related to NAACR records, convert from C to C++, and use a
0009 boost type for the 32 unsigned integers, but the essential features
0010 of the CRC calculation are the same.  The array values, constants,
0011 and algorithmic steps are identical.  The comments in the header
0012 from the original code follow below to attribute the source.
0013 */
0014 
0015 /* crc32.c
0016 
0017    C implementation of CRC-32 checksums for NAACCR records.  Code is based
0018    upon and utilizes algorithm published by Ross Williams.
0019 
0020    This file contains:
0021       CRC lookup table
0022       function CalcCRC32 for calculating CRC-32 checksum
0023       function AssignCRC32 for assigning CRC-32 in NAACCR record
0024       function CheckCRC32 for checking CRC-32 in NAACCR record
0025 
0026    Provided by:
0027       Eric Durbin
0028       Kentucky Cancer Registry
0029       University of Kentucky
0030       October 14, 1998
0031 
0032    Status:
0033       Public Domain
0034 */
0035 
0036 /*****************************************************************/
0037 /*                                                               */
0038 /* CRC LOOKUP TABLE                                              */
0039 /* ================                                              */
0040 /* The following CRC lookup table was generated automagically    */
0041 /* by the Rocksoft^tm Model CRC Algorithm Table Generation       */
0042 /* Program V1.0 using the following model parameters:            */
0043 /*                                                               */
0044 /*    Width   : 4 bytes.                                         */
0045 /*    Poly    : 0x04C11DB7L                                      */
0046 /*    Reverse : TRUE.                                            */
0047 /*                                                               */
0048 /* For more information on the Rocksoft^tm Model CRC Algorithm,  */
0049 /* see the document titled "A Painless Guide to CRC Error        */
0050 /* Detection Algorithms" by Ross Williams                        */
0051 /* (ross@guest.adelaide.edu.au.). This document is likely to be  */
0052 /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft".        */
0053 /*                                                               */
0054 /*****************************************************************/
0055 
0056 #include <cstdint>
0057 
0058 #include <string_view>
0059 
0060 namespace cms {
0061 
0062   std::uint32_t calculateCRC32(std::string_view message);
0063 }  // namespace cms
0064 #endif