Loading...
Searching...
No Matches
shell_interaction.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 SHELL_INTERACTION_HPP
#define SHELL_INTERACTION_HPP
extern "C"
{
#if HAVE_TERMIOS_H
#include <termios.h>
#endif
} // end extern "C"
#include "../my_config.h"
#include <iostream>
#include "user_interaction.hpp"
#include "database.hpp"
#include "archive_options_listing_shell.hpp"
namespace libdar
{
class shell_interaction : public user_interaction
{
public:
shell_interaction(std::ostream & out,
std::ostream & interact,
bool silent);
shell_interaction(const shell_interaction & ref);
shell_interaction(shell_interaction && ref) noexcept = delete;
shell_interaction & operator = (const shell_interaction & ref) = delete;
shell_interaction & operator = (shell_interaction && ref) noexcept = delete;
~shell_interaction();
void change_non_interactive_output(std::ostream & out);
void read_char(char & a);
void set_beep(bool mode) { beep = mode; };
void warning_with_more(U_I num) { at_once = num; count = 0; };
void set_fully_detailed_datetime(bool mode) { full_datetime = mode; };
bool get_fully_detailed_datetime() const { return full_datetime; };
void archive_show_contents(const archive & ref, const archive_options_listing_shell & options);
void database_show_contents(const database & ref);
void database_show_files(const database & ref, archive_num num, const database_used_options & opt);
void database_show_version(const database & ref, const path & chem);
void database_show_statistics(const database &ref);
protected:
// inherited methods from user_interaction class
virtual void inherited_message(const std::string & message) override;
virtual bool inherited_pause(const std::string &message) override;
virtual std::string inherited_get_string(const std::string & message, bool echo) override;
virtual secu_string inherited_get_secu_string(const std::string & message, bool echo) override;
private:
// data type
enum mode { m_initial, m_inter, m_noecho };
// object fields and methods
S_I input;
std::ostream *output;
std::ostream *inter;
bool beep;
termios initial;
termios interaction;
termios initial_noecho;
bool has_terminal;
U_I at_once, count;
// field used by listing_callbacks
bool archive_listing_sizes_in_bytes;
bool archive_listing_display_ea;
range all_slices;
std::string marge;
bool full_datetime;
void set_term_mod(mode m);
void my_message(const std::string & mesg);
void xml_listing_attributes(const list_entry & entry);
// class fields and methods
static const U_I bufsize;
static constexpr const char* REMOVE_TAG = "[--- REMOVED ENTRY ----]";
static void archive_listing_callback_tree(const std::string & the_path,
const list_entry & entry,
void *context);
static void archive_listing_callback_tar(const std::string & the_path,
const list_entry & entry,
void *context);
static void archive_listing_callback_xml(const std::string & the_path,
const list_entry & entry,
void *context);
static void archive_listing_callback_slicing(const std::string & the_path,
const list_entry & entry,
void *context);
static void show_files_callback(void *tag,
const std::string & filename,
bool available_data,
bool available_ea);
static void get_version_callback(void *tag,
archive_num num,
db_etat data_presence,
bool has_data_date,
datetime data,
db_etat ea_presence,
bool has_ea_date,
datetime ea);
static void statistics_callback(void *tag,
U_I number,
const infinint & data_count,
const infinint & total_data,
const infinint & ea_count,
const infinint & total_ea);
static std::string yes_no(bool val) { return (val ? "yes" : "no"); }
};
} // end of namespace
#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.