| Disk ARchive 2.5.10 Full featured and portable backup and archiving tool

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

header_version.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26 #ifndef HEADER_VERSION_HPP
27 #define HEADER_VERSION_HPP
28
29 #include "../my_config.h"
30 #include "infinint.hpp"
31 #include "generic_file.hpp"
32 #include "tools.hpp"
33 #include "archive_version.hpp"
34 #include "on_pool.hpp"
35 #include "crypto.hpp"
36 #include "slice_layout.hpp"
37 #include "compressor.hpp"
38
39 namespace libdar
40 {
41
44
46 class header_version : public on_pool
47 {
48 public:
49 header_version();
50 header_version(const header_version & ref) { copy_from(ref); };
51 const header_version & operator = (const header_version & ref) { detruit(); copy_from(ref); return * this; };
52 ~header_version() { detruit(); };
53
55 void read(generic_file &f, user_interaction & dialog, bool lax_mode);
56
58 void write(generic_file &f) const;
59
60 // settings
61
62 void set_edition(const archive_version & ed) { edition = ed; };
63 void set_compression_algo(const compression & zip) { algo_zip = zip; };
64 void set_command_line(const std::string & line) { cmd_line = line; };
65 void set_initial_offset(const infinint & offset) { initial_offset = offset; };
66 void set_sym_crypto_algo(const crypto_algo & algo) { sym = algo; };
67
69 void set_crypted_key(memory_file *key) { if(key == nullptr) throw SRC_BUG; clear_crypted_key(); crypted_key = key; };
70 void clear_crypted_key() { if(crypted_key != nullptr) { delete crypted_key; crypted_key = nullptr; } };
71
73 void set_slice_layout(slice_layout *layout) { if(layout == nullptr) throw SRC_BUG; clear_slice_layout(); ref_layout = layout; };
74 void clear_slice_layout() { if(ref_layout != nullptr) { delete ref_layout; ref_layout = nullptr; } };
75
76 void set_tape_marks(bool presence) { has_tape_marks = presence; };
77 void set_signed(bool is_signed) { arch_signed = is_signed; };
78
79 // gettings
80
81 const archive_version & get_edition() const { return edition; };
82 compression get_compression_algo() const { return algo_zip; };
83 const std::string & get_command_line() const { return cmd_line; };
84 const infinint & get_initial_offset() const { return initial_offset; };
85
86 bool is_ciphered() const { return ciphered || sym != crypto_none; };
87 bool is_signed() const { return arch_signed; };
88 crypto_algo get_sym_crypto_algo() const { return sym; };
89 memory_file *get_crypted_key() const { return crypted_key; };
90 const slice_layout *get_slice_layout() const { return ref_layout; };
91 bool get_tape_marks() const { return has_tape_marks; };
92
93 private:
94 archive_version edition; //< archive format
95 compression algo_zip; //< compression algorithm used
96 std::string cmd_line; //< used long ago to store cmd_line, then abandonned, then recycled as a user comment field
97 infinint initial_offset; //< defines at which offset starts the archive (passed the archive header), this field is obiously only used in the trailer not in the header
98 // has to be set to zero when it is unknown, in that case this field is not dump to archive
99 crypto_algo sym; //< strong encryption algorithm used for symmetrical encryption
100 memory_file *crypted_key;//< optional field containing the asymmetrically ciphered key used for strong encryption ciphering
101 slice_layout *ref_layout;//< optional field used in isolated catalogues to record the slicing layout of their archive of reference
102 bool has_tape_marks; //< whether the archive contains tape marks aka escape marks aka sequence marks
103
104 bool ciphered; // whether the archive is ciphered, even if we do not know its crypto algorithm (old archives)
105 bool arch_signed; // whether the archive is signed
106
107 void copy_from(const header_version & ref);
108 void detruit();
109
110 // FLAG VALUES
111
112 static const U_I FLAG_SAVED_EA_ROOT = 0x80; //< no more used since version "05"
113 static const U_I FLAG_SAVED_EA_USER = 0x40; //< no more used since version "05"
114 static const U_I FLAG_SCRAMBLED = 0x20; //< scrambled or strong encryption used
115 static const U_I FLAG_SEQUENCE_MARK = 0x10; //< escape sequence marks present for sequential reading
116 static const U_I FLAG_INITIAL_OFFSET = 0x08; //< whether the header contains the initial offset (size of clear data before encrypted) NOTE : This value is set internally by header_version, no need to set flag with it! But that's OK to set it or not, it will be updated according to initial_offset's value.
117 static const U_I FLAG_HAS_CRYPTED_KEY = 0x04; //< the header contains a symmetrical key encrypted with asymmetrical algorithm
118 static const U_I FLAG_HAS_REF_SLICING = 0x02; //< the header contains the slicing information of the archive of reference (used for isolated catalogue)
119 static const U_I FLAG_HAS_AN_EXTENDED_SIZE = 0x01; //< the flag is two bytes length
120 static const U_I FLAG_ARCHIVE_IS_SIGNED = 0x0200; //< archive is signed
121 static const U_I FLAG_HAS_AN_SECOND_EXTENDED_SIZE = 0x0101; //< reserved for future use
122 };
123
124 } // end of namespace
125
126 #endif
libdar::on_pool
Definition: on_pool.hpp:52
libdar::header_version::read
void read(generic_file &f, user_interaction &dialog, bool lax_mode)
read the header or trailer from the archive
tools.hpp
a set of general purpose routines
generic_file.hpp
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
libdar::header_version::set_crypted_key
void set_crypted_key(memory_file *key)
the object pointed to by key passes to the responsibility of this header_version object ...
Definition: header_version.hpp:69
libdar::user_interaction
This is a pure virtual class that is used by libdar when interaction with the user is required...
Definition: user_interaction.hpp:98
libdar::header_version
manages the archive header and trailer
Definition: header_version.hpp:46
crypto.hpp
the crypto algoritm definition
slice_layout.hpp
object describing the slicing of an archive
libdar::crypto_algo
crypto_algo
the different cypher available for encryption (strong or weak)
Definition: crypto.hpp:51
libdar::header_version::write
void write(generic_file &f) const
write down the object to the archive (as header if wrote at the beginning of the archive, as trailer is at the end)
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
libdar::compression
compression
the different compression algorithm available
Definition: compressor.hpp:43
libdar::generic_file
this is the interface class from which all other data transfer classes inherit
Definition: generic_file.hpp:100
libdar::crypto_none
no encryption
Definition: crypto.hpp:53
compressor.hpp
compression engine implementation
archive_version.hpp
class archive_version that rules which archive format to follow
on_pool.hpp
this is the base class of object that can be allocated on a memory pool
libdar::header_version::set_slice_layout
void set_slice_layout(slice_layout *layout)
the object pointed to by layout is passed under the responsibility of this header_version object ...
Definition: header_version.hpp:73
libdar::infinint
the arbitrary large positive integer class
Definition: real_infinint.hpp:59
libdar::archive_version
class archive_version manages the version of the archive format
Definition: archive_version.hpp:44
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47