debian/copyright: sync with experimental
[xz/debian.git] / debug / crc32.c
blobe545a3cc1ebe12655b7a1dc1a13ff7cd52bfa476
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.
11 ///////////////////////////////////////////////////////////////////////////////
13 #include "sysdefs.h"
14 #include "lzma.h"
15 #include <stdio.h>
18 int
19 main(void)
21 uint32_t crc = 0;
23 do {
24 uint8_t buf[BUFSIZ];
25 const size_t size = fread(buf, 1, sizeof(buf), stdin);
26 crc = lzma_crc32(buf, size, crc);
27 } while (!ferror(stdin) && !feof(stdin));
29 //printf("%08" PRIX32 "\n", crc);
31 // I want it little endian so it's easy to work with hex editor.
32 printf("%02" PRIX32 " ", crc & 0xFF);
33 printf("%02" PRIX32 " ", (crc >> 8) & 0xFF);
34 printf("%02" PRIX32 " ", (crc >> 16) & 0xFF);
35 printf("%02" PRIX32 " ", crc >> 24);
36 printf("\n");
38 return 0;