mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Implement md5 checking on decompression.
Implement hash check flag to determine whether to show md5sum on compression/decompression or not.
This commit is contained in:
parent
c2417877bc
commit
fb2a12744a
24
runzip.c
24
runzip.c
|
|
@ -224,16 +224,38 @@ static i64 runzip_chunk(int fd_in, int fd_out, int fd_hist, i64 expected_size, i
|
|||
*/
|
||||
i64 runzip_fd(int fd_in, int fd_out, int fd_hist, i64 expected_size)
|
||||
{
|
||||
char md5_resblock[MD5_DIGEST_SIZE];
|
||||
struct timeval start,end;
|
||||
FILE *md5_stream;
|
||||
i64 total = 0;
|
||||
int j;
|
||||
|
||||
md5_init_ctx (&control.ctx);
|
||||
md5_stream = fopen(control.outfile, "r");
|
||||
if (unlikely(md5_stream == NULL))
|
||||
fatal("Failed to fdopen md5_stream in runzip_fd\n");
|
||||
|
||||
gettimeofday(&start,NULL);
|
||||
|
||||
while (total < expected_size)
|
||||
while (total < expected_size) {
|
||||
total += runzip_chunk(fd_in, fd_out, fd_hist, expected_size, total);
|
||||
if (md5_midstream(md5_stream, &control.ctx))
|
||||
fatal("Failed md5_midstream in runzip_fd\n");
|
||||
}
|
||||
|
||||
gettimeofday(&end,NULL);
|
||||
print_progress("\nAverage DeCompression Speed: %6.3fMB/s\n",
|
||||
(total / 1024 / 1024) / (double)((end.tv_sec-start.tv_sec)? : 1));
|
||||
|
||||
if (unlikely(fclose(md5_stream)))
|
||||
fatal("Failed to fclose md5_stream in runzip_fd\n");
|
||||
md5_finish_ctx (&control.ctx, md5_resblock);
|
||||
if (HASH_CHECK || VERBOSE) {
|
||||
print_output("MD5 sum: ");
|
||||
for (j = 0; j < MD5_DIGEST_SIZE; j++)
|
||||
print_output("%02x", md5_resblock[j] & 0xFF);
|
||||
print_output("\n");
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
|
|
|||
9
rzip.c
9
rzip.c
|
|
@ -929,11 +929,14 @@ retry:
|
|||
if (unlikely(munmap(buf, len)))
|
||||
fatal("Failed to munmap in last md5 calculation in rzip_fd\n");
|
||||
}
|
||||
|
||||
md5_finish_ctx (&control.ctx, md5_resblock);
|
||||
print_verbose("MD5 sum: ");
|
||||
if (HASH_CHECK || VERBOSE) {
|
||||
print_output("MD5 sum: ");
|
||||
for (j = 0; j < MD5_DIGEST_SIZE; j++)
|
||||
print_verbose("%02x", md5_resblock[j] & 0xFF);
|
||||
print_verbose("\n");
|
||||
print_output("%02x", md5_resblock[j] & 0xFF);
|
||||
print_output("\n");
|
||||
}
|
||||
|
||||
gettimeofday(¤t, NULL);
|
||||
if (STDIN)
|
||||
|
|
|
|||
36
rzip.h
36
rzip.h
|
|
@ -195,23 +195,24 @@ static inline i64 get_ram(void)
|
|||
#define mremap fake_mremap
|
||||
#endif
|
||||
|
||||
#define FLAG_SHOW_PROGRESS 2
|
||||
#define FLAG_KEEP_FILES 4
|
||||
#define FLAG_TEST_ONLY 8
|
||||
#define FLAG_FORCE_REPLACE 16
|
||||
#define FLAG_DECOMPRESS 32
|
||||
#define FLAG_NO_COMPRESS 64
|
||||
#define FLAG_LZO_COMPRESS 128
|
||||
#define FLAG_BZIP2_COMPRESS 256
|
||||
#define FLAG_ZLIB_COMPRESS 512
|
||||
#define FLAG_ZPAQ_COMPRESS 1024
|
||||
#define FLAG_VERBOSITY 2048
|
||||
#define FLAG_VERBOSITY_MAX 4096
|
||||
#define FLAG_STDIN 8192
|
||||
#define FLAG_STDOUT 16384
|
||||
#define FLAG_INFO 32768
|
||||
#define FLAG_MAXRAM 65536
|
||||
#define FLAG_UNLIMITED 131072
|
||||
#define FLAG_SHOW_PROGRESS (1 << 0)
|
||||
#define FLAG_KEEP_FILES (1 << 1)
|
||||
#define FLAG_TEST_ONLY (1 << 2)
|
||||
#define FLAG_FORCE_REPLACE (1 << 3)
|
||||
#define FLAG_DECOMPRESS (1 << 4)
|
||||
#define FLAG_NO_COMPRESS (1 << 5)
|
||||
#define FLAG_LZO_COMPRESS (1 << 6)
|
||||
#define FLAG_BZIP2_COMPRESS (1 << 7)
|
||||
#define FLAG_ZLIB_COMPRESS (1 << 8)
|
||||
#define FLAG_ZPAQ_COMPRESS (1 << 9)
|
||||
#define FLAG_VERBOSITY (1 << 10)
|
||||
#define FLAG_VERBOSITY_MAX (1 << 11)
|
||||
#define FLAG_STDIN (1 << 12)
|
||||
#define FLAG_STDOUT (1 << 13)
|
||||
#define FLAG_INFO (1 << 14)
|
||||
#define FLAG_MAXRAM (1 << 15)
|
||||
#define FLAG_UNLIMITED (1 << 16)
|
||||
#define FLAG_HASH (1 << 17)
|
||||
|
||||
#define FLAG_VERBOSE (FLAG_VERBOSITY | FLAG_VERBOSITY_MAX)
|
||||
#define FLAG_NOT_LZMA (FLAG_NO_COMPRESS | FLAG_LZO_COMPRESS | FLAG_BZIP2_COMPRESS | FLAG_ZLIB_COMPRESS | FLAG_ZPAQ_COMPRESS)
|
||||
|
|
@ -235,6 +236,7 @@ static inline i64 get_ram(void)
|
|||
#define INFO (control.flags & FLAG_INFO)
|
||||
#define MAXRAM (control.flags & FLAG_MAXRAM)
|
||||
#define UNLIMITED (control.flags & FLAG_UNLIMITED)
|
||||
#define HASH_CHECK (control.flags & FLAG_HASH)
|
||||
|
||||
#define BITS32 (sizeof(long) == 4)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue