summaryrefslogtreecommitdiffstats
path: root/lzip.h
diff options
context:
space:
mode:
Diffstat (limited to 'lzip.h')
-rw-r--r--lzip.h27
1 files changed, 14 insertions, 13 deletions
diff --git a/lzip.h b/lzip.h
index ea02a5f..dec0aae 100644
--- a/lzip.h
+++ b/lzip.h
@@ -1,4 +1,4 @@
-/* Lziprecover - Data recovery tool for lzipped files
+/* Lziprecover - Data recovery tool for lzip files
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
@@ -30,10 +30,11 @@ public:
static const int next[states] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
st = next[st];
}
-
- void set_match() { st = ( ( st < 7 ) ? 7 : 10 ); }
- void set_rep() { st = ( ( st < 7 ) ? 8 : 11 ); }
- void set_short_rep() { st = ( ( st < 7 ) ? 9 : 11 ); }
+ void set_char1() { st -= ( st < 4 ) ? st : 3; } // for st < 7
+ void set_char2() { st -= ( st < 10 ) ? 3 : 6; } // for st >= 7
+ void set_match() { st = ( st < 7 ) ? 7 : 10; }
+ void set_rep() { st = ( st < 7 ) ? 8 : 11; }
+ void set_short_rep() { st = ( st < 7 ) ? 9 : 11; }
};
@@ -160,10 +161,11 @@ public:
uint32_t operator[]( const uint8_t byte ) const { return data[byte]; }
- void update( uint32_t & crc, const uint8_t byte ) const
+ void update_byte( uint32_t & crc, const uint8_t byte ) const
{ crc = data[(crc^byte)&0xFF] ^ ( crc >> 8 ); }
- void update( uint32_t & crc, const uint8_t * const buffer, const int size ) const
+ void update_buf( uint32_t & crc, const uint8_t * const buffer,
+ const int size ) const
{
for( int i = 0; i < size; ++i )
crc = data[(crc^buffer[i])&0xFF] ^ ( crc >> 8 );
@@ -205,15 +207,15 @@ struct File_header
return sz;
}
- bool dictionary_size( const int sz )
+ bool dictionary_size( const unsigned sz )
{
if( sz >= min_dictionary_size && sz <= max_dictionary_size )
{
data[5] = real_bits( sz - 1 );
if( sz > min_dictionary_size )
{
- const int base_size = 1 << data[5];
- const int wedge = base_size / 16;
+ const unsigned base_size = 1 << data[5];
+ const unsigned wedge = base_size / 16;
for( int i = 7; i >= 1; --i )
if( base_size - ( i * wedge ) >= sz )
{ data[5] |= ( i << 5 ); break; }
@@ -287,9 +289,8 @@ int writeblock( const int fd, const uint8_t * const buf, const int size );
// defined in main.cc
int open_instream( const std::string & name, struct stat * const in_statsp,
- const bool to_stdout, const bool reg_only = false );
-int open_outstream_rw( const std::string & output_filename,
- const bool force );
+ const bool no_ofile, const bool reg_only = false );
+int open_outstream_rw( const std::string & output_filename, const bool force );
void show_header( const File_header & header );
void show_error( const char * const msg, const int errcode = 0,
const bool help = false );