summaryrefslogtreecommitdiffstats
path: root/lzip.h
diff options
context:
space:
mode:
Diffstat (limited to 'lzip.h')
-rw-r--r--lzip.h33
1 files changed, 26 insertions, 7 deletions
diff --git a/lzip.h b/lzip.h
index 34c9a81..ee09d33 100644
--- a/lzip.h
+++ b/lzip.h
@@ -1,5 +1,5 @@
/* Plzip - Parallel compressor compatible with lzip
- Copyright (C) 2009-2016 Antonio Diaz Diaz.
+ Copyright (C) 2009-2017 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
@@ -88,6 +88,12 @@ struct File_header
void set_magic() { std::memcpy( data, magic_string, 4 ); data[4] = 1; }
bool verify_magic() const
{ return ( std::memcmp( data, magic_string, 4 ) == 0 ); }
+ bool verify_prefix( const int size ) const // detect truncated header
+ {
+ for( int i = 0; i < size && i < 4; ++i )
+ if( data[i] != magic_string[i] ) return false;
+ return ( size > 0 );
+ }
uint8_t version() const { return data[4]; }
bool verify_version() const { return ( data[4] == 1 ); }
@@ -108,7 +114,7 @@ struct File_header
{
const unsigned base_size = 1 << data[5];
const unsigned fraction = base_size / 16;
- for( int i = 7; i >= 1; --i )
+ for( unsigned i = 7; i >= 1; --i )
if( base_size - ( i * fraction ) >= sz )
{ data[5] |= ( i << 5 ); break; }
}
@@ -157,6 +163,10 @@ struct File_trailer
};
+const char * const bad_magic_msg = "Bad magic number (file not in lzip format).";
+const char * const bad_dict_msg = "Invalid dictionary size in member header.";
+const char * const trailing_msg = "Trailing data not allowed.";
+
// defined in compress.cc
int readblock( const int fd, uint8_t * const buf, const int size );
int writeblock( const int fd, const uint8_t * const buf, const int size );
@@ -185,25 +195,34 @@ int dec_stdout( const int num_workers, const int infd, const int outfd,
// defined in dec_stream.cc
int dec_stream( const int num_workers, const int infd, const int outfd,
const Pretty_print & pp, const int debug_level,
- const bool ignore_garbage );
+ const bool ignore_trailing );
// defined in decompress.cc
int preadblock( const int fd, uint8_t * const buf, const int size,
const long long pos );
-int pwriteblock( const int fd, const uint8_t * const buf, const int size,
- const long long pos );
int decompress_read_error( struct LZ_Decoder * const decoder,
const Pretty_print & pp, const int worker_id );
int decompress( int num_workers, const int infd, const int outfd,
const Pretty_print & pp, const int debug_level,
- const bool ignore_garbage, const bool infd_isreg );
+ const bool ignore_trailing, const bool infd_isreg );
+
+// defined in list.cc
+int list_files( const std::vector< std::string > & filenames,
+ const bool ignore_trailing );
// defined in main.cc
extern int verbosity;
-void cleanup_and_fail( const int retval = 1 ); // terminate the program
+struct stat;
+const char * bad_version( const unsigned version );
+const char * format_ds( const unsigned dictionary_size );
void show_header( const unsigned dictionary_size );
+int open_instream( const char * const name, struct stat * const in_statsp,
+ const bool no_ofile, const bool reg_only = false );
+void cleanup_and_fail( const int retval = 1 ); // terminate the program
void show_error( const char * const msg, const int errcode = 0,
const bool help = false );
+void show_file_error( const char * const filename, const char * const msg,
+ const int errcode = 0 );
void internal_error( const char * const msg );
void show_progress( const int packet_size,
const Pretty_print * const p = 0,