![]() |
Disk ARchive
2.5.2
Full featured and portable backup and archiving tool
|
00001 /*********************************************************************/ 00002 // dar - disk archive - a backup/restoration program 00003 // Copyright (C) 2002-2052 Denis Corbin 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 // to contact the author : http://dar.linux.free.fr/email.html 00020 /*********************************************************************/ 00021 00025 00026 #ifndef ARCHIVE_OPTIONS_HPP 00027 #define ARCHIVE_OPTIONS_HPP 00028 00029 #include "../my_config.h" 00030 #include "crypto.hpp" 00031 #include "integers.hpp" 00032 #include "mask.hpp" 00033 #include "compressor.hpp" 00034 #include "catalogue.hpp" 00035 #include "criterium.hpp" 00036 #include "hash_fichier.hpp" 00037 #include "secu_string.hpp" 00038 #include "nls_swap.hpp" 00039 #include "entrepot.hpp" 00040 #include "fsa_family.hpp" 00041 #include "on_pool.hpp" 00042 00043 #include <string> 00044 00045 namespace libdar 00046 { 00047 class archive; // needed to be able to use pointer on archive object. 00048 00049 00053 00056 00057 00059 class archive_options_read : public on_pool 00060 { 00061 public: 00063 archive_options_read(); 00064 00066 archive_options_read(const archive_options_read & ref) : x_ref_chem(ref.x_ref_chem) { copy_from(ref); }; 00067 const archive_options_read & operator = (const archive_options_read & ref) { destroy(); copy_from(ref); return *this; }; 00068 ~archive_options_read() { destroy(); }; 00069 00070 00072 // set back to default (this is the state just after the object is constructed 00073 // this method is to be used to reuse a given object 00074 00076 void clear(); 00077 00078 00080 // setting methods 00081 00082 00089 void set_crypto_algo(crypto_algo val) { x_crypto = val; }; 00090 00092 void set_crypto_pass(const secu_string & pass) { x_pass = pass; }; 00093 00095 void set_crypto_size(U_32 crypto_size) { x_crypto_size = crypto_size; }; 00096 00098 void set_default_crypto_size(); 00099 00101 00104 void set_input_pipe(const std::string & input_pipe) { x_input_pipe = input_pipe; }; 00105 00107 00110 void set_output_pipe(const std::string & output_pipe) { x_output_pipe = output_pipe; }; 00111 00113 00121 void set_execute(const std::string & execute) { x_execute = execute; }; 00122 00124 void set_info_details(bool info_details) { x_info_details = info_details; }; 00125 00127 00131 void set_lax(bool val) { x_lax = val; }; 00132 00134 00136 00137 void set_sequential_read(bool val) { x_sequential_read = val; }; 00138 00140 00141 void set_slice_min_digits(infinint val) { x_slice_min_digits = val; }; 00142 00143 00145 void set_entrepot(const entrepot & entr) { if(x_entrepot != nullptr) delete x_entrepot; x_entrepot = entr.clone(); if(x_entrepot == nullptr) throw Ememory("archive_options_read::set_entrepot"); }; 00146 00148 void set_ignore_signature_check_failure(bool val) { x_ignore_signature_check_failure = val; }; 00149 00151 void set_multi_threaded(bool val) { x_multi_threaded = val; }; 00152 00153 00155 00157 void set_external_catalogue(const path & ref_chem, const std::string & ref_basename) { x_ref_chem = ref_chem, x_ref_basename = ref_basename; external_cat = true; }; 00159 void unset_external_catalogue(); 00160 00162 void set_ref_crypto_algo(crypto_algo ref_crypto) { x_ref_crypto = ref_crypto; }; 00163 00165 void set_ref_crypto_pass(const secu_string & ref_pass) { x_ref_pass = ref_pass; }; 00166 00168 void set_ref_crypto_size(U_32 ref_crypto_size) { x_ref_crypto_size = ref_crypto_size; }; 00169 00171 00179 void set_ref_execute(const std::string & ref_execute) { x_ref_execute = ref_execute; }; 00180 00181 00183 00184 void set_ref_slice_min_digits(infinint val) { x_ref_slice_min_digits = val; }; 00185 00187 void set_ref_entrepot(const entrepot & entr) { if(x_ref_entrepot != nullptr) delete x_ref_entrepot; x_ref_entrepot = entr.clone(); if(x_ref_entrepot == nullptr) throw Ememory("archive_options_read::set_entrepot"); }; 00188 00189 00190 00191 00193 // getting methods (mainly used inside libdar, but kept public and part of the API in the case it is needed) 00194 00195 00196 crypto_algo get_crypto_algo() const { return x_crypto; }; 00197 const secu_string & get_crypto_pass() const { return x_pass; }; 00198 U_32 get_crypto_size() const { return x_crypto_size; }; 00199 const std::string & get_input_pipe() const { return x_input_pipe; }; 00200 const std::string & get_output_pipe() const { return x_output_pipe; }; 00201 const std::string & get_execute() const { return x_execute; }; 00202 bool get_info_details() const { return x_info_details; }; 00203 bool get_lax() const { return x_lax; }; 00204 bool get_sequential_read() const { return x_sequential_read; }; 00205 infinint get_slice_min_digits() const { return x_slice_min_digits; }; 00206 const entrepot & get_entrepot() const { if(x_entrepot == nullptr) throw SRC_BUG; return *x_entrepot; }; 00207 bool get_ignore_signature_check_failure() const { return x_ignore_signature_check_failure; }; 00208 bool get_multi_threaded() const { return x_multi_threaded; }; 00209 00210 // All methods that follow concern the archive where to fetch the (isolated) catalogue from 00211 bool is_external_catalogue_set() const { return external_cat; }; 00212 const path & get_ref_path() const; 00213 const std::string & get_ref_basename() const; 00214 crypto_algo get_ref_crypto_algo() const { return x_ref_crypto; }; 00215 const secu_string & get_ref_crypto_pass() const { return x_ref_pass; }; 00216 U_32 get_ref_crypto_size() const { return x_ref_crypto_size; }; 00217 const std::string & get_ref_execute() const { return x_ref_execute; }; 00218 infinint get_ref_slice_min_digits() const { return x_ref_slice_min_digits; }; 00219 const entrepot & get_ref_entrepot() const { if(x_ref_entrepot == nullptr) throw SRC_BUG; return *x_ref_entrepot; }; 00220 00221 00222 private: 00223 crypto_algo x_crypto; 00224 secu_string x_pass; 00225 U_32 x_crypto_size; 00226 std::string x_input_pipe; 00227 std::string x_output_pipe; 00228 std::string x_execute; 00229 bool x_info_details; 00230 bool x_lax; 00231 bool x_sequential_read; 00232 infinint x_slice_min_digits; 00233 entrepot *x_entrepot; 00234 bool x_ignore_signature_check_failure; 00235 bool x_multi_threaded; 00236 00237 00238 // external catalogue relative fields 00239 bool external_cat; 00240 path x_ref_chem; 00241 std::string x_ref_basename; 00242 crypto_algo x_ref_crypto; 00243 secu_string x_ref_pass; 00244 U_32 x_ref_crypto_size; 00245 std::string x_ref_execute; 00246 infinint x_ref_slice_min_digits; 00247 entrepot *x_ref_entrepot; 00248 00249 void copy_from(const archive_options_read & ref); 00250 void destroy(); 00251 }; 00252 00253 00257 00259 class archive_options_create : public on_pool 00260 { 00261 public: 00262 // default constructors and destructor. 00263 00264 archive_options_create(); 00265 archive_options_create(const archive_options_create & ref); 00266 const archive_options_create & operator = (const archive_options_create & ref) { destroy(); copy_from(ref); return *this; }; 00267 ~archive_options_create() { destroy(); }; 00268 00270 // set back to default (this is the state just after the object is constructed 00271 // this method is to be used to reuse a given object 00272 00274 void clear(); 00275 00276 00278 // setting methods 00279 00281 void set_reference(archive *ref_arch) { x_ref_arch = ref_arch; }; 00282 00284 void set_selection(const mask & selection); 00285 00287 void set_subtree(const mask & subtree); 00288 00290 void set_allow_over(bool allow_over) { x_allow_over = allow_over; }; 00291 00293 void set_warn_over(bool warn_over) { x_warn_over = warn_over; }; 00294 00301 void set_info_details(bool info_details) { x_info_details = info_details; }; 00302 00307 void set_display_treated(bool display_treated, bool only_dir) { x_display_treated = display_treated; x_display_treated_only_dir = only_dir; }; 00308 00310 void set_display_skipped(bool display_skipped) { x_display_skipped = display_skipped; }; 00311 00313 void set_display_finished(bool display_finished) { x_display_finished = display_finished; }; 00314 00316 void set_pause(const infinint & pause) { x_pause = pause; }; 00317 00319 void set_empty_dir(bool empty_dir) { x_empty_dir = empty_dir; }; 00320 00322 void set_compression(compression compr_algo) { x_compr_algo = compr_algo; }; 00323 00325 void set_compression_level(U_I compression_level) { x_compression_level = compression_level; }; 00326 00328 00332 void set_slicing(const infinint & file_size, const infinint & first_file_size = 0) 00333 { 00334 x_file_size = file_size; 00335 if(first_file_size.is_zero()) 00336 x_first_file_size = file_size; 00337 else 00338 x_first_file_size = first_file_size; 00339 }; 00340 00341 00343 void set_ea_mask(const mask & ea_mask); 00344 00346 void set_execute(const std::string & execute) { x_execute = execute; }; 00347 00349 void set_crypto_algo(crypto_algo crypto) { x_crypto = crypto; }; 00350 00353 void set_crypto_pass(const secu_string & pass) { x_pass = pass; }; 00354 00356 void set_crypto_size(U_32 crypto_size) { x_crypto_size = crypto_size; }; 00357 00364 void set_gnupg_recipients(const std::vector<std::string> & gnupg_recipients) { x_gnupg_recipients = gnupg_recipients; }; 00365 00366 00368 void set_gnupg_signatories(const std::vector<std::string> & gnupg_signatories) { x_gnupg_signatories = gnupg_signatories; }; 00369 00371 void set_compr_mask(const mask & compr_mask); 00372 00374 void set_min_compr_size(const infinint & min_compr_size) { x_min_compr_size = min_compr_size; }; 00375 00377 void set_nodump(bool nodump) { x_nodump = nodump; }; 00378 00381 void set_exclude_by_ea(const std::string & ea_name) 00382 { exclude_by_ea = (ea_name == "" ? "user.libdar_no_backup" : ea_name); }; 00383 00385 void set_what_to_check(cat_inode::comparison_fields what_to_check) { x_what_to_check = what_to_check; }; 00386 00388 void set_hourshift(const infinint & hourshift) { x_hourshift = hourshift; }; 00389 00391 void set_empty(bool empty) { x_empty = empty; }; 00392 00394 00397 void set_alter_atime(bool alter_atime) 00398 { 00399 if(x_furtive_read) 00400 x_old_alter_atime = alter_atime; 00401 else 00402 x_alter_atime = alter_atime; 00403 }; 00404 00406 void set_furtive_read_mode(bool furtive_read) 00407 { 00408 NLS_SWAP_IN; 00409 try 00410 { 00411 00412 #if FURTIVE_READ_MODE_AVAILABLE 00413 x_furtive_read = furtive_read; 00414 if(furtive_read) 00415 { 00416 x_old_alter_atime = x_alter_atime; 00417 x_alter_atime = true; 00418 // this is required to avoid libdar manipulating ctime of inodes 00419 } 00420 else 00421 x_alter_atime = x_old_alter_atime; 00422 #else 00423 if(furtive_read) 00424 throw Ecompilation(gettext("Furtive read mode")); 00425 x_furtive_read = false; 00426 #endif 00427 } 00428 catch(...) 00429 { 00430 NLS_SWAP_OUT; 00431 throw; 00432 } 00433 NLS_SWAP_OUT; 00434 }; 00435 00437 void set_same_fs(bool same_fs) { x_same_fs = same_fs; }; 00438 00440 void set_snapshot(bool snapshot) { x_snapshot = snapshot; }; 00441 00443 void set_cache_directory_tagging(bool cache_directory_tagging) { x_cache_directory_tagging = cache_directory_tagging; }; 00444 00446 void set_fixed_date(const infinint & fixed_date) { x_fixed_date = fixed_date; }; 00447 00449 void set_slice_permission(const std::string & slice_permission) { x_slice_permission = slice_permission; }; 00450 00452 void set_slice_user_ownership(const std::string & slice_user_ownership) { x_slice_user_ownership = slice_user_ownership; }; 00453 00455 void set_slice_group_ownership(const std::string & slice_group_ownership) { x_slice_group_ownership = slice_group_ownership; }; 00456 00458 void set_retry_on_change(const infinint & count_max_per_file, const infinint & global_max_byte_overhead = 0) { x_repeat_count = count_max_per_file; x_repeat_byte = global_max_byte_overhead; }; 00459 00461 void set_sequential_marks(bool sequential) { x_sequential_marks = sequential; }; 00462 00464 void set_sparse_file_min_size(const infinint & size) { x_sparse_file_min_size = size; }; 00465 00467 void set_security_check(bool check) { x_security_check = check; }; 00468 00470 void set_user_comment(const std::string & comment) { x_user_comment = comment; }; 00471 00475 void set_hash_algo(hash_algo hash) { x_hash = hash; }; 00476 00478 void set_slice_min_digits(infinint val) { x_slice_min_digits = val; }; 00479 00481 void set_backup_hook(const std::string & execute, const mask & which_files); 00482 00484 void set_ignore_unknown_inode_type(bool val) { x_ignore_unknown = val; }; 00485 00487 void set_entrepot(const entrepot & entr); 00488 00490 void set_fsa_scope(const fsa_scope & scope) { x_scope = scope; }; 00491 00493 void set_multi_threaded(bool val) { x_multi_threaded = val; }; 00494 00495 00497 // getting methods 00498 00499 archive *get_reference() const { return x_ref_arch; }; 00500 const mask & get_selection() const { if(x_selection == nullptr) throw SRC_BUG; return *x_selection; }; 00501 const mask & get_subtree() const { if(x_subtree == nullptr) throw SRC_BUG; return *x_subtree; }; 00502 bool get_allow_over() const { return x_allow_over; }; 00503 bool get_warn_over() const { return x_warn_over; }; 00504 bool get_info_details() const { return x_info_details; }; 00505 bool get_display_treated() const { return x_display_treated; }; 00506 bool get_display_treated_only_dir() const { return x_display_treated_only_dir; }; 00507 bool get_display_skipped() const { return x_display_skipped; }; 00508 bool get_display_finished() const { return x_display_finished; }; 00509 const infinint & get_pause() const { return x_pause; }; 00510 bool get_empty_dir() const { return x_empty_dir; }; 00511 compression get_compression() const { return x_compr_algo; }; 00512 U_I get_compression_level() const { return x_compression_level; }; 00513 const infinint & get_slice_size() const { return x_file_size; }; 00514 const infinint & get_first_slice_size() const { return x_first_file_size; }; 00515 const mask & get_ea_mask() const { if(x_ea_mask == nullptr) throw SRC_BUG; return *x_ea_mask; }; 00516 const std::string & get_execute() const { return x_execute; }; 00517 crypto_algo get_crypto_algo() const { return x_crypto; }; 00518 const secu_string & get_crypto_pass() const { return x_pass; }; 00519 U_32 get_crypto_size() const { return x_crypto_size; }; 00520 const std::vector<std::string> & get_gnupg_recipients() const { return x_gnupg_recipients; }; 00521 const std::vector<std::string> & get_gnupg_signatories() const { return x_gnupg_signatories; }; 00522 const mask & get_compr_mask() const { if(x_compr_mask == nullptr) throw SRC_BUG; return *x_compr_mask; }; 00523 const infinint & get_min_compr_size() const { return x_min_compr_size; }; 00524 bool get_nodump() const { return x_nodump; }; 00525 const std::string & get_exclude_by_ea() const { return exclude_by_ea; }; 00526 cat_inode::comparison_fields get_comparison_fields() const { return x_what_to_check; }; 00527 const infinint & get_hourshift() const { return x_hourshift; }; 00528 bool get_empty() const { return x_empty; }; 00529 bool get_alter_atime() const { return x_alter_atime; }; 00530 bool get_furtive_read_mode() const { return x_furtive_read; }; 00531 bool get_same_fs() const { return x_same_fs; }; 00532 bool get_snapshot() const { return x_snapshot; }; 00533 bool get_cache_directory_tagging() const { return x_cache_directory_tagging; }; 00534 const infinint & get_fixed_date() const { return x_fixed_date; }; 00535 const std::string & get_slice_permission() const { return x_slice_permission; }; 00536 const std::string & get_slice_user_ownership() const { return x_slice_user_ownership; }; 00537 const std::string & get_slice_group_ownership() const { return x_slice_group_ownership; }; 00538 const infinint & get_repeat_count() const { return x_repeat_count; }; 00539 const infinint & get_repeat_byte() const { return x_repeat_byte; }; 00540 bool get_sequential_marks() const { return x_sequential_marks; }; 00541 infinint get_sparse_file_min_size() const { return x_sparse_file_min_size; }; 00542 bool get_security_check() const { return x_security_check; }; 00543 const std::string & get_user_comment() const { return x_user_comment; }; 00544 hash_algo get_hash_algo() const { return x_hash; }; 00545 infinint get_slice_min_digits() const { return x_slice_min_digits; }; 00546 const std::string & get_backup_hook_file_execute() const { return x_backup_hook_file_execute; }; 00547 const mask & get_backup_hook_file_mask() const { return *x_backup_hook_file_mask; }; 00548 bool get_ignore_unknown_inode_type() const { return x_ignore_unknown; }; 00549 const entrepot & get_entrepot() const { if(x_entrepot == nullptr) throw SRC_BUG; return *x_entrepot; }; 00550 const fsa_scope & get_fsa_scope() const { return x_scope; }; 00551 bool get_multi_threaded() const { return x_multi_threaded; }; 00552 00553 private: 00554 archive *x_ref_arch; //< just contains the address of an existing object, no local copy of object is done here 00555 mask * x_selection; //< points to a local copy of mask (must be allocated / releases by the archive_option_create object) 00556 mask * x_subtree; //< points to a local copy of mask (must be allocated / releases by the archive_option_create objects) 00557 bool x_allow_over; 00558 bool x_warn_over; 00559 bool x_info_details; 00560 bool x_display_treated; 00561 bool x_display_treated_only_dir; 00562 bool x_display_skipped; 00563 bool x_display_finished; 00564 infinint x_pause; 00565 bool x_empty_dir; 00566 compression x_compr_algo; 00567 U_I x_compression_level; 00568 infinint x_file_size; 00569 infinint x_first_file_size; 00570 mask * x_ea_mask; //< points to a local copy of mask (must be allocated / releases by the archive_option_create objects) 00571 std::string x_execute; 00572 crypto_algo x_crypto; 00573 secu_string x_pass; 00574 U_32 x_crypto_size; 00575 std::vector<std::string> x_gnupg_recipients; 00576 std::vector<std::string> x_gnupg_signatories; 00577 mask * x_compr_mask; //< points to a local copy of mask (must be allocated / releases by the archive_option_create objects) 00578 infinint x_min_compr_size; 00579 bool x_nodump; 00580 std::string exclude_by_ea; 00581 cat_inode::comparison_fields x_what_to_check; 00582 infinint x_hourshift; 00583 bool x_empty; 00584 bool x_alter_atime; 00585 bool x_old_alter_atime; //< used to backup origina alter_atime value when activating furtive read mode 00586 bool x_furtive_read; 00587 bool x_same_fs; 00588 bool x_snapshot; 00589 bool x_cache_directory_tagging; 00590 infinint x_fixed_date; 00591 std::string x_slice_permission; 00592 std::string x_slice_user_ownership; 00593 std::string x_slice_group_ownership; 00594 infinint x_repeat_count; 00595 infinint x_repeat_byte; 00596 bool x_sequential_marks; 00597 infinint x_sparse_file_min_size; 00598 bool x_security_check; 00599 std::string x_user_comment; 00600 hash_algo x_hash; 00601 infinint x_slice_min_digits; 00602 mask * x_backup_hook_file_mask; 00603 std::string x_backup_hook_file_execute; 00604 bool x_ignore_unknown; 00605 entrepot *x_entrepot; 00606 fsa_scope x_scope; 00607 bool x_multi_threaded; 00608 00609 void destroy(); 00610 void copy_from(const archive_options_create & ref); 00611 void destroy_mask(mask * & ptr); 00612 void clean_mask(mask * & ptr); 00613 void check_mask(const mask & m); 00614 }; 00615 00616 00617 00618 00619 00620 00624 00626 class archive_options_isolate : public on_pool 00627 { 00628 public: 00629 archive_options_isolate() { x_entrepot = nullptr; clear(); }; 00630 archive_options_isolate(const archive_options_isolate & ref) { x_entrepot = nullptr; copy_from(ref); }; 00631 const archive_options_isolate & operator = (const archive_options_isolate & ref) { destroy(); copy_from(ref); return *this; }; 00632 ~archive_options_isolate() { destroy(); }; 00633 00634 00635 void clear(); 00636 00638 // setting methods 00639 00641 void set_allow_over(bool allow_over) { x_allow_over = allow_over; }; 00642 00644 void set_warn_over(bool warn_over) { x_warn_over = warn_over; }; 00645 00647 void set_info_details(bool info_details) { x_info_details = info_details; }; 00648 00650 void set_pause(const infinint & pause) { x_pause = pause; }; 00651 00653 void set_compression(compression algo) { x_algo = algo; }; 00654 00656 void set_compression_level(U_I compression_level) { x_compression_level = compression_level; }; 00657 00659 00663 void set_slicing(const infinint & file_size, const infinint & first_file_size = 0) 00664 { 00665 x_file_size = file_size; 00666 if(first_file_size.is_zero()) 00667 x_first_file_size = file_size; 00668 else 00669 x_first_file_size = first_file_size; 00670 }; 00671 00673 void set_execute(const std::string & execute) { x_execute = execute; }; 00674 00676 void set_crypto_algo(crypto_algo crypto) { x_crypto = crypto; }; 00677 00679 void set_crypto_pass(const secu_string & pass) { x_pass = pass; }; 00680 00682 void set_crypto_size(U_32 crypto_size) { x_crypto_size = crypto_size; }; 00683 00686 void set_gnupg_recipients(const std::vector<std::string> & gnupg_recipients) { x_gnupg_recipients = gnupg_recipients; }; 00687 00689 void set_gnupg_signatories(const std::vector<std::string> & gnupg_signatories) { x_gnupg_signatories = gnupg_signatories; }; 00690 00692 void set_empty(bool empty) { x_empty = empty; }; 00693 00695 void set_slice_permission(const std::string & slice_permission) { x_slice_permission = slice_permission; }; 00696 00698 void set_slice_user_ownership(const std::string & slice_user_ownership) { x_slice_user_ownership = slice_user_ownership; }; 00699 00701 void set_slice_group_ownership(const std::string & slice_group_ownership) { x_slice_group_ownership = slice_group_ownership; }; 00702 00704 void set_user_comment(const std::string & comment) { x_user_comment = comment; }; 00705 00707 void set_hash_algo(hash_algo hash) { x_hash = hash; }; 00708 00710 void set_slice_min_digits(infinint val) { x_slice_min_digits = val; }; 00711 00713 void set_sequential_marks(bool sequential) { x_sequential_marks = sequential; }; 00714 00716 void set_entrepot(const entrepot & entr); 00717 00719 void set_multi_threaded(bool val) { x_multi_threaded = val; }; 00720 00721 00723 // getting methods 00724 00725 bool get_allow_over() const { return x_allow_over; }; 00726 bool get_warn_over() const { return x_warn_over; }; 00727 bool get_info_details() const { return x_info_details; }; 00728 const infinint & get_pause() const { return x_pause; }; 00729 compression get_compression() const { return x_algo; }; 00730 U_I get_compression_level() const { return x_compression_level; }; 00731 const infinint & get_slice_size() const { return x_file_size; }; 00732 const infinint & get_first_slice_size() const { return x_first_file_size; }; 00733 const std::string & get_execute() const { return x_execute; }; 00734 crypto_algo get_crypto_algo() const { return x_crypto; }; 00735 const secu_string & get_crypto_pass() const { return x_pass; }; 00736 U_32 get_crypto_size() const { return x_crypto_size; }; 00737 const std::vector<std::string> & get_gnupg_recipients() const { return x_gnupg_recipients; }; 00738 const std::vector<std::string> & get_gnupg_signatories() const { return x_gnupg_signatories; }; 00739 bool get_empty() const { return x_empty; }; 00740 const std::string & get_slice_permission() const { return x_slice_permission; }; 00741 const std::string & get_slice_user_ownership() const { return x_slice_user_ownership; }; 00742 const std::string & get_slice_group_ownership() const { return x_slice_group_ownership; }; 00743 const std::string & get_user_comment() const { return x_user_comment; }; 00744 hash_algo get_hash_algo() const { return x_hash; }; 00745 infinint get_slice_min_digits() const { return x_slice_min_digits; }; 00746 bool get_sequential_marks() const { return x_sequential_marks; }; 00747 const entrepot & get_entrepot() const { if(x_entrepot == nullptr) throw SRC_BUG; return *x_entrepot; }; 00748 bool get_multi_threaded() const { return x_multi_threaded; }; 00749 00750 00751 private: 00752 bool x_allow_over; 00753 bool x_warn_over; 00754 bool x_info_details; 00755 infinint x_pause; 00756 compression x_algo; 00757 U_I x_compression_level; 00758 infinint x_file_size; 00759 infinint x_first_file_size; 00760 std::string x_execute; 00761 crypto_algo x_crypto; 00762 secu_string x_pass; 00763 U_32 x_crypto_size; 00764 std::vector<std::string> x_gnupg_recipients; 00765 std::vector<std::string> x_gnupg_signatories; 00766 bool x_empty; 00767 std::string x_slice_permission; 00768 std::string x_slice_user_ownership; 00769 std::string x_slice_group_ownership; 00770 std::string x_user_comment; 00771 hash_algo x_hash; 00772 infinint x_slice_min_digits; 00773 bool x_sequential_marks; 00774 entrepot *x_entrepot; 00775 bool x_multi_threaded; 00776 00777 void copy_from(const archive_options_isolate & ref); 00778 void destroy(); 00779 }; 00780 00781 00782 00786 00788 class archive_options_merge : public on_pool 00789 { 00790 public: 00791 00792 archive_options_merge() { x_selection = x_subtree = x_ea_mask = x_compr_mask = nullptr; x_overwrite = nullptr; x_entrepot = nullptr; clear(); }; 00793 archive_options_merge(const archive_options_merge & ref) { copy_from(ref); }; 00794 const archive_options_merge & operator = (const archive_options_merge & ref) { destroy(); copy_from(ref); return *this; }; 00795 ~archive_options_merge() { destroy(); }; 00796 00797 void clear(); 00798 00800 // setting methods 00801 00802 void set_auxilliary_ref(archive *ref) { x_ref = ref; }; 00803 00805 void set_selection(const mask & selection); 00806 00808 void set_subtree(const mask & subtree); 00809 00811 void set_allow_over(bool allow_over) { x_allow_over = allow_over; }; 00812 00814 void set_warn_over(bool warn_over) { x_warn_over = warn_over; }; 00815 00817 void set_overwriting_rules(const crit_action & overwrite); 00818 00825 void set_info_details(bool info_details) { x_info_details = info_details; }; 00826 00831 void set_display_treated(bool display_treated, bool only_dir) { x_display_treated = display_treated; x_display_treated_only_dir = only_dir; }; 00832 00834 void set_display_skipped(bool display_skipped) { x_display_skipped = display_skipped; }; 00835 00837 void set_pause(const infinint & pause) { x_pause = pause; }; 00838 00840 void set_empty_dir(bool empty_dir) { x_empty_dir = empty_dir; }; 00841 00843 void set_compression(compression compr_algo) { x_compr_algo = compr_algo; }; 00844 00846 void set_compression_level(U_I compression_level) { x_compression_level = compression_level; }; 00847 00849 00853 void set_slicing(const infinint & file_size, const infinint & first_file_size = 0) 00854 { 00855 x_file_size = file_size; 00856 if(first_file_size.is_zero()) 00857 x_first_file_size = file_size; 00858 else 00859 x_first_file_size = first_file_size; 00860 }; 00861 00863 void set_ea_mask(const mask & ea_mask); 00864 00866 void set_execute(const std::string & execute) { x_execute = execute; }; 00867 00869 void set_crypto_algo(crypto_algo crypto) { x_crypto = crypto; }; 00870 00873 void set_crypto_pass(const secu_string & pass) { x_pass = pass; }; 00874 00876 void set_crypto_size(U_32 crypto_size) { x_crypto_size = crypto_size; }; 00877 00880 void set_gnupg_recipients(const std::vector<std::string> & gnupg_recipients) { x_gnupg_recipients = gnupg_recipients; }; 00881 00883 void set_gnupg_signatories(const std::vector<std::string> & gnupg_signatories) { x_gnupg_signatories = gnupg_signatories; }; 00884 00886 void set_compr_mask(const mask & compr_mask); 00887 00889 void set_min_compr_size(const infinint & min_compr_size) { x_min_compr_size = min_compr_size; }; 00890 00892 void set_empty(bool empty) { x_empty = empty; }; 00893 00895 void set_keep_compressed(bool keep_compressed) { x_keep_compressed = keep_compressed; }; 00896 00898 void set_slice_permission(const std::string & slice_permission) { x_slice_permission = slice_permission; }; 00899 00901 void set_slice_user_ownership(const std::string & slice_user_ownership) { x_slice_user_ownership = slice_user_ownership; }; 00902 00904 void set_slice_group_ownership(const std::string & slice_group_ownership) { x_slice_group_ownership = slice_group_ownership; }; 00905 00907 void set_decremental_mode(bool mode) { x_decremental = mode; }; 00908 00910 void set_sequential_marks(bool sequential) { x_sequential_marks = sequential; }; 00911 00913 void set_sparse_file_min_size(const infinint & size) { x_sparse_file_min_size = size; }; 00914 00916 void set_user_comment(const std::string & comment) { x_user_comment = comment; }; 00917 00919 void set_hash_algo(hash_algo hash) { x_hash = hash; }; 00920 00922 void set_slice_min_digits(infinint val) { x_slice_min_digits = val; }; 00923 00925 void set_entrepot(const entrepot & entr); 00926 00928 void set_fsa_scope(const fsa_scope & scope) { x_scope = scope; }; 00929 00931 void set_multi_threaded(bool val) { x_multi_threaded = val; }; 00932 00933 00935 // getting methods 00936 00937 archive * get_auxilliary_ref() const { return x_ref; }; 00938 const mask & get_selection() const { if(x_selection == nullptr) throw SRC_BUG; return *x_selection; }; 00939 const mask & get_subtree() const { if(x_subtree == nullptr) throw SRC_BUG; return *x_subtree; }; 00940 bool get_allow_over() const { return x_allow_over; }; 00941 bool get_warn_over() const { return x_warn_over; }; 00942 const crit_action & get_overwriting_rules() const { if(x_overwrite == nullptr) throw SRC_BUG; return *x_overwrite; }; 00943 bool get_info_details() const { return x_info_details; }; 00944 bool get_display_treated() const { return x_display_treated; }; 00945 bool get_display_treated_only_dir() const { return x_display_treated_only_dir; }; 00946 bool get_display_skipped() const { return x_display_skipped; }; 00947 const infinint & get_pause() const { return x_pause; }; 00948 bool get_empty_dir() const { return x_empty_dir; }; 00949 compression get_compression() const { return x_compr_algo; }; 00950 U_I get_compression_level() const { return x_compression_level; }; 00951 const infinint & get_slice_size() const { return x_file_size; }; 00952 const infinint & get_first_slice_size() const { return x_first_file_size; }; 00953 const mask & get_ea_mask() const { if(x_ea_mask == nullptr) throw SRC_BUG; return *x_ea_mask; }; 00954 const std::string & get_execute() const { return x_execute; }; 00955 crypto_algo get_crypto_algo() const { return x_crypto; }; 00956 const secu_string & get_crypto_pass() const { return x_pass; }; 00957 U_32 get_crypto_size() const { return x_crypto_size; }; 00958 const std::vector<std::string> & get_gnupg_recipients() const { return x_gnupg_recipients; }; 00959 const std::vector<std::string> & get_gnupg_signatories() const { return x_gnupg_signatories; }; 00960 const mask & get_compr_mask() const { if(x_compr_mask == nullptr) throw SRC_BUG; return *x_compr_mask; }; 00961 const infinint & get_min_compr_size() const { return x_min_compr_size; }; 00962 bool get_empty() const { return x_empty; }; 00963 bool get_keep_compressed() const { return x_keep_compressed; }; 00964 const std::string & get_slice_permission() const { return x_slice_permission; }; 00965 const std::string & get_slice_user_ownership() const { return x_slice_user_ownership; }; 00966 const std::string & get_slice_group_ownership() const { return x_slice_group_ownership; }; 00967 bool get_decremental_mode() const { return x_decremental; }; 00968 bool get_sequential_marks() const { return x_sequential_marks; }; 00969 infinint get_sparse_file_min_size() const { return x_sparse_file_min_size; }; 00970 const std::string & get_user_comment() const { return x_user_comment; }; 00971 hash_algo get_hash_algo() const { return x_hash; }; 00972 infinint get_slice_min_digits() const { return x_slice_min_digits; }; 00973 const entrepot & get_entrepot() const { if(x_entrepot == nullptr) throw SRC_BUG; return *x_entrepot; }; 00974 const fsa_scope & get_fsa_scope() const { return x_scope; }; 00975 bool get_multi_threaded() const { return x_multi_threaded; }; 00976 00977 private: 00978 archive * x_ref; //< points to an external existing object, must never be deleted by "this" 00979 mask * x_selection; 00980 mask * x_subtree; 00981 bool x_allow_over; 00982 bool x_warn_over; 00983 crit_action * x_overwrite; 00984 bool x_info_details; 00985 bool x_display_treated; 00986 bool x_display_treated_only_dir; 00987 bool x_display_skipped; 00988 infinint x_pause; 00989 bool x_empty_dir; 00990 compression x_compr_algo; 00991 U_I x_compression_level; 00992 infinint x_file_size; 00993 infinint x_first_file_size; 00994 mask * x_ea_mask; 00995 std::string x_execute; 00996 crypto_algo x_crypto; 00997 secu_string x_pass; 00998 U_32 x_crypto_size; 00999 std::vector<std::string> x_gnupg_recipients; 01000 std::vector<std::string> x_gnupg_signatories; 01001 mask * x_compr_mask; 01002 infinint x_min_compr_size; 01003 bool x_empty; 01004 bool x_keep_compressed; 01005 std::string x_slice_permission; 01006 std::string x_slice_user_ownership; 01007 std::string x_slice_group_ownership; 01008 bool x_decremental; 01009 bool x_sequential_marks; 01010 infinint x_sparse_file_min_size; 01011 std::string x_user_comment; 01012 hash_algo x_hash; 01013 infinint x_slice_min_digits; 01014 entrepot *x_entrepot; 01015 fsa_scope x_scope; 01016 bool x_multi_threaded; 01017 01018 void destroy(); 01019 void copy_from(const archive_options_merge & ref); 01020 }; 01021 01022 01026 01028 class archive_options_extract : public on_pool 01029 { 01030 public: 01031 enum t_dirty { dirty_ignore, dirty_warn, dirty_ok }; 01032 01033 archive_options_extract() { x_selection = x_subtree = x_ea_mask = nullptr; x_overwrite = nullptr; clear(); }; 01034 archive_options_extract(const archive_options_extract & ref) { copy_from(ref); }; 01035 const archive_options_extract & operator = (const archive_options_extract & ref) { destroy(); copy_from(ref); return *this; }; 01036 ~archive_options_extract() { destroy(); }; 01037 01038 void clear(); 01039 01041 // setting methods 01042 01044 void set_selection(const mask & selection); 01045 01047 void set_subtree(const mask & subtree); 01048 01050 void set_warn_over(bool warn_over) { x_warn_over = warn_over; }; 01051 01058 void set_info_details(bool info_details) { x_info_details = info_details; }; 01059 01063 void set_display_treated(bool display_treated, bool only_dir) { x_display_treated = display_treated; x_display_treated_only_dir = only_dir; }; 01064 01066 void set_display_skipped(bool display_skipped) { x_display_skipped = display_skipped; }; 01067 01069 void set_ea_mask(const mask & ea_mask); 01070 01072 void set_flat(bool flat) { x_flat = flat; }; 01073 01075 void set_what_to_check(cat_inode::comparison_fields what_to_check) { x_what_to_check = what_to_check; }; 01076 01078 void set_warn_remove_no_match(bool warn_remove_no_match) { x_warn_remove_no_match = warn_remove_no_match; }; 01079 01081 void set_empty(bool empty) { x_empty = empty; }; 01082 01084 void set_empty_dir(bool empty_dir) { x_empty_dir = empty_dir; }; 01085 01087 01090 void set_dirty_behavior(bool ignore, bool warn) { x_dirty = ignore ? dirty_ignore : (warn ? dirty_warn : dirty_ok); }; 01091 01093 void set_dirty_behavior(t_dirty val) { x_dirty = val; }; 01094 01096 void set_overwriting_rules(const crit_action & over); 01097 01099 01101 void set_only_deleted(bool val) { x_only_deleted = val; }; 01102 01103 01105 01107 void set_ignore_deleted(bool val) { x_ignore_deleted = val; }; 01108 01110 void set_fsa_scope(const fsa_scope & scope) { x_scope = scope; }; 01111 01112 01114 // getting methods 01115 01116 const mask & get_selection() const { if(x_selection == nullptr) throw SRC_BUG; return *x_selection; }; 01117 const mask & get_subtree() const { if(x_subtree == nullptr) throw SRC_BUG; return *x_subtree; }; 01118 bool get_warn_over() const { return x_warn_over; }; 01119 bool get_info_details() const { return x_info_details; }; 01120 bool get_display_treated() const { return x_display_treated; }; 01121 bool get_display_treated_only_dir() const { return x_display_treated_only_dir; }; 01122 bool get_display_skipped() const { return x_display_skipped; }; 01123 const mask & get_ea_mask() const { if(x_ea_mask == nullptr) throw SRC_BUG; return *x_ea_mask; }; 01124 bool get_flat() const { return x_flat; }; 01125 cat_inode::comparison_fields get_what_to_check() const { return x_what_to_check; }; 01126 bool get_warn_remove_no_match() const { return x_warn_remove_no_match; }; 01127 bool get_empty() const { return x_empty; }; 01128 bool get_empty_dir() const { return x_empty_dir; }; 01129 t_dirty get_dirty_behavior() const { return x_dirty; } 01130 const crit_action & get_overwriting_rules() const { if(x_overwrite == nullptr) throw SRC_BUG; return *x_overwrite; }; 01131 bool get_only_deleted() const { return x_only_deleted; }; 01132 bool get_ignore_deleted() const { return x_ignore_deleted; }; 01133 const fsa_scope & get_fsa_scope() const { return x_scope; }; 01134 01135 private: 01136 mask * x_selection; 01137 mask * x_subtree; 01138 bool x_warn_over; 01139 bool x_info_details; 01140 bool x_display_treated; 01141 bool x_display_treated_only_dir; 01142 bool x_display_skipped; 01143 mask * x_ea_mask; 01144 bool x_flat; 01145 cat_inode::comparison_fields x_what_to_check; 01146 bool x_warn_remove_no_match; 01147 bool x_empty; 01148 bool x_empty_dir; 01149 t_dirty x_dirty; 01150 crit_action *x_overwrite; 01151 bool x_only_deleted; 01152 bool x_ignore_deleted; 01153 fsa_scope x_scope; 01154 01155 void destroy(); 01156 void copy_from(const archive_options_extract & ref); 01157 }; 01158 01159 01160 01161 01165 01167 class archive_options_listing : public on_pool 01168 { 01169 public: 01170 archive_options_listing() { x_selection = x_subtree = nullptr; x_slicing_first = x_slicing_others = nullptr; clear(); }; 01171 archive_options_listing(const archive_options_listing & ref) { copy_from(ref); }; 01172 const archive_options_listing & operator = (const archive_options_listing & ref) { destroy(); copy_from(ref); return *this; }; 01173 ~archive_options_listing() { destroy(); }; 01174 01175 void clear(); 01176 01178 01179 enum listformat 01180 { 01181 normal, //< the tar-like listing (this is the default) 01182 tree, //< the original dar's tree listing (for those that like forest) 01183 xml, //< the xml catalogue output 01184 slicing //< the slicing output (give info about where files are located) 01185 }; 01186 01188 // setting methods 01189 01190 void set_info_details(bool info_details) { x_info_details = info_details; }; 01191 void set_list_mode(listformat list_mode) { x_list_mode = list_mode; }; 01192 void set_selection(const mask & selection); 01193 void set_subtree(const mask & subtree); 01194 void set_filter_unsaved(bool filter_unsaved) { x_filter_unsaved = filter_unsaved; }; 01195 void set_display_ea(bool display_ea) { x_display_ea = display_ea; }; 01196 void set_user_slicing(const infinint & slicing_first, const infinint & slicing_others); 01197 01199 // getting methods 01200 01201 bool get_info_details() const { return x_info_details; }; 01202 listformat get_list_mode() const { return x_list_mode; }; 01203 const mask & get_selection() const; 01204 const mask & get_subtree() const; 01205 bool get_filter_unsaved() const { return x_filter_unsaved; }; 01206 bool get_display_ea() const { return x_display_ea; }; 01207 bool get_user_slicing(infinint & slicing_first, infinint & slicing_others) const; 01208 01209 private: 01210 bool x_info_details; 01211 listformat x_list_mode; 01212 mask * x_selection; 01213 mask * x_subtree; 01214 bool x_filter_unsaved; 01215 bool x_display_ea; 01216 infinint *x_slicing_first; 01217 infinint *x_slicing_others; 01218 01219 void destroy(); 01220 void copy_from(const archive_options_listing & ref); 01221 }; 01222 01223 01227 01228 01229 class archive_options_diff : public on_pool 01230 { 01231 public: 01232 archive_options_diff() { x_selection = x_subtree = x_ea_mask = nullptr; clear(); }; 01233 archive_options_diff(const archive_options_diff & ref) { copy_from(ref); }; 01234 const archive_options_diff & operator = (const archive_options_diff & ref) { destroy(); copy_from(ref); return *this; }; 01235 ~archive_options_diff() { destroy(); }; 01236 01237 void clear(); 01238 01240 // setting methods 01241 01243 void set_selection(const mask & selection); 01244 01246 void set_subtree(const mask & subtree); 01247 01254 void set_info_details(bool info_details) { x_info_details = info_details; }; 01255 01259 void set_display_treated(bool display_treated, bool only_dir) { x_display_treated = display_treated; x_display_treated_only_dir = only_dir; }; 01260 01262 void set_display_skipped(bool display_skipped) { x_display_skipped = display_skipped; }; 01263 01265 void set_ea_mask(const mask & ea_mask); 01266 01268 void set_what_to_check(cat_inode::comparison_fields what_to_check) { x_what_to_check = what_to_check; }; 01269 01271 01274 void set_alter_atime(bool alter_atime) 01275 { 01276 if(x_furtive_read) 01277 x_old_alter_atime = alter_atime; 01278 else 01279 x_alter_atime = alter_atime; 01280 }; 01281 01283 void set_furtive_read_mode(bool furtive_read); 01284 01286 void set_hourshift(const infinint & hourshift) { x_hourshift = hourshift; }; 01287 01289 void set_compare_symlink_date(bool compare_symlink_date) { x_compare_symlink_date = compare_symlink_date; }; 01290 01292 void set_fsa_scope(const fsa_scope & scope) { x_scope = scope; }; 01293 01294 01296 // getting methods 01297 01298 const mask & get_selection() const { if(x_selection == nullptr) throw SRC_BUG; return *x_selection; }; 01299 const mask & get_subtree() const { if(x_subtree == nullptr) throw SRC_BUG; return *x_subtree; }; 01300 bool get_info_details() const { return x_info_details; }; 01301 bool get_display_treated() const { return x_display_treated; }; 01302 bool get_display_treated_only_dir() const { return x_display_treated_only_dir; }; 01303 bool get_display_skipped() const { return x_display_skipped; }; 01304 const mask & get_ea_mask() const { if(x_ea_mask == nullptr) throw SRC_BUG; return *x_ea_mask; }; 01305 cat_inode::comparison_fields get_what_to_check() const { return x_what_to_check; }; 01306 bool get_alter_atime() const { return x_alter_atime; }; 01307 bool get_furtive_read_mode() const { return x_furtive_read; }; 01308 const infinint & get_hourshift() const { return x_hourshift; }; 01309 bool get_compare_symlink_date() const { return x_compare_symlink_date; }; 01310 const fsa_scope & get_fsa_scope() const { return x_scope; }; 01311 01312 private: 01313 mask * x_selection; 01314 mask * x_subtree; 01315 bool x_info_details; 01316 bool x_display_treated; 01317 bool x_display_treated_only_dir; 01318 bool x_display_skipped; 01319 mask * x_ea_mask; 01320 cat_inode::comparison_fields x_what_to_check; 01321 bool x_alter_atime; 01322 bool x_old_alter_atime; 01323 bool x_furtive_read; 01324 infinint x_hourshift; 01325 bool x_compare_symlink_date; 01326 fsa_scope x_scope; 01327 01328 void destroy(); 01329 void copy_from(const archive_options_diff & ref); 01330 }; 01331 01332 01333 01334 01338 01340 class archive_options_test : public on_pool 01341 { 01342 public: 01343 archive_options_test() { x_selection = x_subtree = nullptr; clear(); }; 01344 archive_options_test(const archive_options_test & ref) { copy_from(ref); }; 01345 const archive_options_test & operator = (const archive_options_test & ref) { destroy(); copy_from(ref); return *this; }; 01346 ~archive_options_test() { destroy(); }; 01347 01348 void clear(); 01349 01351 // setting methods 01352 01354 void set_selection(const mask & selection); 01355 01357 void set_subtree(const mask & subtree); 01358 01365 void set_info_details(bool info_details) { x_info_details = info_details; }; 01366 01368 void set_display_skipped(bool display_skipped) { x_display_skipped = display_skipped; }; 01369 01373 void set_display_treated(bool display_treated, bool only_dir) { x_display_treated = display_treated; x_display_treated_only_dir = only_dir; }; 01374 01376 void set_empty(bool empty) { x_empty = empty; }; 01377 01378 01380 // getting methods 01381 01382 const mask & get_selection() const { if(x_selection == nullptr) throw SRC_BUG; return *x_selection; }; 01383 const mask & get_subtree() const { if(x_subtree == nullptr) throw SRC_BUG; return *x_subtree; }; 01384 bool get_info_details() const { return x_info_details; }; 01385 bool get_display_treated() const { return x_display_treated; }; 01386 bool get_display_treated_only_dir() const { return x_display_treated_only_dir; }; 01387 bool get_display_skipped() const { return x_display_skipped; }; 01388 bool get_empty() const { return x_empty; }; 01389 01390 private: 01391 mask * x_selection; 01392 mask * x_subtree; 01393 bool x_info_details; 01394 bool x_display_treated; 01395 bool x_display_treated_only_dir; 01396 bool x_display_skipped; 01397 bool x_empty; 01398 01399 void destroy(); 01400 void copy_from(const archive_options_test & ref); 01401 }; 01402 01404 01405 } // end of namespace 01406 01407 #endif