]> icculus.org git repositories - icculus/xz.git/blob - debug/crc32.c
Put the interesting parts of XZ Utils into the public domain.
[icculus/xz.git] / debug / crc32.c
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       crc32.c
4 /// \brief      Primitive CRC32 calculation tool
5 //
6 //  Author:     Lasse Collin
7 //
8 //  This file has been put into the public domain.
9 //  You can do whatever you want with this file.
10 //
11 ///////////////////////////////////////////////////////////////////////////////
12
13 #include "sysdefs.h"
14 #include <stdio.h>
15
16
17 int
18 main(void)
19 {
20         uint32_t crc = 0;
21
22         do {
23                 uint8_t buf[BUFSIZ];
24                 const size_t size = fread(buf, 1, sizeof(buf), stdin);
25                 crc = lzma_crc32(buf, size, crc);
26         } while (!ferror(stdin) && !feof(stdin));
27
28         //printf("%08" PRIX32 "\n", crc);
29
30         // I want it little endian so it's easy to work with hex editor.
31         printf("%02" PRIX32 " ", crc & 0xFF);
32         printf("%02" PRIX32 " ", (crc >> 8) & 0xFF);
33         printf("%02" PRIX32 " ", (crc >> 16) & 0xFF);
34         printf("%02" PRIX32 " ", crc >> 24);
35         printf("\n");
36
37         return 0;
38 }