aboutsummaryrefslogtreecommitdiff
path: root/debug/crc32.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-08-28 22:53:15 +0300
committerLasse Collin <lasse.collin@tukaani.org>2008-08-28 22:53:15 +0300
commit3b34851de1eaf358cf9268922fa0eeed8278d680 (patch)
tree7bab212af647541df64227a8d350d17a2e789f6b /debug/crc32.c
parentFix test_filter_flags to match the new restriction of lc+lp. (diff)
downloadxz-3b34851de1eaf358cf9268922fa0eeed8278d680.tar.xz
Sort of garbage collection commit. :-| Many things are still
broken. API has changed a lot and it will still change a little more here and there. The command line tool doesn't have all the required changes to reflect the API changes, so it's easy to get "internal error" or trigger assertions.
Diffstat (limited to '')
-rw-r--r--debug/crc32.c (renamed from src/liblzma/lz/lz_encoder_private.h)41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/liblzma/lz/lz_encoder_private.h b/debug/crc32.c
index 638fcb2d..4052a863 100644
--- a/src/liblzma/lz/lz_encoder_private.h
+++ b/debug/crc32.c
@@ -1,10 +1,9 @@
///////////////////////////////////////////////////////////////////////////////
//
-/// \file lz_encoder_private.h
-/// \brief Private definitions for LZ encoder
+/// \file crc32.c
+/// \brief Primitive CRC32 calculation tool
//
-// Copyright (C) 1999-2006 Igor Pavlov
-// Copyright (C) 2007 Lasse Collin
+// Copyright (C) 2008 Lasse Collin
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -18,23 +17,29 @@
//
///////////////////////////////////////////////////////////////////////////////
-#ifndef LZMA_LZ_ENCODER_PRIVATE_H
-#define LZMA_LZ_ENCODER_PRIVATE_H
+#include "sysdefs.h"
+#include <stdio.h>
-#include "lz_encoder.h"
-/// Value used to indicate unused slot
-#define EMPTY_HASH_VALUE 0
+int
+main(void)
+{
+ uint32_t crc = 0;
-/// When the dictionary and hash variables need to be adjusted to prevent
-/// integer overflows. Since we use uint32_t to store the offsets, half
-/// of it is the biggest safe limit.
-#define MAX_VAL_FOR_NORMALIZE (UINT32_MAX / 2)
+ 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);
-struct lzma_coder_s {
- lzma_next_coder next;
- lzma_lz_encoder lz;
-};
+ // 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");
-#endif
+ return 0;
+}