Disk ARchive: shell_interaction.hpp Source File

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

Loading...
Searching...
No Matches
shell_interaction.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2026 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, see the AUTHOR file
20/*********************************************************************/
21
25
26
27#ifndef SHELL_INTERACTION_HPP
28#define SHELL_INTERACTION_HPP
29
30extern "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
44namespace 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 set_fully_detailed_datetime(bool mode) { full_datetime = mode; };
91
93 bool get_fully_detailed_datetime() const { return full_datetime; };
94
96 void archive_show_contents(const archive & ref, const archive_options_listing_shell & options);
97
99 void database_show_contents(const database & ref);
100
102 void database_show_files(const database & ref, archive_num num, const database_used_options & opt);
103
105 void database_show_version(const database & ref, const path & chem);
106
108 void database_show_statistics(const database &ref);
109
110 protected:
111 // inherited methods from user_interaction class
112
113 virtual void inherited_message(const std::string & message) override;
114 virtual bool inherited_pause(const std::string &message) override;
115 virtual std::string inherited_get_string(const std::string & message, bool echo) override;
116 virtual secu_string inherited_get_secu_string(const std::string & message, bool echo) override;
117
118 private:
119 // data type
120
121 enum mode { m_initial, m_inter, m_noecho };
122
123 // object fields and methods
124
125 S_I input;
126 std::ostream *output;
127 std::ostream *inter;
128 bool beep;
129 termios initial;
130 termios interaction;
131 termios initial_noecho;
132 bool has_terminal;
133 U_I at_once, count;
134
135 // field used by listing_callbacks
136
137 bool archive_listing_sizes_in_bytes;
138 bool archive_listing_display_ea;
139 range all_slices;
140 std::string marge;
141 bool full_datetime;
142
143 void set_term_mod(mode m);
144 void my_message(const std::string & mesg);
145 void xml_listing_attributes(const list_entry & entry);
146
147
148 // class fields and methods
149
150 static const U_I bufsize;
151 static constexpr const char* REMOVE_TAG = "[--- REMOVED ENTRY ----]";
152
153 static void archive_listing_callback_tree(const std::string & the_path,
154 const list_entry & entry,
155 void *context);
156
157 static void archive_listing_callback_tar(const std::string & the_path,
158 const list_entry & entry,
159 void *context);
160
161 static void archive_listing_callback_xml(const std::string & the_path,
162 const list_entry & entry,
163 void *context);
164
165 static void archive_listing_callback_slicing(const std::string & the_path,
166 const list_entry & entry,
167 void *context);
168
169 static void show_files_callback(void *tag,
170 const std::string & filename,
171 bool available_data,
172 bool available_ea);
173
174
175 static void get_version_callback(void *tag,
176 archive_num num,
177 db_etat data_presence,
178 bool has_data_date,
179 datetime data,
180 db_etat ea_presence,
181 bool has_ea_date,
182 datetime ea);
183
184 static void statistics_callback(void *tag,
185 U_I number,
186 const infinint & data_count,
187 const infinint & total_data,
188 const infinint & ea_count,
189 const infinint & total_ea);
190
191 static std::string yes_no(bool val) { return (val ? "yes" : "no"); }
192
193 };
194
196
197} // end of namespace
198
199#endif
archive_options_listing_shell.hpp
this file contains shell_interaction options class for listing
libdar::user_interaction
This is a pure virtual class that is used by libdar when interaction with the user is required.
Definition user_interaction.hpp:58
database.hpp
this file holds the database class definition
libdar::db_etat
db_etat
the status for a founded entry
Definition database_aux.hpp:55
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
user_interaction.hpp
defines the interaction interface between libdar and users.