"Fossies" - the Fresh Open Source Software Archive

Member "dbtool-1.9.1/engine.h" (15 May 2015, 2695 Bytes) of package /linux/privat/dbtool-1.9.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "engine.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.9_vs_1.9.1.

    1 /*
    2  * 'dbtool' is a simple but powerful  commandline interface to the
    3  * GNU gdbm system (or, alternatively the Berkeley DB), useful for
    4  * shellscripts which needs a database for data storage.
    5  */
    6 
    7 /*
    8  *
    9  *  This file  is part of the DBTOOL program.
   10  *
   11  *  By  accessing  this software,  DBTOOL, you  are  duly informed
   12  *  of and agree to be  bound  by the  conditions  described below
   13  *  in this notice:
   14  *
   15  *  This software product,  DBTOOL,  is developed by T.v. Dein
   16  *  and  copyrighted  (C)  2001-2015  by  T.v. Dein,  with all
   17  *  rights reserved.
   18  *
   19  *  There  is no charge for DBTOOL software.  You can redistribute
   20  *  it and/or modify it under the terms of the GNU  General Public
   21  *  License, which is incorporated by reference herein.
   22  *
   23  *  DBTOOL is distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS,
   24  *  OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE or that
   25  *  the use of it will not infringe on any third party's intellec-
   26  *  tual property rights.
   27  *
   28  *  You  should  have received a copy of the  GNU  General  Public
   29  *  License  along with DBTOOL.  Copies can also be obtained from:
   30  *
   31  *    http://www.gnu.org/licenses/gpl.txt
   32  *
   33  *  or by writing to:
   34  *
   35  *  Free Software Foundation, Inc.
   36  *  59 Temple Place, Suite 330
   37  *  Boston, MA 02111-1307
   38  *  USA
   39  *
   40  *  Or contact:
   41  *
   42  *   "T.v. Dein" <tlinden@cpan.org>
   43  *
   44  *
   45  */
   46 
   47 
   48 #ifndef ENGINE_H
   49 #define ENGINE_H
   50 
   51 /* the default initial blocksize for the gdbm database, see gdbm(3) */
   52 #define BLOCKSIZE 1024
   53 
   54 /* the default filemode for file creation, will be xored to the users umask */
   55 #define FILEMODE  0644
   56 
   57 
   58 #include <string>
   59 
   60 extern "C" {
   61 #include <stdio.h>
   62 #include <stdlib.h>
   63 #include <pcre.h>
   64 }
   65 
   66 #ifdef HAVE_BERKELEY
   67 
   68 #ifndef NO_SYSTEM_INCLUDES
   69 #include <sys/types.h>
   70 #include <stdlib.h>
   71 #include <string.h>
   72 #ifndef _MSC_VER
   73 #include <unistd.h>
   74 #endif
   75 #endif
   76 
   77 #include "platform.h"
   78 #include DB_CXX_HEADER
   79 
   80 #else
   81 
   82 # include <gdbm.h>
   83 
   84 #endif
   85 
   86 #include "config.h"
   87 #include "cipher.h"
   88 
   89 extern Config config; /* instanced in ::main() */
   90 extern cipher rijn;   /* instanced in ::main() */
   91 
   92 /*
   93  * The Engine class will do all gdbm related stuff, i.e.
   94  * insert, search, create, remove and so on.
   95  * methods defined in engine.cc
   96  */
   97 class Engine {
   98  private:
   99   void init(); /* init() will be called from every method once */
  100   string encode(const string& data);
  101   string decode(const string& data);
  102 
  103   /*
  104    * the db object has the same name for both backends
  105    */
  106 #ifdef HAVE_BERKELEY
  107   Db *db;
  108 #else
  109   GDBM_FILE db;
  110 #endif
  111 
  112   string pkg;
  113 
  114  public:
  115   Engine() {};
  116   void insert();
  117   void update();
  118   void remove();
  119   void select();
  120   void from_input();
  121   void   dump();
  122   void regexp();
  123 };
  124 
  125 
  126 #endif // ENGINE_H