1
0
Fork 0

Merging upstream version 0.26.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-17 21:27:57 +01:00
parent 7185f44b62
commit 180f99b04d
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
44 changed files with 610 additions and 505 deletions

35
tarlz.h
View file

@ -81,9 +81,9 @@ inline int decimal_digits( unsigned long long value )
inline bool dotdot_at_i( const char * const filename, const int i )
{
return ( filename[i] == '.' && filename[i+1] == '.' &&
( i == 0 || filename[i-1] == '/' ) &&
( filename[i+2] == 0 || filename[i+2] == '/' ) );
return filename[i] == '.' && filename[i+1] == '.' &&
( i == 0 || filename[i-1] == '/' ) &&
( filename[i+2] == 0 || filename[i+2] == '/' );
}
@ -244,10 +244,10 @@ class CRC32
uint32_t data[256]; // Table of CRCs of all 8-bit messages.
public:
CRC32( const bool castagnoli = false )
explicit CRC32( const bool castagnoli = false )
{
const unsigned cpol = 0x82F63B78U; // CRC32-C Castagnoli polynomial.
const unsigned ipol = 0xEDB88320U; // IEEE 802.3 Ethernet polynomial.
const unsigned cpol = 0x82F63B78U; // CRC32-C Castagnoli polynomial
const unsigned ipol = 0xEDB88320U; // IEEE 802.3 Ethernet polynomial
const unsigned poly = castagnoli ? cpol : ipol;
for( unsigned n = 0; n < 256; ++n )
@ -275,8 +275,7 @@ public:
uint32_t compute_crc( const uint8_t * const buffer, const int size ) const
{
uint32_t crc = 0xFFFFFFFFU;
for( int i = 0; i < size; ++i )
crc = data[(crc^buffer[i])&0xFF] ^ ( crc >> 8 );
update_buf( crc, buffer, size );
return crc ^ 0xFFFFFFFFU;
}
@ -322,8 +321,8 @@ enum {
inline bool isvalid_ds( const unsigned dictionary_size )
{ return ( dictionary_size >= min_dictionary_size &&
dictionary_size <= max_dictionary_size ); }
{ return dictionary_size >= min_dictionary_size &&
dictionary_size <= max_dictionary_size; }
const uint8_t lzip_magic[4] = { 0x4C, 0x5A, 0x49, 0x50 }; // "LZIP"
@ -335,14 +334,13 @@ struct Lzip_header
// 4 version
// 5 coded dictionary size
bool check_magic() const
{ return ( std::memcmp( data, lzip_magic, 4 ) == 0 ); }
bool check_magic() const { return std::memcmp( data, lzip_magic, 4 ) == 0; }
bool check_prefix( const int sz ) const // detect (truncated) header
{
for( int i = 0; i < sz && i < 4; ++i )
if( data[i] != lzip_magic[i] ) return false;
return ( sz > 0 );
return sz > 0;
}
bool check_corrupt() const // detect corrupt header
@ -350,15 +348,15 @@ struct Lzip_header
int matches = 0;
for( int i = 0; i < 4; ++i )
if( data[i] == lzip_magic[i] ) ++matches;
return ( matches > 1 && matches < 4 );
return matches > 1 && matches < 4;
}
uint8_t version() const { return data[4]; }
bool check_version() const { return ( data[4] == 1 ); }
bool check_version() const { return data[4] == 1; }
unsigned dictionary_size() const
{
unsigned sz = ( 1 << ( data[5] & 0x1F ) );
unsigned sz = 1 << ( data[5] & 0x1F );
if( sz > min_dictionary_size )
sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 7 );
return sz;
@ -488,7 +486,7 @@ const char * const eclosa_msg = "Error closing archive";
const char * const eclosf_msg = "Error closing file";
const char * const nfound_msg = "Not found in archive.";
const char * const seek_msg = "Seek error";
const char * const werr_msg = "Write error";
const char * const wr_err_msg = "Write error";
const char * const chdir_msg = "Error changing working directory";
const char * const intdir_msg = "Failed to create intermediate directory";
@ -521,7 +519,8 @@ void show_atpos_error( const char * const filename, const long long pos,
int compress( const Cl_options & cl_opts );
// defined in create.cc
bool copy_file( const int infd, const int outfd, const long long max_size = -1 );
bool copy_file( const int infd, const int outfd, const char * const filename,
const long long max_size = -1 );
bool writeblock_wrapper( const int outfd, const uint8_t * const buffer,
const int size );
bool write_eoa_records( const int outfd, const bool compressed );