]> icculus.org git repositories - icculus/xz.git/blob - src/liblzma/check/crc64_tablegen.c
Update the code to mostly match the new simpler file format
[icculus/xz.git] / src / liblzma / check / crc64_tablegen.c
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       crc64_tablegen.c
4 /// \brief      Generates CRC64 crc64_table.c
5 ///
6 /// Compiling: gcc -std=c99 -o crc64_tablegen crc64_tablegen.c
7 /// Add -DWORDS_BIGENDIAN to generate big endian table.
8 //
9 //  This code has been put into the public domain.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 //
15 ///////////////////////////////////////////////////////////////////////////////
16
17 #include <sys/types.h>
18 #include <inttypes.h>
19 #include <stdio.h>
20
21 #include "crc64_init.c"
22
23
24 int
25 main()
26 {
27         lzma_crc64_init();
28
29         printf("/* This file has been automatically generated by "
30                         "crc64_tablegen.c. */\n\n"
31                         "const uint64_t lzma_crc64_table[4][256] = {\n\t{");
32
33         for (size_t s = 0; s < 4; ++s) {
34                 for (size_t b = 0; b < 256; ++b) {
35                         if ((b % 2) == 0)
36                                 printf("\n\t\t");
37
38                         printf("UINT64_C(0x%016" PRIX64 ")",
39                                         lzma_crc64_table[s][b]);
40
41                         if (b != 255)
42                                 printf(", ");
43                 }
44
45                 if (s == 3)
46                         printf("\n\t}\n};\n");
47                 else
48                         printf("\n\t}, {");
49         }
50
51         return 0;
52 }