From e6759ba4e68c66f0927bb89bfb87215eb29016ae Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 20 May 2016 08:54:36 +0200 Subject: Adding upstream version 1.18. Signed-off-by: Daniel Baumann --- mtester.h | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'mtester.h') diff --git a/mtester.h b/mtester.h index 71df64d..53f0abe 100644 --- a/mtester.h +++ b/mtester.h @@ -1,5 +1,5 @@ /* Lziprecover - Data recovery tool for the lzip format - Copyright (C) 2009-2015 Antonio Diaz Diaz. + Copyright (C) 2009-2016 Antonio Diaz Diaz. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,27 +37,29 @@ public: at_stream_end( false ) {} - bool code_is_zero() const { return ( code == 0 ); } bool finished() { return pos >= buffer_size; } - long member_position() const { return pos; } + unsigned long member_position() const { return pos; } uint8_t get_byte() { - if( finished() ) return 0xAA; // make code != 0 + // 0xFF avoids decoder error if member is truncated at EOS marker + if( finished() ) return 0xFF; return buffer[pos++]; } const File_trailer * get_trailer() { if( buffer_size - pos < File_trailer::size ) return 0; - const File_trailer * const p = (File_trailer *)(buffer + pos); + const File_trailer * const p = (File_trailer *)( buffer + pos ); pos += File_trailer::size; return p; } void load() { + code = 0; for( int i = 0; i < 5; ++i ) code = (code << 8) | get_byte(); + range = 0xFFFFFFFFU; code &= range; // make sure that first byte is discarded } @@ -198,11 +200,14 @@ class LZ_mtester unsigned pos; // current pos in buffer unsigned stream_pos; // first byte not yet written to file uint32_t crc_; + const int outfd; // output file descriptor unsigned rep0; // rep[0-3] latest four distances unsigned rep1; // used for efficient coding of unsigned rep2; // repeated distances unsigned rep3; State state; + unsigned max_rep0; // maximum distance found + bool pos_wrapped; Bit_model bm_literal[1<