Index: /gsdl/trunk/src/recpt/userdb.cpp
===================================================================
--- /gsdl/trunk/src/recpt/userdb.cpp	(revision 15585)
+++ /gsdl/trunk/src/recpt/userdb.cpp	(revision 15586)
@@ -26,4 +26,5 @@
 #include "gsdlconf.h"
 #include "userdb.h"
+#include "gdbmclass.h"
 #include "gsdltimes.h"
 #include "fileutil.h"
@@ -78,12 +79,13 @@
 {
   storeduserdbfilename = userdbfilename;
-  activated = (!userdb.opendatabase(storeduserdbfilename, GDBM_READER, 1000, true)) ? false : true;
+  userdb = new gdbmclass();
+  activated = (!userdb->opendatabase(storeduserdbfilename, DB_READER, 1000, true)) ? false : true;
   if (activated == false) 
     {
-      activated = (!userdb.opendatabase(storeduserdbfilename, GDBM_WRCREAT, 1000, true)) ? false : true;
+      activated = (!userdb->opendatabase(storeduserdbfilename, DB_WRITER_CREATE, 1000, true)) ? false : true;
       if (activated == true)
         {
-          userdb.closedatabase();
-          activated = (!userdb.opendatabase(storeduserdbfilename, GDBM_READER, 1000, true)) ? false : true;
+          userdb->closedatabase();
+          activated = (!userdb->opendatabase(storeduserdbfilename, DB_READER, 1000, true)) ? false : true;
         }
     }
@@ -92,14 +94,11 @@
 }
 
-userdbclass::userdbclass(const gdbmclass &external_userdb)
-{
-  userdb = external_userdb;
-  activated = true;
-  external_db = true;
-}
-
 userdbclass::~userdbclass()
 {
-  if (external_db == false) { userdb.closedatabase();}
+  if (external_db == false)
+  {
+    userdb->closedatabase();
+    delete userdb;
+  }
 }
 
@@ -207,5 +206,5 @@
       infodbclass info;
       // See if we can get the user's infomration
-      if (userdb.getinfo (username, info)) 
+      if (userdb->getinfo (username, info)) 
         {
           userinfo.username = info["username"];
@@ -248,9 +247,9 @@
       info["groups"] = userinfo.groups;
       info["comment"] = userinfo.comment;
-      userdb.closedatabase();
-      userdb.opendatabase(storeduserdbfilename, GDBM_WRCREAT, 1000, true);
-      int result = (userdb.setinfo (username, info)) ? ERRNO_SUCCEED : ERRNO_GDBMACTIONFILED;
-      userdb.closedatabase();
-      userdb.opendatabase(storeduserdbfilename, GDBM_READER, 1000, true);         
+      userdb->closedatabase();
+      userdb->opendatabase(storeduserdbfilename, DB_WRITER_CREATE, 1000, true);
+      int result = (userdb->setinfo (username, info)) ? ERRNO_SUCCEED : ERRNO_DBACTIONFAILED;
+      userdb->closedatabase();
+      userdb->opendatabase(storeduserdbfilename, DB_READER, 1000, true);         
       return  result;
     }
