Disk ARchive  2.5.15
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-2052 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 
42 using namespace std;
43 using namespace libdar;
44 
47 
48 class shell_interaction : public user_interaction_callback
49 {
50 public:
58  shell_interaction(ostream *out, ostream *interact, bool silent);
59 
61  shell_interaction(const shell_interaction & ref);
62 
64  ~shell_interaction();
65 
66  void change_non_interactive_output(ostream *out);
67  void read_char(char & a);
68  void set_beep(bool mode) { beep = mode; };
69 
70 
72  virtual user_interaction *clone() const { user_interaction *ret = new (get_pool()) shell_interaction(*this); if(ret == nullptr) throw Ememory("shell_interaction::clone"); return ret; };
73 
74 private:
75  // data type
76 
77  enum mode { m_initial, m_inter, m_noecho };
78 
79  // object fields and methods
80 
81  S_I input; //< filedescriptor to read from the user's answers
82  ostream *output; //< holds the destination for non interactive messages
83  ostream *inter; //< holds the destination for interactive messages
84  bool beep; //< whether to issue bell char before displaying a new interactive message
85  termios initial; //< controlling terminal configuration when the object has been created
86  termios interaction; //< controlling terminal configuration to use when requiring user interaction
87  termios initial_noecho; //< controlling terminal configuration to use when noecho has been requested
88  bool has_terminal; //< true if a terminal could be found
89 
90  void set_term_mod(mode m);
91 
92  // class fields and methods
93 
94  static const U_I bufsize;
95 
96  static bool interaction_pause(const string &message, void *context);
97  static void interaction_warning(const string & message, void *context);
98  static string interaction_string(const string & message, bool echo, void *context);
99  static secu_string interaction_secu_string(const string & message, bool echo, void *context);
100 };
101 
103 
104 #endif
STL namespace.
This is a pure virtual class that is used by libdar when interaction with the user is required...
full implemented class for user_interaction based on callback functions.
defines the interaction between libdar and the user.Three classes are defined
exception used when memory has been exhausted
Definition: erreurs.hpp:111
class secu_string
Definition: secu_string.hpp:57
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47