summaryrefslogtreecommitdiffstats
path: root/extended.cc
diff options
context:
space:
mode:
Diffstat (limited to 'extended.cc')
-rw-r--r--extended.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/extended.cc b/extended.cc
index d03494f..1057142 100644
--- a/extended.cc
+++ b/extended.cc
@@ -1,5 +1,5 @@
/* Tarlz - Archiver with multimember lzip compression
- Copyright (C) 2013-2020 Antonio Diaz Diaz.
+ Copyright (C) 2013-2021 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
@@ -24,16 +24,17 @@
#include <cstring>
#include <string>
#include <vector>
-#include <pthread.h>
+#include <pthread.h> // for tarlz.h
#include <stdint.h>
#include "tarlz.h"
-namespace {
-
const CRC32 crc32c( true );
+
+namespace {
+
unsigned decimal_digits( unsigned long long value )
{
unsigned digits = 1;
@@ -132,6 +133,7 @@ bool print_record( char * const buf, const int size,
} // end namespace
+std::vector< std::string > Extended::unknown_keywords;
const std::string Extended::crc_record( "22 GNU.crc32=00000000\n" );
void Extended::calculate_sizes() const
@@ -147,6 +149,22 @@ void Extended::calculate_sizes() const
}
+// print a diagnostic for each unknown keyword once per keyword
+void Extended::unknown_keyword( const char * const buf,
+ const unsigned long long size ) const
+ {
+ unsigned long long eq_pos = 0; // position of '=' in buf
+ while( eq_pos < size && buf[eq_pos] != '=' ) ++eq_pos;
+ const std::string keyword( buf, eq_pos );
+ for( unsigned i = 0; i < unknown_keywords.size(); ++i )
+ if( keyword == unknown_keywords[i] ) return;
+ unknown_keywords.push_back( keyword );
+ std::string msg( "Ignoring unknown extended header keyword '" );
+ msg += keyword; msg += '\'';
+ show_error( msg.c_str() );
+ }
+
+
// Returns the extended block size, or -1 if error.
long long Extended::format_block( Resizable_buffer & rbuf ) const
{
@@ -239,6 +257,8 @@ bool Extended::parse( const char * const buf, const unsigned long long edsize,
return false;
}
}
+ else if( ( rest < 8 || std::memcmp( tail, "comment=", 8 ) != 0 ) &&
+ verbosity >= 1 ) unknown_keyword( tail, rest );
pos += rsize;
}
return true;