Loading...
Searching...
No Matches
command_line.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2026 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 COMMAND_LINE_HPP
#define COMMAND_LINE_HPP
#include "../my_config.h"
#include <string>
#include <deque>
#include <vector>
#include "libdar.hpp"
using namespace std;
using namespace libdar;
enum operation { noop, extract, create, diff, test, listing, isolate, merging, version_or_help, repairing };
// noop stands for no-operation. get_args() never returns such value,
// it is just necessary within the command_line module
enum dirty_behavior { dirtyb_ignore, dirtyb_warn, dirtyb_ok };
struct ent_params
{
string ent_proto;
string ent_login;
secu_string ent_pass;
string ent_host;
string ent_port;
U_I network_retry;
bool auth_from_file;
void clear()
{ ent_proto.clear(); ent_login.clear(); ent_pass.clear();
ent_host.clear(); ent_port.clear(); network_retry = 3;
auth_from_file = false; };
};
struct line_param
{
operation op;
path * fs_root;
path * sauv_root;
string filename;
path * ref_root;
string * ref_filename;
infinint file_size;
infinint first_file_size;
mask * selection;
mask * subtree;
bool allow_over;
bool warn_over;
bool info_details;
bool display_treated;
bool display_treated_only_dir;
bool display_skipped;
bool display_finished;
bool display_masks;
compression algo;
U_I compression_level;
U_I compression_block_size;
infinint pause;
bool beep;
bool empty_dir;
mask * ea_mask;
string input_pipe;
string output_pipe;
comparison_fields what_to_check;
string execute;
string execute_ref;
secu_string pass;
vector<string> signatories;
bool blind_signatures;
secu_string pass_ref;
mask * compress_mask;
bool flat;
infinint min_compr_size;
bool nodump;
bool exclude_by_ea;
string ea_name_for_exclusion;
infinint hourshift;
bool warn_remove_no_match;
bool filter_unsaved;
bool empty;
bool alter_atime;
bool same_fs;
deque<string> same_fs_incl;
deque<string> same_fs_excl;
bool snapshot;
bool cache_directory_tagging;
U_32 crypto_size;
U_32 crypto_size_ref;
archive_options_listing_shell::listformat list_mode;
path * aux_root;
string * aux_filename;
secu_string aux_pass;
string aux_execute;
U_32 aux_crypto_size;
bool keep_compressed;
infinint fixed_date;
bool quiet;
bool quiet_crypto;
const crit_action * overwrite;
string slice_perm;
string slice_user;
string slice_group;
infinint repeat_count;
infinint repeat_byte;
bool decremental;
bool furtive_read_mode;
bool lax;
bool use_sequential_marks;
bool sequential_read;
infinint sparse_file_min_size;
dirty_behavior dirty;
bool security_check;
string user_comment;
hash_algo hash;
infinint num_digits;
infinint ref_num_digits;
infinint aux_num_digits;
bool only_deleted;
bool not_deleted;
mask * backup_hook_mask;
string backup_hook_execute;
bool list_ea;
bool ignore_unknown_inode;
bool no_compare_symlink_date;
fsa_scope scope;
U_I multi_threaded_crypto;
U_I multi_threaded_compress;
bool delta_sig;
mask *delta_mask;
bool delta_diff;
infinint delta_sig_min_size;
ent_params remote;
ent_params ref_remote;
ent_params aux_remote;
bool remote_verbose;
bool sizes_in_bytes;
bool header_only;
bool zeroing_neg_dates;
string ignored_as_symlink;
modified_data_detection modet;
infinint iteration_count;
hash_algo kdf_hash;
delta_sig_block_size delta_sig_len;
bool unix_sockets;
bool in_place;
bool never_resave_uncompr;
bool force_first_slice;
bool fully_detailed_dates;
bool isolation_repair;
bool extract_from_database;
// constructor for line_param
line_param()
{
fs_root = nullptr;
sauv_root = nullptr;
ref_root = nullptr;
selection = nullptr;
subtree = nullptr;
ref_filename = nullptr;
ea_mask = nullptr;
compress_mask = nullptr;
aux_root = nullptr;
aux_filename = nullptr;
overwrite = nullptr;
backup_hook_mask = nullptr;
};
// destructor for line_param
~line_param()
{
if(fs_root != nullptr)
delete fs_root;
if(sauv_root != nullptr)
delete sauv_root;
if(ref_root != nullptr)
delete ref_root;
if(selection != nullptr)
delete selection;
if(subtree != nullptr)
delete subtree;
if(ref_filename != nullptr)
delete ref_filename;
if(ea_mask != nullptr)
delete ea_mask;
if(compress_mask != nullptr)
delete compress_mask;
if(aux_root != nullptr)
delete aux_root;
if(aux_filename != nullptr)
delete aux_filename;
if(overwrite != nullptr)
delete overwrite;
if(backup_hook_mask != nullptr)
delete backup_hook_mask;
};
};
extern bool get_args(shared_ptr<user_interaction> & dialog,
const char *home,
const deque<string> & dar_dcf_path,
const deque<string> & dar_duc_path,
S_I argc,
char * const argv[],
line_param & param);
#if HAVE_GETOPT_LONG
const struct option *get_long_opt();
#endif
const char *get_short_opt();
#endif
libdar::archive_options_listing_shell::listformat
listformat
defines the way archive listing is done:
Definition archive_options_listing_shell.hpp:62
libdar::crit_action
the global action for overwriting
Definition crit_action.hpp:81
libdar::infinint
the arbitrary large positive integer class
Definition real_infinint.hpp:62
libdar::mask
the generic class, parent of all masks
Definition mask.hpp:62
libdar::path
the class path is here to manipulate paths in the Unix notation: using'/'
Definition path.hpp:51
libdar::secu_string
class secu_string
Definition secu_string.hpp:54
libdar::modified_data_detection
modified_data_detection
how to detect data has changed when some fields
Definition archive_aux.hpp:44
libdar::comparison_fields
comparison_fields
how to consider file change during comparison and incremental backup
Definition archive_aux.hpp:53
libdar::hash_algo
hash_algo
hashing algorithm available
Definition archive_aux.hpp:63
libdar::fsa_scope
std::set< fsa_family > fsa_scope
set of fsa families
Definition fsa_family.hpp:70
libdar::compression
compression
the different compression algorithm available
Definition compression.hpp:46
get_args
bool get_args(shared_ptr< user_interaction > &dialog, const char *home, const deque< string > &dar_dcf_path, const deque< string > &dar_duc_path, S_I argc, char *const argv[], line_param &param)
main routine to extract parameters from command-line and included files
libdar.hpp
the main file of the libdar API definitions
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47
ent_params
entrepot relative parameters
Definition command_line.hpp:49
ent_params::ent_login
string ent_login
entrepot login
Definition command_line.hpp:51
ent_params::ent_pass
secu_string ent_pass
entrepot password
Definition command_line.hpp:52
ent_params::ent_host
string ent_host
entrepot hostname
Definition command_line.hpp:53
ent_params::ent_port
string ent_port
entrepot port
Definition command_line.hpp:54
ent_params::auth_from_file
bool auth_from_file
whether ~/.netrc and ~/.ssh files should be considered for credentials
Definition command_line.hpp:56
ent_params::network_retry
U_I network_retry
libcurl entrepot network retry time
Definition command_line.hpp:55
ent_params::ent_proto
string ent_proto
entrepot protocol
Definition command_line.hpp:50
libdar::delta_sig_block_size
defines how to calculate delta signature block size based of file size to delta sign
Definition delta_sig_block_size.hpp:50
line_param
all parameters retreived from command-line
Definition command_line.hpp:66
line_param::security_check
bool security_check
whether to signal possible root-kit presence
Definition command_line.hpp:142
line_param::warn_remove_no_match
bool warn_remove_no_match
whether to warn file about to be removed during a restoration, when they to no match the expected typ...
Definition command_line.hpp:108
line_param::pass_ref
secu_string pass_ref
if not an empty string, use the provided encryption scheme to read the archive of reference
Definition command_line.hpp:100
line_param::filter_unsaved
bool filter_unsaved
whether to not list files that are not saved in the archive
Definition command_line.hpp:109
line_param::quiet
bool quiet
whether to display final summary for the operation
Definition command_line.hpp:127
line_param::compression_level
U_I compression_level
compression level to use when generating an archive
Definition command_line.hpp:86
line_param::isolation_repair
bool isolation_repair
whether to try isolate content of a truncated archive
Definition command_line.hpp:179
line_param::exclude_by_ea
bool exclude_by_ea
whether inode have to be check against a given EA before backup
Definition command_line.hpp:105
line_param::nodump
bool nodump
whether to ignore files having the "nodump" flag set when performing a backup
Definition command_line.hpp:104
line_param::filename
string filename
basename of the archive to operate on
Definition command_line.hpp:70
line_param::display_skipped
bool display_skipped
whether to display skipped files
Definition command_line.hpp:82
line_param::remote_verbose
bool remote_verbose
whether to have verbose output from libcurl
Definition command_line.hpp:165
line_param::beep
bool beep
whether to ring the terminal upon user interaction request
Definition command_line.hpp:89
line_param::subtree
mask * subtree
filter files for the operation based on path+filename
Definition command_line.hpp:76
line_param::dirty
dirty_behavior dirty
what to do when comes the time to restore a file that is flagged as dirty
Definition command_line.hpp:141
line_param::header_only
bool header_only
whether we just display the header of archives to be read
Definition command_line.hpp:167
line_param::ref_filename
string * ref_filename
basename of the archive of reference (nullptr => no archive of reference)
Definition command_line.hpp:72
line_param::ignore_unknown_inode
bool ignore_unknown_inode
whether to ignore unknown inode types
Definition command_line.hpp:153
line_param::fixed_date
infinint fixed_date
the data for the snapshot backup
Definition command_line.hpp:126
line_param::never_resave_uncompr
bool never_resave_uncompr
never resave uncompressed when compression ratio is bad
Definition command_line.hpp:176
line_param::delta_diff
bool delta_diff
whether to save binary diff or whole file's data during a differential backup
Definition command_line.hpp:160
line_param::in_place
bool in_place
in-place restoration or comparison
Definition command_line.hpp:175
line_param::aux_execute
string aux_execute
command to be run between the slice of the auxiliary archive of reference
Definition command_line.hpp:123
line_param::blind_signatures
bool blind_signatures
whether to ignore signature check failures
Definition command_line.hpp:99
line_param::extract_from_database
bool extract_from_database
whether to extract from a dar_manager database or from a dar archive
Definition command_line.hpp:180
line_param::flat
bool flat
whether to ignore directory structure when restoring data
Definition command_line.hpp:102
line_param::crypto_size
U_32 crypto_size
block size by which to cypher data
Definition command_line.hpp:117
line_param::display_treated_only_dir
bool display_treated_only_dir
whether to show treated files's current working directory
Definition command_line.hpp:81
line_param::delta_sig_min_size
infinint delta_sig_min_size
size below which to never calculate delta signatures
Definition command_line.hpp:161
line_param::force_first_slice
bool force_first_slice
whether to read the first instead of the last slice when a isolated catalogue is given in complement
Definition command_line.hpp:177
line_param::multi_threaded_compress
U_I multi_threaded_compress
number of compress worker threads (requires libthreadar and per block compression)
Definition command_line.hpp:157
line_param::sequential_read
bool sequential_read
whether to follow escape sequential marks to achieve a sequential reading of the archive
Definition command_line.hpp:139
line_param::num_digits
infinint num_digits
minimum number of decimal for the slice number
Definition command_line.hpp:145
line_param::info_details
bool info_details
whether to show processing messages
Definition command_line.hpp:79
line_param::input_pipe
string input_pipe
if not an empty string, name of the pipe through which to read data from dar_slave
Definition command_line.hpp:92
line_param::fs_root
path * fs_root
filesystem root
Definition command_line.hpp:68
line_param::hash
hash_algo hash
whether to produce a hash file, and which algoritm to use for that hash
Definition command_line.hpp:144
line_param::decremental
bool decremental
whether to produce a decremental backup (when merging)
Definition command_line.hpp:135
line_param::remote
ent_params remote
remote entrepot coordinates
Definition command_line.hpp:162
line_param::op
operation op
which operation to perform
Definition command_line.hpp:67
line_param::scope
fsa_scope scope
FSA scope to consider for the operation.
Definition command_line.hpp:155
line_param::what_to_check
comparison_fields what_to_check
what fields to take into account when comparing/restoring files,
Definition command_line.hpp:94
line_param::aux_remote
ent_params aux_remote
remote entrepot coordinates for the auxiliary archive
Definition command_line.hpp:164
line_param::aux_filename
string * aux_filename
basename of the auxiliary archive if reference (nullptr => no auxiliary of reference)
Definition command_line.hpp:121
line_param::pass
secu_string pass
if not an empty string, encrypt the archive with the given algo:pass string
Definition command_line.hpp:97
line_param::repeat_byte
infinint repeat_byte
archive total maximum amount of byte to waste re-saving changing files
Definition command_line.hpp:134
line_param::unix_sockets
bool unix_sockets
whether to restore unix-sockets
Definition command_line.hpp:174
line_param::alter_atime
bool alter_atime
whether to reset the atime of file read during backup to their original value (resetting atime does m...
Definition command_line.hpp:111
line_param::slice_group
string slice_group
group to set when creating a slice
Definition command_line.hpp:132
line_param::keep_compressed
bool keep_compressed
when merging, whether to not uncompress/re-compress data in the process
Definition command_line.hpp:125
line_param::display_masks
bool display_masks
whether to display masks value
Definition command_line.hpp:84
line_param::kdf_hash
hash_algo kdf_hash
hash algo used for key derivation function
Definition command_line.hpp:172
line_param::compress_mask
mask * compress_mask
which file to compress
Definition command_line.hpp:101
line_param::delta_sig
bool delta_sig
whether to calculate rsync signature of files
Definition command_line.hpp:158
line_param::not_deleted
bool not_deleted
whether to ignore deleted files
Definition command_line.hpp:149
line_param::display_finished
bool display_finished
whether to display summary (space/compression ratio) for each completed directory
Definition command_line.hpp:83
line_param::execute
string execute
if not an empty string, the command to execute between slices
Definition command_line.hpp:95
line_param::empty_dir
bool empty_dir
whether to store skipped directories as empty, whether to avoid restoring directory where no data is ...
Definition command_line.hpp:90
line_param::use_sequential_marks
bool use_sequential_marks
whether to add escape sequential marks in the archive
Definition command_line.hpp:138
line_param::quiet_crypto
bool quiet_crypto
do not display message about impossibility do detect wrong key when reading ciphered backup
Definition command_line.hpp:128
line_param::zeroing_neg_dates
bool zeroing_neg_dates
whether to automatically zeroing negative dates while reading inode from filesystem
Definition command_line.hpp:168
line_param::fully_detailed_dates
bool fully_detailed_dates
whether to show subsecond value of dates
Definition command_line.hpp:178
line_param::delta_mask
mask * delta_mask
which file to calculate delta sig when not using the default mask
Definition command_line.hpp:159
line_param::aux_root
path * aux_root
where is the auxiliary archive of reference [used for merging but also when creating an archive,...
Definition command_line.hpp:120
line_param::cache_directory_tagging
bool cache_directory_tagging
whether to ignore directory contents where a the cache directory tagging files is found
Definition command_line.hpp:116
line_param::overwrite
const crit_action * overwrite
the overwriting policy
Definition command_line.hpp:129
line_param::output_pipe
string output_pipe
if not an empty string, name of the pipe through which to write orders to dar_slave
Definition command_line.hpp:93
line_param::empty
bool empty
whether to do a dry-run execution
Definition command_line.hpp:110
line_param::algo
compression algo
compression algorithm to use when generating an archive
Definition command_line.hpp:85
line_param::min_compr_size
infinint min_compr_size
below which size to never try compressing files
Definition command_line.hpp:103
line_param::slice_perm
string slice_perm
permission to set when creating a slice
Definition command_line.hpp:130
line_param::ea_name_for_exclusion
string ea_name_for_exclusion
EA name to use for file exclusion, or empty string for the default EA name.
Definition command_line.hpp:106
line_param::slice_user
string slice_user
user to set when creating a slice
Definition command_line.hpp:131
line_param::list_mode
archive_options_listing_shell::listformat list_mode
type of listing to follow
Definition command_line.hpp:119
line_param::ref_num_digits
infinint ref_num_digits
minimum number of decimal for the slice number of the archive of reference
Definition command_line.hpp:146
line_param::same_fs_incl
deque< string > same_fs_incl
optional list of path to filesystems to stick to (for backup operation)
Definition command_line.hpp:113
line_param::ref_root
path * ref_root
where is the archive of reference
Definition command_line.hpp:71
line_param::aux_pass
secu_string aux_pass
crypto to use for the auxiliary archive
Definition command_line.hpp:122
line_param::only_deleted
bool only_deleted
whether to only consider deleted files
Definition command_line.hpp:148
line_param::repeat_count
infinint repeat_count
number of time to try saving a file if it changes at the time it is read for backup
Definition command_line.hpp:133
line_param::sparse_file_min_size
infinint sparse_file_min_size
minimum size of a zeroed byte sequence to be considered as a hole and stored this way in the archive
Definition command_line.hpp:140
line_param::warn_over
bool warn_over
whether to warn before overwriting files or slices
Definition command_line.hpp:78
line_param::list_ea
bool list_ea
whether to list Extended Attribute of files
Definition command_line.hpp:152
line_param::backup_hook_execute
string backup_hook_execute
which command to execute as backup hook
Definition command_line.hpp:151
line_param::modet
modified_data_detection modet
how to detect that a file has changed since the archive of reference was done
Definition command_line.hpp:170
line_param::no_compare_symlink_date
bool no_compare_symlink_date
whether to report difference in dates of symlinks while diffing an archive with filesystem
Definition command_line.hpp:154
line_param::multi_threaded_crypto
U_I multi_threaded_crypto
number of crypto worker threads (requires libthreadar)
Definition command_line.hpp:156
line_param::snapshot
bool snapshot
whether to perform a snapshot backup
Definition command_line.hpp:115
line_param::allow_over
bool allow_over
whether to allow slice overwriting
Definition command_line.hpp:77
line_param::first_file_size
infinint first_file_size
sice of the first slice to create
Definition command_line.hpp:74
line_param::sizes_in_bytes
bool sizes_in_bytes
whether to display sizes in bytes of to the larges unit (Mo, Go, To,...)
Definition command_line.hpp:166
line_param::backup_hook_mask
mask * backup_hook_mask
which file have to considered for backup hook
Definition command_line.hpp:150
line_param::aux_num_digits
infinint aux_num_digits
minimum number of decimal for the slice number of the auxiliary archive of reference
Definition command_line.hpp:147
line_param::delta_sig_len
delta_sig_block_size delta_sig_len
block len to used for delta signature computation
Definition command_line.hpp:173
line_param::sauv_root
path * sauv_root
where is the archive to operate on (create, read, etc.)
Definition command_line.hpp:69
line_param::compression_block_size
U_I compression_block_size
compression block size (0 for legacy compression method)
Definition command_line.hpp:87
line_param::pause
infinint pause
whether to pause between slices
Definition command_line.hpp:88
line_param::aux_crypto_size
U_32 aux_crypto_size
block size by which to cypher/uncypher data to/from the auxiliary archive of reference
Definition command_line.hpp:124
line_param::iteration_count
infinint iteration_count
iteration count used when creating/isolating/merging an encrypted archive (key derivation)
Definition command_line.hpp:171
line_param::lax
bool lax
whether to activate the last chance recovery mode (use with caution!)
Definition command_line.hpp:137
line_param::user_comment
string user_comment
user comment to add to the archive
Definition command_line.hpp:143
line_param::ignored_as_symlink
string ignored_as_symlink
column separated list of absolute paths of links to follow rather to record as such
Definition command_line.hpp:169
line_param::hourshift
infinint hourshift
consider equal two dates that have an integer hour of difference equal or less than hourshift
Definition command_line.hpp:107
line_param::ea_mask
mask * ea_mask
which EA to work on
Definition command_line.hpp:91
line_param::file_size
infinint file_size
size of the slices to create (except the first)
Definition command_line.hpp:73
line_param::same_fs_excl
deque< string > same_fs_excl
optional list of path to filesystems to not consider (for backup operation)
Definition command_line.hpp:114
line_param::ref_remote
ent_params ref_remote
remote entrepot coordinates for archive of reference
Definition command_line.hpp:163
line_param::execute_ref
string execute_ref
if not an empty string, the command to execute between slices of the archive of reference
Definition command_line.hpp:96
line_param::crypto_size_ref
U_32 crypto_size_ref
block size by which to uncypher data from the archive of reference
Definition command_line.hpp:118
line_param::same_fs
bool same_fs
whether to stick to a same filesystem
Definition command_line.hpp:112
line_param::selection
mask * selection
filter files for the operation based on filename only
Definition command_line.hpp:75
line_param::signatories
vector< string > signatories
list of email's key to use to sign the archive
Definition command_line.hpp:98
line_param::display_treated
bool display_treated
whether to show treated files
Definition command_line.hpp:80
line_param::furtive_read_mode
bool furtive_read_mode
whether to use the furtive read mode
Definition command_line.hpp:136