Disk ARchive  2.5.12
Full featured and portable backup and archiving tool
scrambler.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 #ifndef SCRAMBLER_HPP
27 #define SCRAMBLER_HPP
28 
29 #include "../my_config.h"
30 #include <string>
31 #include "infinint.hpp"
32 #include "generic_file.hpp"
33 #include "erreurs.hpp"
34 #include "infinint.hpp"
35 #include "secu_string.hpp"
36 
37 namespace libdar
38 {
39 
42 
43  class scrambler : public generic_file
44  {
45  public:
46  scrambler(const secu_string & pass, generic_file & hidden_side);
47  scrambler(const scrambler & ref) : generic_file(ref) { throw SRC_BUG; };
48  ~scrambler() { if(buffer != nullptr) meta_delete(buffer); };
49 
50  const scrambler & operator = (const scrambler & ref) { throw SRC_BUG; };
51 
52  bool skippable(skippability direction, const infinint & amount) { return ref->skippable(direction, amount); };
53  bool skip(const infinint & pos) { if(ref == nullptr) throw SRC_BUG; return ref->skip(pos); };
54  bool skip_to_eof() { if(ref==nullptr) throw SRC_BUG; return ref->skip_to_eof(); };
55  bool skip_relative(S_I x) { if(ref == nullptr) throw SRC_BUG; return ref->skip_relative(x); };
56  infinint get_position() const { if(ref == nullptr) throw SRC_BUG; return ref->get_position(); };
57 
58  protected:
59  void inherited_read_ahead(const infinint & amount) { ref->read_ahead(amount); };
60  U_I inherited_read(char *a, U_I size);
61  void inherited_write(const char *a, U_I size);
62  void inherited_sync_write() {}; // nothing to do
63  void inherited_flush_read() {}; // nothing to do
64  void inherited_terminate() {}; // nothing to do
65 
66  private:
67  secu_string key;
68  U_I len;
69  generic_file *ref;
70  unsigned char *buffer;
71  U_I buf_size;
72  };
73 
74 } // end of namespace
75 
76 #endif
void inherited_terminate()
destructor-like call, except that it is allowed to throw exceptions
Definition: scrambler.hpp:64
void inherited_read_ahead(const infinint &amount)
Definition: scrambler.hpp:59
U_I inherited_read(char *a, U_I size)
implementation of read() operation
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
virtual void read_ahead(const infinint &amount)
bool skip(const infinint &pos)
Definition: scrambler.hpp:53
bool skip_relative(S_I x)
skip relatively to the current position
Definition: scrambler.hpp:55
void inherited_write(const char *a, U_I size)
implementation of the write() operation
infinint get_position() const
get the current read/write position
Definition: scrambler.hpp:56
generic_file(gf_mode m)
main constructor
bool skip_to_eof()
skip to the end of file
Definition: scrambler.hpp:54
contains all the excetion class thrown by libdar
switch module to limitint (32 ou 64 bits integers) or infinint
void inherited_sync_write()
write down any pending data
Definition: scrambler.hpp:62
scrambler is a very weak encryption scheme
Definition: scrambler.hpp:43
class secu_string
Definition: secu_string.hpp:57
this is the interface class from which all other data transfer classes inherit
bool skippable(skippability direction, const infinint &amount)
Definition: scrambler.hpp:52
void inherited_flush_read()
Definition: scrambler.hpp:63
the arbitrary large positive integer class
this file contains the definition of secu_string class, a std::string like class but allocated in sec...
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47