summaryrefslogtreecommitdiffstats
path: root/decoder.h
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:16:35 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:16:35 +0000
commit9c4f65be76622adb3e5429760e1828c36343c15e (patch)
treeafc77153dd2432a0c71fe3589f0a431920b1ed33 /decoder.h
parentAdding upstream version 1.13~rc2. (diff)
downloadlziprecover-9c4f65be76622adb3e5429760e1828c36343c15e.tar.xz
lziprecover-9c4f65be76622adb3e5429760e1828c36343c15e.zip
Adding upstream version 1.13.upstream/1.13
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decoder.h')
-rw-r--r--decoder.h45
1 files changed, 30 insertions, 15 deletions
diff --git a/decoder.h b/decoder.h
index f1a48cb..92da2b3 100644
--- a/decoder.h
+++ b/decoder.h
@@ -1,5 +1,5 @@
/* Lziprecover - Data recovery tool for lzipped files
- Copyright (C) 2009, 2010, 2011 Antonio Diaz Diaz.
+ Copyright (C) 2009, 2010, 2011, 2012 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
@@ -29,8 +29,11 @@ class Range_decoder
bool read_block();
+ Range_decoder( const Range_decoder & ); // declared as private
+ void operator=( const Range_decoder & ); // declared as private
+
public:
- Range_decoder( const int ifd )
+ explicit Range_decoder( const int ifd )
:
partial_member_pos( 0 ),
buffer( new uint8_t[buffer_size] ),
@@ -43,12 +46,10 @@ public:
~Range_decoder() { delete[] buffer; }
- bool code_is_zero() const throw() { return ( code == 0 ); }
+ bool code_is_zero() const { return ( code == 0 ); }
bool finished() { return pos >= stream_pos && !read_block(); }
- long long member_position() const throw()
- { return partial_member_pos + pos; }
- void reset_member_position() throw()
- { partial_member_pos = -pos; }
+ long long member_position() const { return partial_member_pos + pos; }
+ void reset_member_position() { partial_member_pos = -pos; }
uint8_t get_byte()
{
@@ -56,6 +57,19 @@ public:
return buffer[pos++];
}
+ int read( uint8_t * const outbuf, const int size )
+ {
+ int rest = size;
+ while( rest > 0 && !finished() )
+ {
+ const int rd = std::min( rest, stream_pos - pos );
+ std::memcpy( outbuf + size - rest, buffer + pos, rd );
+ pos += rd;
+ rest -= rd;
+ }
+ return ( rest > 0 ) ? size - rest : size;
+ }
+
void load()
{
code = 0;
@@ -176,7 +190,7 @@ class Literal_decoder
{
Bit_model bm_literal[1<<literal_context_bits][0x300];
- int lstate( const int prev_byte ) const throw()
+ int lstate( const uint8_t prev_byte ) const
{ return ( prev_byte >> ( 8 - literal_context_bits ) ); }
public:
@@ -205,18 +219,17 @@ class LZ_decoder
const int member_version;
Range_decoder & range_decoder;
- long long stream_position() const throw()
- { return partial_data_pos + stream_pos; }
+ long long stream_position() const { return partial_data_pos + stream_pos; }
void flush_data();
bool verify_trailer( const Pretty_print & pp ) const;
- uint8_t get_prev_byte() const throw()
+ uint8_t get_prev_byte() const
{
const int i = ( ( pos > 0 ) ? pos : buffer_size ) - 1;
return buffer[i];
}
- uint8_t get_byte( const int distance ) const throw()
+ uint8_t get_byte( const int distance ) const
{
int i = pos - distance - 1;
if( i < 0 ) i += buffer_size;
@@ -246,6 +259,9 @@ class LZ_decoder
}
}
+ LZ_decoder( const LZ_decoder & ); // declared as private
+ void operator=( const LZ_decoder & ); // declared as private
+
public:
LZ_decoder( const File_header & header, Range_decoder & rdec, const int ofd,
const long long oskip = 0, const long long oend = LLONG_MAX )
@@ -266,10 +282,9 @@ public:
~LZ_decoder() { delete[] buffer; }
- uint32_t crc() const throw() { return crc_ ^ 0xFFFFFFFFU; }
+ uint32_t crc() const { return crc_ ^ 0xFFFFFFFFU; }
- long long data_position() const throw()
- { return partial_data_pos + pos; }
+ long long data_position() const { return partial_data_pos + pos; }
int decode_member( const Pretty_print & pp );
};