1 //----------------------------------------------------------------------
2 // This software is part of the OpenBeOS distribution and is covered
5 // Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
6 //---------------------------------------------------------------------
8 /*! \file crc_table.cpp
10 Standalone program to generate the CRC table used for calculating
11 UDF tag id CRC values.
13 This code based off of crc code in UDF-2.50 specs, as permitted.
14 See UDF-2.50 6.5 for more information.
16 Reflected version by Jéme Duval
20 #include "system_dependencies.h"
23 typedef unsigned int uint32
;
30 for (int i
= 0; i
< 32; i
++){
40 main(int argc
, char* argv
[]) {
44 fprintf(stderr
, "USAGE: crc_table <octal polynomial=3667067501 for btrfs>\n");
48 sscanf(argv
[1], "%lo", &poly
);
50 printf("//! CRC 0%o table, as generated by crc_table.cpp\n", poly
);
51 printf("static uint32 crc_table[256] = { \n");
52 for (int n
= 0; n
< 256; n
++) {
56 for (int i
= 0; i
< 8; i
++) {
58 crc
= (crc
<< 1) ^ poly
;
63 printf("0x%08x%s ", crc
, (n
!= 255 ? "," : ""));