Loading...
Searching...
No Matches
macro_tools.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2024 Denis Corbin
//
// 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 the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// to contact the author, see the AUTHOR file
/*********************************************************************/
#ifndef MACRO_TOOLS_HPP
#define MACRO_TOOLS_HPP
#include "../my_config.h"
extern "C"
{
#if HAVE_LIMITS_H
#include <limits.h>
#endif
}
#include <string>
#include <vector>
#include "catalogue.hpp"
#include "compression.hpp"
#include "infinint.hpp"
#include "header_version.hpp"
#include "generic_file.hpp"
#include "crypto.hpp"
#include "pile.hpp"
#include "entrepot.hpp"
#include "range.hpp"
#include "slice_layout.hpp"
#include "tuyau.hpp"
#include "trivial_sar.hpp"
#include "proto_compressor.hpp"
#define BUFFER_SIZE 102400
#ifdef SSIZE_MAX
#if SSIZE_MAX < BUFFER_SIZE
#undef BUFFER_SIZE
#define BUFFER_SIZE SSIZE_MAX
#endif
#endif
namespace libdar
{
constexpr U_I GLOBAL_ELASTIC_BUFFER_SIZE = 51200;
extern const archive_version macro_tools_supported_version;
extern const std::string LIBDAR_STACK_LABEL_UNCOMPRESSED;
extern const std::string LIBDAR_STACK_LABEL_CLEAR;
extern const std::string LIBDAR_STACK_LABEL_UNCYPHERED;
extern const std::string LIBDAR_STACK_LABEL_LEVEL1;
extern trivial_sar *macro_tools_open_archive_tuyau(const std::shared_ptr<user_interaction> & dialog,
S_I fd,
gf_mode mode,
const label & internal_name,
const label & data_name,
bool slice_header_format_07,
const std::string & execute);
extern void macro_tools_open_archive(const std::shared_ptr<user_interaction> & dialog,
const std::shared_ptr<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,
U_I multi_threaded_crypto,
U_I multi_threaded_compress,
bool header_only
);
// all allocated objects (ret1, ret2, scram), must be deleted when no more needed by the caller of this routine
extern catalogue *macro_tools_get_derivated_catalogue_from(const std::shared_ptr<user_interaction> & dialog,
pile & data_stack, // where to get the files and EA from
pile & cata_stack, // where to get the catalogue from
const header_version & ver, // version format as defined in the header of the archive to read
bool info_details, // verbose display (throught user_interaction)
infinint &cat_size, // return size of archive in file (not in memory !)
const infinint & second_terminateur_offset, // location of the second terminateur (zero if none exist)
std::list<signator> & signatories, // returns the list of signatories (empty if archive is was not signed)
bool lax_mode); // whether to do relaxed checkings
extern catalogue *macro_tools_get_catalogue_from(const std::shared_ptr<user_interaction> & dialog,
pile & stack, // raw data access object
const header_version & ver, // version format as defined in the header of the archive to read
bool info_details, // verbose display (throught user_interaction)
infinint &cat_size, // return size of archive in file (not in memory !)
const infinint & second_terminateur_offset,
std::list<signator> & signatories, // returns the list of signatories (empty if archive is was not signed)
bool lax_mode);
extern catalogue *macro_tools_read_catalogue(const std::shared_ptr<user_interaction> & dialog,
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);
extern catalogue *macro_tools_lax_search_catalogue(const std::shared_ptr<user_interaction> & dialog,
pile & stack,
const archive_version & edition,
compression compr_algo,
bool info_details,
bool even_partial_catalogues,
const label & layer1_data_name);
// return the offset of the beginning of the catalogue.
extern infinint macro_tools_get_terminator_start(generic_file & f, const archive_version & reading_ver);
extern void macro_tools_create_layers(const std::shared_ptr<user_interaction> & dialog,
pile & layers,
header_version & ver,
slice_layout & slicing,
const slice_layout *ref_slicing,
const std::shared_ptr<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,
U_I compression_block_size,
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,
const infinint & iteration_count,
hash_algo kdf_hash,
U_I multi_threaded_crypto,
U_I multi_threaded_compress);
extern void macro_tools_close_layers(const std::shared_ptr<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);
extern range macro_tools_get_slices(const cat_nomme *obj, slice_layout sl);
extern void macro_tools_open_pipes(const std::shared_ptr<user_interaction> & dialog,
const std::string &input,
const std::string & output,
tuyau *&in,
tuyau *&out);
extern proto_compressor* macro_tools_build_streaming_compressor(compression algo,
generic_file & base,
U_I compression_level,
U_I num_workers);
extern proto_compressor* macro_tools_build_block_compressor(compression algo,
generic_file & base,
U_I compression_level,
U_I num_workers,
U_I block_size);
} // end of namespace
#endif
catalogue.hpp
here is defined the classe used to manage catalogue of archives
libdar::archive_version
class archive_version manages the version of the archive format
Definition archive_version.hpp:47
libdar::cat_nomme
the base class for all entry that have a name
Definition cat_nomme.hpp:45
libdar::catalogue
the catalogue class which gather all objects contained in a give archive
Definition catalogue.hpp:60
libdar::generic_file
this is the interface class from which all other data transfer classes inherit
Definition generic_file.hpp:77
libdar::header_version
manages the archive header and trailer
Definition header_version.hpp:48
libdar::infinint
the arbitrary large positive integer class
Definition real_infinint.hpp:62
libdar::label
manage label data structure used in archive slice headers
Definition label.hpp:43
libdar::pile
stores a stack of generic_files writing/reading on each others
Definition pile.hpp:44
libdar::range
stores a range of integers or a set of ranges
Definition range.hpp:44
libdar::secu_string
class secu_string
Definition secu_string.hpp:54
libdar::trivial_sar
Definition trivial_sar.hpp:54
libdar::tuyau
pipe implementation under the generic_file interface.
Definition tuyau.hpp:49
compression.hpp
compression parameters for API
crypto.hpp
the crypto algoritm definition
entrepot.hpp
defines the entrepot interface.
generic_file.hpp
class generic_file is defined here as well as class fichier
libdar::hash_algo
hash_algo
hashing algorithm available
Definition archive_aux.hpp:63
libdar::compression
compression
the different compression algorithm available
Definition compression.hpp:46
libdar::crypto_algo
crypto_algo
the different cypher available for encryption (strong or weak)
Definition crypto.hpp:50
libdar::macro_tools_create_layers
void macro_tools_create_layers(const std::shared_ptr< user_interaction > &dialog, pile &layers, header_version &ver, slice_layout &slicing, const slice_layout *ref_slicing, const std::shared_ptr< 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, U_I compression_block_size, 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, const infinint &iteration_count, hash_algo kdf_hash, U_I multi_threaded_crypto, U_I multi_threaded_compress)
build layers for a new archive
libdar::macro_tools_close_layers
void macro_tools_close_layers(const std::shared_ptr< 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)
dumps the catalogue and close all the archive layers to terminate the archive
libdar::macro_tools_get_slices
range macro_tools_get_slices(const cat_nomme *obj, slice_layout sl)
gives the location of data EA and FSA (when they are saved) of the object given in argument
libdar::macro_tools_read_catalogue
catalogue * macro_tools_read_catalogue(const std::shared_ptr< user_interaction > &dialog, 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...
libdar::macro_tools_get_catalogue_from
catalogue * macro_tools_get_catalogue_from(const std::shared_ptr< user_interaction > &dialog, 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
libdar::macro_tools_open_pipes
void macro_tools_open_pipes(const std::shared_ptr< user_interaction > &dialog, const std::string &input, const std::string &output, tuyau *&in, tuyau *&out)
open a pair of tuyau objects encapsulating two named pipes.
libdar::macro_tools_get_derivated_catalogue_from
catalogue * macro_tools_get_derivated_catalogue_from(const std::shared_ptr< user_interaction > &dialog, 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...
libdar::macro_tools_build_block_compressor
proto_compressor * macro_tools_build_block_compressor(compression algo, generic_file &base, U_I compression_level, U_I num_workers, U_I block_size)
return a proto_compressor object realizing the desired (de)compression level/algo on to of "base" in ...
libdar::macro_tools_build_streaming_compressor
proto_compressor * macro_tools_build_streaming_compressor(compression algo, generic_file &base, U_I compression_level, U_I num_workers)
return a proto_compressor object realizing the desired (de)compression level/aglo on top of "base" in...
libdar::gf_mode
gf_mode
generic_file openning modes
Definition gf_mode.hpp:44
libdar::macro_tools_open_archive_tuyau
trivial_sar * macro_tools_open_archive_tuyau(const std::shared_ptr< user_interaction > &dialog, 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
libdar::macro_tools_open_archive
void macro_tools_open_archive(const std::shared_ptr< user_interaction > &dialog, const std::shared_ptr< 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, U_I multi_threaded_crypto, U_I multi_threaded_compress, bool header_only)
setup the given pile object to contain a stack of generic_files suitable to read an archive
header_version.hpp
archive global header/trailer structure is defined here
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47
pile.hpp
class pile definition. Used to manage a stack of generic_file objects
proto_compressor.hpp
abstracted ancestor class for compressor and parallel_compressor classes
range.hpp
class than provide a way to manipulate and represent range of integer numbers (infinint)
slice_layout.hpp
object describing the slicing of an archive
trivial_sar.hpp
the trivial_sar classes manages the slicing layer when single slice is used
tuyau.hpp
defines the implementation of pipe under the generic_file interface.