Disk ARchive  2.5.2
Full featured and portable backup and archiving tool
macro_tools.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 MACRO_TOOLS_HPP
27 #define MACRO_TOOLS_HPP
28 
29 #include "../my_config.h"
30 
31 extern "C"
32 {
33 #if HAVE_LIMITS_H
34 #include <limits.h>
35 #endif
36 }
37 #include <string>
38 
39 #include "catalogue.hpp"
40 #include "compressor.hpp"
41 #include "infinint.hpp"
42 #include "header_version.hpp"
43 #include "generic_file.hpp"
44 #include "scrambler.hpp"
45 #include "crypto.hpp"
46 #include "escape.hpp"
47 #include "pile.hpp"
48 #include "entrepot.hpp"
49 #include "tools.hpp"
50 #include "range.hpp"
51 #include "slice_layout.hpp"
52 #include "trivial_sar.hpp"
53 
54 
57 
58 
59 #define BUFFER_SIZE 102400
60 #ifdef SSIZE_MAX
61 #if SSIZE_MAX < BUFFER_SIZE
62 #undef BUFFER_SIZE
63 #define BUFFER_SIZE SSIZE_MAX
64 #endif
65 #endif
66 
67 #define GLOBAL_ELASTIC_BUFFER_SIZE 51200
68 
69 namespace libdar
70 {
71 
72  extern const archive_version macro_tools_supported_version;
73  extern const std::string LIBDAR_STACK_LABEL_UNCOMPRESSED;
74  extern const std::string LIBDAR_STACK_LABEL_CLEAR;
75  extern const std::string LIBDAR_STACK_LABEL_UNCYPHERED;
76  extern const std::string LIBDAR_STACK_LABEL_LEVEL1;
77 
79  extern trivial_sar *macro_tools_open_archive_tuyau(user_interaction & dialog,
80  memory_pool *pool,
81  S_I fd,
82  gf_mode mode,
83  const label & internal_name,
84  const label & data_name,
85  bool slice_header_format_07,
86  const std::string & execute);
87 
88 
115 
116  extern void macro_tools_open_archive(user_interaction & dialog, //< for user interaction
117  memory_pool *pool, //< whether memory_pool allocation has to be performed
118  const entrepot &where, //< slices location
119  const std::string &basename, //< slice basename
120  const infinint & min_digits, //< minimum digits for the slice number
121  const std::string &extension, //< slice extensions
122  crypto_algo crypto, //< encryption algorithm
123  const secu_string &pass, //< pass key for crypto/scrambling
124  U_32 crypto_size, //< crypto block size
125  pile & stack, //< the stack of generic_file resulting of the archive openning
126  header_version &ver, //< header read from raw data
127  const std::string &input_pipe, //< named pipe for input when basename is "-" (dar_slave)
128  const std::string &output_pipe, //< named pipe for output when basename is "-" (dar_slave)
129  const std::string & execute, //< command to execute between slices
130  infinint & second_terminateur_offset, //< where to start looking for the second terminateur (set to zero if there is only one terminateur).
131  bool lax, // whether we skip&warn the usual verifications
132  bool sequential_read, // whether to use the escape sequence (if present) to get archive contents and proceed to sequential reading
133  bool info_details, // be or not verbose about the archive openning
134  std::list<signator> & gnupg_signed, //< list of existing signature found for that archive (valid or not)
135  slice_layout & sl, //< slicing layout of the archive
136  bool multi_threaded); //< true if several thread shall be run concurrently by libdar
137  // all allocated objects (ret1, ret2, scram), must be deleted when no more needed by the caller of this routine
138 
140  extern catalogue *macro_tools_get_derivated_catalogue_from(user_interaction & dialog,
141  memory_pool *pool,
142  pile & data_stack, // where to get the files and EA from
143  pile & cata_stack, // where to get the catalogue from
144  const header_version & ver, // version format as defined in the header of the archive to read
145  bool info_details, // verbose display (throught user_interaction)
146  infinint &cat_size, // return size of archive in file (not in memory !)
147  const infinint & second_terminateur_offset, // location of the second terminateur (zero if none exist)
148  std::list<signator> & signatories, // returns the list of signatories (empty if archive is was not signed)
149  bool lax_mode); // whether to do relaxed checkings
150 
152  extern catalogue *macro_tools_get_catalogue_from(user_interaction & dialog,
153  memory_pool *pool,
154  pile & stack, // raw data access object
155  const header_version & ver, // version format as defined in the header of the archive to read
156  bool info_details, // verbose display (throught user_interaction)
157  infinint &cat_size, // return size of archive in file (not in memory !)
158  const infinint & second_terminateur_offset,
159  std::list<signator> & signatories, // returns the list of signatories (empty if archive is was not signed)
160  bool lax_mode);
161 
163  extern catalogue *macro_tools_read_catalogue(user_interaction & dialog,
164  memory_pool *pool,
165  const header_version & ver,
166  const pile_descriptor & cata_pdesc,
167  const infinint & cat_size,
168  std::list<signator> & signatories,
169  bool lax_mode,
170  const label & lax_layer1_data_name,
171  bool only_detruits);
172 
173  extern catalogue *macro_tools_lax_search_catalogue(user_interaction & dialog,
174  memory_pool *pool,
175  pile & stack,
176  const archive_version & edition,
177  compression compr_algo,
178  bool info_details,
179  bool even_partial_catalogues,
180  const label & layer1_data_name);
181 
182  // return the offset of the beginning of the catalogue.
183  extern infinint macro_tools_get_terminator_start(generic_file & f, const archive_version & reading_ver);
184 
244 
245  extern void macro_tools_create_layers(user_interaction & dialog,
246  pile & layers,
247  header_version & ver,
248  slice_layout & slicing,
249  const slice_layout *ref_slicing,
250  memory_pool *pool,
251  const entrepot & sauv_path_t,
252  const std::string & filename,
253  const std::string & extension,
254  bool allow_over,
255  bool warn_over,
256  bool info_details,
257  const infinint & pause,
258  compression algo,
259  U_I compression_level,
260  const infinint & file_size,
261  const infinint & first_file_size,
262  const std::string & execute,
263  crypto_algo crypto,
264  const secu_string & pass,
265  U_32 crypto_size,
266  const std::vector<std::string> & gnupg_recipients,
267  const std::vector<std::string> & gnupg_signatories,
268  bool empty,
269  const std::string & slice_permission,
270  bool add_marks_for_sequential_reading,
271  const std::string & user_comment,
272  hash_algo hash,
273  const infinint & slice_min_digits,
274  const label & internal_name,
275  const label & data_name,
276  bool multi_threaded);
277 
290  void macro_tools_close_layers(user_interaction & dialog,
291  pile & layers,
292  const header_version & ver,
293  const catalogue & cat,
294  bool info_details,
295  crypto_algo crypto,
296  compression algo,
297  const std::vector<std::string> & gnupg_recipients,
298  const std::vector<std::string> & gnupg_signatories,
299  bool empty);
300 
301 
308  range macro_tools_get_slices(const cat_nomme *obj, slice_layout sl);
309 
310 } // end of namespace
311 
313 
314 #endif
defines the entrepot interface. Entrepot interface defines a generic way to interact with files (slic...
void macro_tools_close_layers(user_interaction &dialog, pile &layers, const header_version &ver, const catalogue &cat, bool info_details, crypto_algo crypto, compression algo, const std::vector< std::string > &gnupg_recipients, const std::vector< std::string > &gnupg_signatories, bool empty)
catalogue * macro_tools_get_catalogue_from(user_interaction &dialog, memory_pool *pool, pile &stack, const header_version &ver, bool info_details, infinint &cat_size, const infinint &second_terminateur_offset, std::list< signator > &signatories, bool lax_mode)
uses terminator to skip to the position where to find the catalogue and read it
a set of general purpose routines
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
class pile definition. Used to manage a stack of generic_file objects
range macro_tools_get_slices(const cat_nomme *obj, slice_layout sl)
the trivial_sar classes manages the slicing layer when single slice is used
the crypto algoritm definition
gf_mode
generic_file openning modes
object describing the slicing of an archive
void macro_tools_create_layers(user_interaction &dialog, pile &layers, header_version &ver, slice_layout &slicing, const slice_layout *ref_slicing, memory_pool *pool, const entrepot &sauv_path_t, const std::string &filename, const std::string &extension, bool allow_over, bool warn_over, bool info_details, const infinint &pause, compression algo, U_I compression_level, const infinint &file_size, const infinint &first_file_size, const std::string &execute, crypto_algo crypto, const secu_string &pass, U_32 crypto_size, const std::vector< std::string > &gnupg_recipients, const std::vector< std::string > &gnupg_signatories, bool empty, const std::string &slice_permission, bool add_marks_for_sequential_reading, const std::string &user_comment, hash_algo hash, const infinint &slice_min_digits, const label &internal_name, const label &data_name, bool multi_threaded)
archive global header/trailer structure is defined here
crypto_algo
the different cypher available for encryption (strong or weak)
Definition: crypto.hpp:51
catalogue * macro_tools_read_catalogue(user_interaction &dialog, memory_pool *pool, const header_version &ver, const pile_descriptor &cata_pdesc, const infinint &cat_size, std::list< signator > &signatories, bool lax_mode, const label &lax_layer1_data_name, bool only_detruits)
read the catalogue from cata_stack assuming the cata_stack is positionned at the beginning of the are...
class escape definition, used for sequential reading of archivesThe class escape is used to insert es...
trivial_sar * macro_tools_open_archive_tuyau(user_interaction &dialog, memory_pool *pool, S_I fd, gf_mode mode, const label &internal_name, const label &data_name, bool slice_header_format_07, const std::string &execute)
create an container to write an archive to a pipe
void macro_tools_open_archive(user_interaction &dialog, memory_pool *pool, const entrepot &where, const std::string &basename, const infinint &min_digits, const std::string &extension, crypto_algo crypto, const secu_string &pass, U_32 crypto_size, pile &stack, header_version &ver, const std::string &input_pipe, const std::string &output_pipe, const std::string &execute, infinint &second_terminateur_offset, bool lax, bool sequential_read, bool info_details, std::list< signator > &gnupg_signed, slice_layout &sl, bool multi_threaded)
switch module to limitint (32 ou 64 bits integers) or infinint
compression
the different compression algorithm available
Definition: compressor.hpp:43
compression engine implementation
contains the definition of the scrambler class, a very weak encryption scheme
class than provide a way to manipulate and represent range of integer numbers (infinint) ...
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
catalogue * macro_tools_get_derivated_catalogue_from(user_interaction &dialog, memory_pool *pool, pile &data_stack, pile &cata_stack, const header_version &ver, bool info_details, infinint &cat_size, const infinint &second_terminateur_offset, std::list< signator > &signatories, bool lax_mode)
uses terminator to skip to the position where to find the catalogue and read it, taking care of havin...
here is defined the many classed which is build of the catalogue