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