| Disk ARchive 2.6.11 Full featured and portable backup and archiving tool

shell_interaction.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2020 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26
27 #ifndef SHELL_INTERACTION_HPP
28 #define SHELL_INTERACTION_HPP
29
30 extern "C"
31 {
32 #if HAVE_TERMIOS_H
33 #include <termios.h>
34 #endif
35 } // end extern "C"
36
37 #include "../my_config.h"
38 #include <iostream>
39
40 #include "user_interaction.hpp"
41 #include "database.hpp"
42 #include "archive_options_listing_shell.hpp"
43
44 namespace libdar
45 {
46
49
50 class shell_interaction : public user_interaction
51 {
52 public:
58 shell_interaction(std::ostream & out,
59 std::ostream & interact,
60 bool silent);
61
63 shell_interaction(const shell_interaction & ref);
64
66 shell_interaction(shell_interaction && ref) noexcept = delete;
67
69 shell_interaction & operator = (const shell_interaction & ref) = delete;
70
72 shell_interaction & operator = (shell_interaction && ref) noexcept = delete;
73
75 ~shell_interaction();
76
77 void change_non_interactive_output(std::ostream & out);
78 void read_char(char & a);
79 void set_beep(bool mode) { beep = mode; };
80
82
87 void warning_with_more(U_I num) { at_once = num; count = 0; };
88
90 void archive_show_contents(const archive & ref, const archive_options_listing_shell & options);
91
93 void database_show_contents(const database & ref);
94
96 void database_show_files(const database & ref, archive_num num, const database_used_options & opt);
97
99 void database_show_version(const database & ref, const path & chem);
100
102 void database_show_statistics(const database &ref);
103
104 protected:
105 // inherited methods from user_interaction class
106
107 virtual void inherited_message(const std::string & message) override;
108 virtual bool inherited_pause(const std::string &message) override;
109 virtual std::string inherited_get_string(const std::string & message, bool echo) override;
110 virtual secu_string inherited_get_secu_string(const std::string & message, bool echo) override;
111
112 private:
113 // data type
114
115 enum mode { m_initial, m_inter, m_noecho };
116
117 // object fields and methods
118
119 S_I input;
120 std::ostream *output;
121 std::ostream *inter;
122 bool beep;
123 termios initial;
124 termios interaction;
125 termios initial_noecho;
126 bool has_terminal;
127 U_I at_once, count;
128
129 // field used by listing_callbacks
130
131 bool archive_listing_sizes_in_bytes;
132 bool archive_listing_display_ea;
133 range all_slices;
134 std::string marge;
135
136 void set_term_mod(mode m);
137 void my_message(const std::string & mesg);
138 void xml_listing_attributes(const list_entry & entry);
139
140
141 // class fields and methods
142
143 static const U_I bufsize;
144 static constexpr const char* REMOVE_TAG = "[--- REMOVED ENTRY ----]";
145
146 static void archive_listing_callback_tree(const std::string & the_path,
147 const list_entry & entry,
148 void *context);
149
150 static void archive_listing_callback_tar(const std::string & the_path,
151 const list_entry & entry,
152 void *context);
153
154 static void archive_listing_callback_xml(const std::string & the_path,
155 const list_entry & entry,
156 void *context);
157
158 static void archive_listing_callback_slicing(const std::string & the_path,
159 const list_entry & entry,
160 void *context);
161
162 static void show_files_callback(void *tag,
163 const std::string & filename,
164 bool available_data,
165 bool available_ea);
166
167
168 static void get_version_callback(void *tag,
169 archive_num num,
170 db_etat data_presence,
171 bool has_data_date,
172 datetime data,
173 db_etat ea_presence,
174 bool has_ea_date,
175 datetime ea);
176
177 static void statistics_callback(void *tag,
178 U_I number,
179 const infinint & data_count,
180 const infinint & total_data,
181 const infinint & ea_count,
182 const infinint & total_ea);
183
184 static std::string yes_no(bool val) { return (val ? "yes" : "no"); }
185
186 };
187
189
190 } // end of namespace
191
192 #endif
archive_options_listing_shell.hpp
this file contains shell_interaction options class for listing
database.hpp
this file holds the database class definition
user_interaction.hpp
defines the interaction interface between libdar and users.
libdar::db_etat
db_etat
the status for a founded entry
Definition: database_aux.hpp:55
libdar::compile_time::ea
bool ea() noexcept
returns whether EA support has been activated at compilation time
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47