summaryrefslogtreecommitdiffstats
path: root/tarlz.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-01-23 17:42:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-01-23 17:42:07 +0000
commit2f15376ba464cf08e710c3353bdacc4f503e11b4 (patch)
tree646663261d4ebf123dd0bb167d626b6c448dc3b8 /tarlz.h
parentReleasing debian version 0.8-2. (diff)
downloadtarlz-2f15376ba464cf08e710c3353bdacc4f503e11b4.tar.xz
tarlz-2f15376ba464cf08e710c3353bdacc4f503e11b4.zip
Merging upstream version 0.9.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tarlz.h')
-rw-r--r--tarlz.h68
1 files changed, 55 insertions, 13 deletions
diff --git a/tarlz.h b/tarlz.h
index bc84c53..09baaf2 100644
--- a/tarlz.h
+++ b/tarlz.h
@@ -1,5 +1,5 @@
/* Tarlz - Archiver with multimember lzip compression
- Copyright (C) 2013-2018 Antonio Diaz Diaz.
+ Copyright (C) 2013-2019 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
@@ -16,7 +16,7 @@
*/
enum { header_size = 512 };
-typedef char Tar_header[header_size];
+typedef uint8_t Tar_header[header_size];
enum Offsets {
name_o = 0, mode_o = 100, uid_o = 108, gid_o = 116, size_o = 124,
@@ -33,13 +33,13 @@ enum Lengths {
enum Typeflag {
tf_regular = '0', tf_link = '1', tf_symlink = '2', tf_chardev = '3',
tf_blockdev = '4', tf_directory = '5', tf_fifo = '6', tf_hiperf = '7',
- tf_extended = 'x' };
+ tf_global = 'g', tf_extended = 'x' };
const uint8_t ustar_magic[magic_l] =
{ 0x75, 0x73, 0x74, 0x61, 0x72, 0 }; // "ustar\0"
-inline bool verify_ustar_magic( const uint8_t * const buf )
- { return std::memcmp( buf + magic_o, ustar_magic, magic_l ) == 0; }
+inline bool verify_ustar_magic( const uint8_t * const header )
+ { return std::memcmp( header + magic_o, ustar_magic, magic_l ) == 0; }
class CRC32C // Uses CRC32-C (Castagnoli) polynomial.
@@ -101,15 +101,44 @@ struct Extended // stores metadata from/for extended records
void reset()
{ linkpath.clear(); path.clear(); size = 0; crc_present = false; }
bool empty() { return linkpath.empty() && path.empty() && size == 0; }
- bool parse( const int infd, const Tar_header header, const bool permissive );
+ bool parse( const char * const buf, const unsigned long long edsize,
+ const bool permissive );
+ };
+
+
+enum { initial_line_length = 1000 }; // must be >= 77
+
+class Resizable_buffer
+ {
+ char * p;
+ unsigned size_;
+
+public:
+ explicit Resizable_buffer( const unsigned initial_size )
+ : p( (char *)std::malloc( initial_size ) ), size_( p ? initial_size : 0 ) {}
+ ~Resizable_buffer() { if( p ) std::free( p ); p = 0; size_ = 0; }
+
+ bool resize( const unsigned new_size )
+ {
+ if( size_ < new_size )
+ {
+ char * const tmp = (char *)std::realloc( p, new_size );
+ if( !tmp ) return false;
+ p = tmp; size_ = new_size;
+ }
+ return true;
+ }
+ char * operator()() const { return p; }
+ unsigned size() const { return size_; }
};
// defined in create.cc
+enum Solidity { no_solid, dsolid, asolid, solid };
extern int cl_owner;
extern int cl_group;
-extern int cl_solid;
-unsigned ustar_chksum( const uint8_t * const buf );
-bool verify_ustar_chksum( const uint8_t * const buf );
+extern Solidity solidity;
+unsigned ustar_chksum( const uint8_t * const header );
+bool verify_ustar_chksum( const uint8_t * const header );
class Arg_parser;
int concatenate( const std::string & archive_name, const Arg_parser & parser,
const int filenames );
@@ -117,16 +146,29 @@ int encode( const std::string & archive_name, const Arg_parser & parser,
const int filenames, const int level, const bool append );
// defined in extract.cc
+bool block_is_zero( const uint8_t * const buf, const int size );
+void format_member_name( const Extended & extended, const Tar_header header,
+ Resizable_buffer & rbuf, const bool long_format );
+const char * remove_leading_slash( const char * const filename );
+bool compare_prefix_dir( const char * const dir, const char * const name );
+bool compare_tslash( const char * const name1, const char * const name2 );
+unsigned long long parse_octal( const uint8_t * const ptr, const int size );
int decode( const std::string & archive_name, const Arg_parser & parser,
- const int filenames, const bool keep_damaged, const bool listing,
- const bool missing_crc, const bool permissive );
+ const int filenames, const int num_workers, const int debug_level,
+ const bool keep_damaged, const bool listing, const bool missing_crc,
+ const bool permissive );
+
+// defined in list_lz.cc
+class Lzip_index;
+int list_lz( const Arg_parser & parser, std::vector< char > & name_pending,
+ const Lzip_index & lzip_index, const int filenames,
+ const int debug_level, const int infd, const int num_workers,
+ const bool missing_crc, const bool permissive );
// defined in main.cc
extern int verbosity;
int open_instream( const std::string & name );
int open_outstream( const std::string & name, const bool create = true );
-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 );
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,