From eac54b7c4aec25060d7bd856f7cdc290943d6aae Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 23:12:04 +0200 Subject: Adding upstream version 5.4.1. Signed-off-by: Daniel Baumann --- debug/crc32.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 debug/crc32.c (limited to 'debug/crc32.c') diff --git a/debug/crc32.c b/debug/crc32.c new file mode 100644 index 0000000..e545a3c --- /dev/null +++ b/debug/crc32.c @@ -0,0 +1,39 @@ +/////////////////////////////////////////////////////////////////////////////// +// +/// \file crc32.c +/// \brief Primitive CRC32 calculation tool +// +// Author: Lasse Collin +// +// This file has been put into the public domain. +// You can do whatever you want with this file. +// +/////////////////////////////////////////////////////////////////////////////// + +#include "sysdefs.h" +#include "lzma.h" +#include + + +int +main(void) +{ + uint32_t crc = 0; + + 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)); + + //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; +} -- cgit v1.2.3