2008-01-22 20:49:24 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2008-08-28 19:53:15 +00:00
|
|
|
/// \file crc32.c
|
|
|
|
/// \brief Primitive CRC32 calculation tool
|
2008-01-22 20:49:24 +00:00
|
|
|
//
|
2009-04-13 08:27:40 +00:00
|
|
|
// Author: Lasse Collin
|
2008-01-22 20:49:24 +00:00
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-08-28 19:53:15 +00:00
|
|
|
#include "sysdefs.h"
|
2009-11-14 17:45:39 +00:00
|
|
|
#include "lzma.h"
|
2008-08-28 19:53:15 +00:00
|
|
|
#include <stdio.h>
|
2008-01-22 20:49:24 +00:00
|
|
|
|
|
|
|
|
2008-08-28 19:53:15 +00:00
|
|
|
int
|
|
|
|
main(void)
|
2008-06-18 15:02:10 +00:00
|
|
|
{
|
2008-08-28 19:53:15 +00:00
|
|
|
uint32_t crc = 0;
|
2008-01-22 20:49:24 +00:00
|
|
|
|
2008-08-28 19:53:15 +00:00
|
|
|
do {
|
|
|
|
uint8_t buf[BUFSIZ];
|
|
|
|
const size_t size = fread(buf, 1, sizeof(buf), stdin);
|
|
|
|
crc = lzma_crc32(buf, size, crc);
|
|
|
|
} while (!ferror(stdin) && !feof(stdin));
|
2008-06-18 15:02:10 +00:00
|
|
|
|
2008-08-28 19:53:15 +00:00
|
|
|
//printf("%08" PRIX32 "\n", crc);
|
|
|
|
|
|
|
|
// I want it little endian so it's easy to work with hex editor.
|
|
|
|
printf("%02" PRIX32 " ", crc & 0xFF);
|
|
|
|
printf("%02" PRIX32 " ", (crc >> 8) & 0xFF);
|
|
|
|
printf("%02" PRIX32 " ", (crc >> 16) & 0xFF);
|
|
|
|
printf("%02" PRIX32 " ", crc >> 24);
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
return 0;
|
2008-06-18 15:02:10 +00:00
|
|
|
}
|