@@ -278,5 +277,5 @@
     {
       infodbclass info;
-      if (userdb.getinfo (userinfo.username, info)) 
+      if (userdb->getinfo (userinfo.username, info)) 
         {
           // There is an existing username already
@@ -297,5 +296,5 @@
     {
       infodbclass info;
-      if (userdb.getinfo (userinfo.username, info)) 
+      if (userdb->getinfo (userinfo.username, info)) 
         {
           return set_user_info(userinfo.username, userinfo);
@@ -315,9 +314,9 @@
   if (activated == true)
     {
-      userdb.closedatabase();
-      userdb.opendatabase(storeduserdbfilename, GDBM_WRCREAT, 1000, true);
-      userdb.deletekey (username);
-      userdb.closedatabase();
-      userdb.opendatabase(storeduserdbfilename, GDBM_READER, 1000, true);
+      userdb->closedatabase();
+      userdb->opendatabase(storeduserdbfilename, DB_WRITER_CREATE, 1000, true);
+      userdb->deletekey (username);
+      userdb->closedatabase();
+      userdb->opendatabase(storeduserdbfilename, DB_READER, 1000, true);
       return ERRNO_SUCCEED;
     }
@@ -333,5 +332,5 @@
     {
       userinfo_array.erase(userinfo_array.begin(), userinfo_array.end());
-      text_t user = userdb.getfirstkey();
+      text_t user = userdb->getfirstkey();
       while (!user.empty()) {
         userinfo_t one_userinfo;
@@ -339,5 +338,5 @@
         if (returned != ERRNO_SUCCEED) return returned;
         userinfo_array.push_back(one_userinfo);
-        user = userdb.getnextkey(user);
+        user = userdb->getnextkey(user);
       }
       return ERRNO_SUCCEED;
@@ -355,8 +354,8 @@
       userlist.erase (userlist.begin(), userlist.end());
       
-      text_t user = userdb.getfirstkey ();
+      text_t user = userdb->getfirstkey ();
       while (!user.empty()) {
         userlist.push_back(user);
-        user = userdb.getnextkey (user);
+        user = userdb->getnextkey (user);
       }
       return ERRNO_SUCCEED;
@@ -374,12 +373,13 @@
 {
   storedkeydbfilename = keydbfilename;
-  activated = keydb.opendatabase(storedkeydbfilename, GDBM_READER, 1000, true);
+  keydb = new gdbmclass();
+  activated = keydb->opendatabase(storedkeydbfilename, DB_READER, 1000, true);
   if (activated == false) 
     {
-      activated = keydb.opendatabase(storedkeydbfilename, GDBM_WRCREAT, 1000, true);
+      activated = keydb->opendatabase(storedkeydbfilename, DB_WRITER_CREATE, 1000, true);
       if (activated == true)
         {
-          keydb.closedatabase();
-          activated = keydb.opendatabase(storedkeydbfilename, GDBM_READER, 1000, true);
+          keydb->closedatabase();
+          activated = keydb->opendatabase(storedkeydbfilename, DB_READER, 1000, true);
         }
     }
@@ -387,15 +387,13 @@
 }
 
-keydbclass::keydbclass(const gdbmclass &external_keydb)
-{
-  keydb = external_keydb;
-  activated = true;
-  external_db = true;
-}
-
 keydbclass::~keydbclass()
 {
-  if (external_db == false) { keydb.closedatabase();}
-}
+  if (external_db == false)
+  {
+    keydb->closedatabase();
+    delete keydb;
+  }
+}
+
 // generates a random key for the user, stores it in the database and
 // returns it so that it can be used in page generation
@@ -423,5 +421,5 @@
         // make sure this key is not in the database
         crypt_userkey = userdbclass::crypt_text(userkey);
-        if (keydb.exists (crypt_userkey)) userkey.clear();
+        if (keydb->exists (crypt_userkey)) userkey.clear();
       } while (userkey.empty());
       
@@ -431,12 +429,12 @@
       keydata["time"] = time2text(time(NULL));
       
-      keydb.closedatabase();
-      keydb.opendatabase(storedkeydbfilename, GDBM_WRCREAT, 1000, true);
-      if (!keydb.setinfo (crypt_userkey, keydata)) 
+      keydb->closedatabase();
+      keydb->opendatabase(storedkeydbfilename, DB_WRITER_CREATE, 1000, true);
+      if (!keydb->setinfo (crypt_userkey, keydata)) 
         {
           userkey.clear(); // failed
         }
-      keydb.closedatabase();
-      keydb.opendatabase(storedkeydbfilename, GDBM_READER, 1000, true); 
+      keydb->closedatabase();
+      keydb->opendatabase(storedkeydbfilename, DB_READER, 1000, true); 
       
       return userkey;
@@ -463,5 +461,5 @@
       text_t crypt_key = userdbclass::crypt_text(key);
       infodbclass info;
-      if (keydb.getinfo (crypt_key, info))  {
+      if (keydb->getinfo (crypt_key, info))  {
         if (info["user"] == thisuser.username) {
           time_t keycreation = text2time (info["time"]);
@@ -470,9 +468,9 @@
             // succeeded, update the key's time
             info["time"] = time2text(time(NULL));
-            keydb.closedatabase();
-            keydb.opendatabase(storedkeydbfilename, GDBM_WRCREAT, 1000, true);
-            keydb.setinfo (crypt_key, info);
-            keydb.closedatabase();
-            keydb.opendatabase(storedkeydbfilename, GDBM_READER, 1000, true); 
+            keydb->closedatabase();
+            keydb->opendatabase(storedkeydbfilename, DB_WRITER_CREATE, 1000, true);
+            keydb->setinfo (crypt_key, info);
+            keydb->closedatabase();
+            keydb->opendatabase(storedkeydbfilename, DB_READER, 1000, true); 
             return true;
           }
@@ -492,10 +490,10 @@
       // get a list of keys created more than keydecay seconds agon
       text_tarray oldkeys;
-      text_t key = keydb.getfirstkey ();
+      text_t key = keydb->getfirstkey ();
       infodbclass info;
       time_t timenow = text2time(time2text(time(NULL)));
       time_t keycreation = (time_t)-1;
       while (!key.empty()) {
-        if (keydb.getinfo (key, info))  {
+        if (keydb->getinfo (key, info))  {
           keycreation = text2time (info["time"]);
           if (keycreation != (time_t)-1 && difftime (timenow, keycreation) > keydecay) {
@@ -505,19 +503,19 @@
         }
         
-        key = keydb.getnextkey (key);
+        key = keydb->getnextkey (key);
       }
       
       // delete the old keys
       if (oldkeys.size() > 0) {
-	keydb.closedatabase();
-	keydb.opendatabase(storedkeydbfilename, GDBM_WRCREAT, 1000, true);
+	keydb->closedatabase();
+	keydb->opendatabase(storedkeydbfilename, DB_WRITER_CREATE, 1000, true);
 	text_tarray::iterator keys_here = oldkeys.begin();
 	text_tarray::iterator keys_end = oldkeys.end();
 	while (keys_here != keys_end) {
-	  keydb.deletekey(*keys_here);
+	  keydb->deletekey(*keys_here);
 	  ++keys_here;
 	}
-	keydb.closedatabase();
-	keydb.opendatabase(storedkeydbfilename, GDBM_READER, 1000, true);
+	keydb->closedatabase();
+	keydb->opendatabase(storedkeydbfilename, DB_READER, 1000, true);
       }
     }
Index: /gsdl/trunk/src/recpt/userdb.h
===================================================================
--- /gsdl/trunk/src/recpt/userdb.h	(revision 15585)
+++ /gsdl/trunk/src/recpt/userdb.h	(revision 15586)
@@ -34,8 +34,8 @@
 #define ERRNO_MISSINGPASSWORD  -4
 #define ERRNO_PASSWORDMISMATCH -5
-#define ERRNO_GDBMACTIONFILED  -6
+#define ERRNO_DBACTIONFAILED   -6
 
 
-#include "gdbmclass.h"
+#include "dbclass.h"
 
 // The user information object and it provides basic functions for the information object, such as clear and copy (=) functions;
@@ -61,5 +61,5 @@
  protected:
   // The internal storage for the userdbfilename and the userdb object
-  gdbmclass userdb;
+  dbclass* userdb;
   bool external_db;
   bool activated;
@@ -68,5 +68,4 @@
  public:
   userdbclass (const text_t &userdbfilename);
-  userdbclass (const gdbmclass &external_userdb);
   virtual ~userdbclass();
 
@@ -121,5 +120,5 @@
  protected:
   // The internal storage for the userdbfilename and the userdb object
-  gdbmclass keydb;
+  dbclass* keydb;
   bool external_db;
   bool activated;
@@ -128,5 +127,4 @@
  public:
   keydbclass (const text_t &keydbfilename);
-  keydbclass (const gdbmclass &external_keydb);
   virtual ~keydbclass();
   // functions dealing with databases of temporary keys
