]> icculus.org git repositories - icculus/xz.git/blob - src/liblzma/check/crc32_tablegen.c
Sort of garbage collection commit. :-| Many things are still
[icculus/xz.git] / src / liblzma / check / crc32_tablegen.c
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       crc32_tablegen.c
4 /// \brief      Generates CRC32 crc32_table.c
5 ///
6 /// Compiling: gcc -std=c99 -o crc32_tablegen crc32_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 "crc32_init.c"
22
23
24 int
25 main()
26 {
27         lzma_crc32_init();
28
29         printf("/* This file has been automatically generated by "
30                         "crc32_tablegen.c. */\n\n"
31                         "const uint32_t lzma_crc32_table[8][256] = {\n\t{");
32
33         for (size_t s = 0; s < 8; ++s) {
34                 for (size_t b = 0; b < 256; ++b) {
35                         if ((b % 4) == 0)
36                                 printf("\n\t\t");
37
38                         printf("0x%08" PRIX32, lzma_crc32_table[s][b]);
39
40                         if (b != 255)
41                                 printf(", ");
42                 }
43
44                 if (s == 7)
45                         printf("\n\t}\n};\n");
46                 else
47                         printf("\n\t}, {");
48         }
49
50         return 0;
51 }