Disk ARchive  2.5.6
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 has_external_cat, //< true if the catalogue will not be read from the current archive (flag used in lax mode only)
133  bool sequential_read, // whether to use the escape sequence (if present) to get archive contents and proceed to sequential reading
134  bool info_details, // be or not verbose about the archive openning
135  std::list<signator> & gnupg_signed, //< list of existing signature found for that archive (valid or not)
136  slice_layout & sl, //< slicing layout of the archive
137  bool multi_threaded); //< true if several thread shall be run concurrently by libdar
138  // all allocated objects (ret1, ret2, scram), must be deleted when no more needed by the caller of this routine
139 
141  extern catalogue *macro_tools_get_derivated_catalogue_from(user_interaction & dialog,
142  memory_pool *pool,
143  pile & data_stack, // where to get the files and EA from
144  pile & cata_stack, // where to get the catalogue from
145  const header_version & ver, // version format as defined in the header of the archive to read
146  bool info_details, // verbose display (throught user_interaction)
147  infinint &cat_size, // return size of archive in file (not in memory !)
148  const infinint & second_terminateur_offset, // location of the second terminateur (zero if none exist)
149  std::list<signator> & signatories, // returns the list of signatories (empty if archive is was not signed)
150  bool lax_mode); // whether to do relaxed checkings
151 
153  extern catalogue *macro_tools_get_catalogue_from(user_interaction & dialog,
154  memory_pool *pool,
155  pile & stack, // raw data access object
156  const header_version & ver, // version format as defined in the header of the archive to read
157  bool info_details, // verbose display (throught user_interaction)
158  infinint &cat_size, // return size of archive in file (not in memory !)
159  const infinint & second_terminateur_offset,
160  std::list<signator> & signatories, // returns the list of signatories (empty if archive is was not signed)
161  bool lax_mode);
162 
164  extern catalogue *macro_tools_read_catalogue(user_interaction & dialog,
165  memory_pool *pool,
166  const header_version & ver,
167  const pile_descriptor & cata_pdesc,
168  const infinint & cat_size,
169  std::list<signator> & signatories,
170  bool lax_mode,
171  const label & lax_layer1_data_name,
172  bool only_detruits);
173 
174  extern catalogue *macro_tools_lax_search_catalogue(user_interaction & dialog,
175  memory_pool *pool,
176  pile & stack,
177  const archive_version & edition,
178  compression compr_algo,
179  bool info_details,
180  bool even_partial_catalogues,
181  const label & layer1_data_name);
182 
183  // return the offset of the beginning of the catalogue.
184  extern infinint macro_tools_get_terminator_start(generic_file & f, const archive_version & reading_ver);
185 
245 
246  extern void macro_tools_create_layers(user_interaction & dialog,
247  pile & layers,
248  header_version & ver,
249  slice_layout & slicing,
250  const slice_layout *ref_slicing,
251  memory_pool *pool,
252  const entrepot & sauv_path_t,
253  const std::string & filename,
254  const std::string & extension,
255  bool allow_over,
256  bool warn_over,
257  bool info_details,
258  const infinint & pause,
259  compression algo,
260  U_I compression_level,
261  const infinint & file_size,
262  const infinint & first_file_size,
263  const std::string & execute,
264  crypto_algo crypto,
265  const secu_string & pass,
266  U_32 crypto_size,
267  const std::vector<std::string> & gnupg_recipients,
268  const std::vector<std::string> & gnupg_signatories,
269  bool empty,
270  const std::string & slice_permission,
271  bool add_marks_for_sequential_reading,
272  const std::string & user_comment,
273  hash_algo hash,
274  const infinint & slice_min_digits,
275  const label & internal_name,
276  const label & data_name,
277  bool multi_threaded);
278 
291  void macro_tools_close_layers(user_interaction & dialog,
292  pile & layers,
293  const header_version & ver,
294  const catalogue & cat,
295  bool info_details,
296  crypto_algo crypto,
297  compression algo,
298  const std::vector<std::string> & gnupg_recipients,
299  const std::vector<std::string> & gnupg_signatories,
300  bool empty);
301 
302 
309  range macro_tools_get_slices(const cat_nomme *obj, slice_layout sl);
310 
311 } // end of namespace
312 
314 
315 #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
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
switch module to limitint (32 ou 64 bits integers) or infinint
compression
the different compression algorithm available
Definition: compressor.hpp:43
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 has_external_cat, bool sequential_read, bool info_details, std::list< signator > &gnupg_signed, slice_layout &sl, bool multi_threaded)
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