From 72abeec91e77c0d5b7e89d4731b2c7dcbbbbc87a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 24 Feb 2019 21:21:09 +0100 Subject: Adding upstream version 0.12. Signed-off-by: Daniel Baumann --- main.cc | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'main.cc') diff --git a/main.cc b/main.cc index 976bbd0..fe74f7a 100644 --- a/main.cc +++ b/main.cc @@ -62,8 +62,6 @@ const char * const program_name = "tarlz"; const char * const program_year = "2019"; const char * invocation_name = 0; -enum Mode { m_none, m_append, m_concatenate, m_create, m_extract, m_list }; - void show_help( const long num_online ) { @@ -90,6 +88,8 @@ void show_help( const long num_online ) " -B, --data-size= set target size of input data blocks [2x8=16 MiB]\n" " -c, --create create a new archive\n" " -C, --directory= change to directory \n" + " -d, --diff find differences between archive and file system\n" + " --ignore-ids ignore differences in owner and group IDs\n" " -f, --file= use archive file \n" " -n, --threads= set number of (de)compression threads [%ld]\n" " -q, --quiet suppress all messages\n" @@ -98,6 +98,7 @@ void show_help( const long num_online ) " -v, --verbose verbosely list files processed\n" " -x, --extract extract files from an archive\n" " -0 .. -9 set compression level [default 6]\n" + " --uncompressed don't compress the archive created\n" " --asolid create solidly compressed appendable archive\n" " --bsolid create per block compressed archive (default)\n" " --dsolid create per directory compressed archive\n" @@ -108,8 +109,7 @@ void show_help( const long num_online ) " --group= use name/ID for files added\n" " --keep-damaged don't delete partially extracted files\n" " --missing-crc exit with error status if missing extended CRC\n" -// " --permissive allow repeated extended headers and records\n" - " --uncompressed don't compress the archive created\n", +/* " --permissive allow repeated extended headers and records\n"*/, num_online ); if( verbosity >= 1 ) { @@ -185,7 +185,7 @@ unsigned long long getnum( const char * const ptr, } -void set_mode( Mode & program_mode, const Mode new_mode ) +void set_mode( Program_mode & program_mode, const Program_mode new_mode ) { if( program_mode != m_none && program_mode != new_mode ) { @@ -245,7 +245,7 @@ int open_outstream( const std::string & name, const bool create ) // void cleanup_and_fail( const int retval ) { - // only one thread can delete and exit + // calling 'exit' more than once results in undefined behavior static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_lock( &mutex ); // ignore errors to avoid loop @@ -290,7 +290,8 @@ int main( const int argc, const char * const argv[] ) int debug_level = 0; int num_workers = -1; // start this many worker threads int level = 6; // compression level, < 0 means uncompressed - Mode program_mode = m_none; + Program_mode program_mode = m_none; + bool ignore_ids = false; bool keep_damaged = false; bool missing_crc = false; bool permissive = false; @@ -301,7 +302,7 @@ int main( const int argc, const char * const argv[] ) return 1; } enum { opt_ano = 256, opt_aso, opt_bso, opt_crc, opt_dbg, opt_dso, opt_grp, - opt_kd, opt_nso, opt_own, opt_per, opt_sol, opt_un }; + opt_id, opt_kd, opt_nso, opt_own, opt_per, opt_sol, opt_un }; const Arg_parser::Option options[] = { { '0', 0, Arg_parser::no }, @@ -318,6 +319,7 @@ int main( const int argc, const char * const argv[] ) { 'B', "data-size", Arg_parser::yes }, { 'c', "create", Arg_parser::no }, { 'C', "directory", Arg_parser::yes }, + { 'd', "diff", Arg_parser::no }, { 'f', "file", Arg_parser::yes }, { 'h', "help", Arg_parser::no }, { 'H', "format", Arg_parser::yes }, @@ -334,6 +336,7 @@ int main( const int argc, const char * const argv[] ) { opt_dbg, "debug", Arg_parser::yes }, { opt_dso, "dsolid", Arg_parser::no }, { opt_grp, "group", Arg_parser::yes }, + { opt_id, "ignore-ids", Arg_parser::no }, { opt_kd, "keep-damaged", Arg_parser::no }, { opt_crc, "missing-crc", Arg_parser::no }, { opt_nso, "no-solid", Arg_parser::no }, @@ -370,6 +373,7 @@ int main( const int argc, const char * const argv[] ) break; case 'c': set_mode( program_mode, m_create ); break; case 'C': break; // skip chdir + case 'd': set_mode( program_mode, m_diff ); break; case 'f': if( sarg != "-" ) archive_name = sarg; break; case 'h': show_help( num_online ); return 0; case 'H': break; // ignore format @@ -387,6 +391,7 @@ int main( const int argc, const char * const argv[] ) case opt_dbg: debug_level = getnum( arg, 0, 3 ); break; case opt_dso: solidity = dsolid; break; case opt_grp: set_group( arg ); break; + case opt_id: ignore_ids = true; break; case opt_kd: keep_damaged = true; break; case opt_nso: solidity = no_solid; break; case opt_own: set_owner( arg ); break; @@ -411,9 +416,10 @@ int main( const int argc, const char * const argv[] ) case m_create: return encode( archive_name, parser, filenames, level, num_workers, debug_level, program_mode == m_append ); case m_concatenate: return concatenate( archive_name, parser, filenames ); + case m_diff: case m_extract: - case m_list: return decode( archive_name, parser, filenames, num_workers, - debug_level, keep_damaged, program_mode == m_list, - missing_crc, permissive ); + case m_list: return decode( archive_name, parser, filenames, + num_workers, debug_level, program_mode, + ignore_ids, keep_damaged, missing_crc, permissive ); } } -- cgit v1.2.3