Disk ARchive  2.4.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/libdar/scrambler.hpp
00001 /*********************************************************************/
00002 // dar - disk archive - a backup/restoration program
00003 // Copyright (C) 2002-2052 Denis Corbin
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 // to contact the author : http://dar.linux.free.fr/email.html
00020 /*********************************************************************/
00021 // $Id$
00022 //
00023 /*********************************************************************/
00024 
00028 
00029 #ifndef SCRAMBLER_HPP
00030 #define SCRAMBLER_HPP
00031 
00032 #include "../my_config.h"
00033 #include <string>
00034 #include "infinint.hpp"
00035 #include "generic_file.hpp"
00036 #include "erreurs.hpp"
00037 #include "infinint.hpp"
00038 #include "secu_string.hpp"
00039 
00040 namespace libdar
00041 {
00042 
00045 
00046     class scrambler : public generic_file
00047     {
00048     public:
00049         scrambler(const secu_string & pass, generic_file & hidden_side);
00050         scrambler(const scrambler & ref) : generic_file(ref) { throw SRC_BUG; };
00051         ~scrambler() { if(buffer != NULL) delete [] buffer; };
00052 
00053         const scrambler & operator = (const scrambler & ref) { throw SRC_BUG; };
00054 
00055         bool skip(const infinint & pos) { if(ref == NULL) throw SRC_BUG; return ref->skip(pos); };
00056         bool skip_to_eof() { if(ref==NULL) throw SRC_BUG; return ref->skip_to_eof(); };
00057         bool skip_relative(S_I x) { if(ref == NULL) throw SRC_BUG; return ref->skip_relative(x); };
00058         infinint get_position() { if(ref == NULL) throw SRC_BUG; return ref->get_position(); };
00059 
00060 #ifdef LIBDAR_SPECIAL_ALLOC
00061         USE_SPECIAL_ALLOC(scrambler);
00062 #endif
00063     protected:
00064         U_I inherited_read(char *a, U_I size);
00065         void inherited_write(const char *a, U_I size);
00066         void inherited_sync_write() {}; // nothing to do
00067         void inherited_terminate() {};  // nothing to do
00068 
00069     private:
00070         std::string key;
00071         U_32 len;
00072         generic_file *ref;
00073         unsigned char *buffer;
00074         U_I buf_size;
00075     };
00076 
00077 } // end of namespace
00078 
00079 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines