Index: /gsdl/trunk/common-src/src/lib/gdbmclass.cpp
===================================================================
--- /gsdl/trunk/common-src/src/lib/gdbmclass.cpp	(revision 18049)
+++ /gsdl/trunk/common-src/src/lib/gdbmclass.cpp	(revision 18050)
@@ -69,9 +69,204 @@
   }
 
-  if (gdbm_mode == GDBM_READER) {
+  if (gdbm_mode == GDBM_READER)
+  {
+    if (!file_exists(filename))
+    {
+      generate_from_txtgz(filename);
+    }
+  }
+
+  char *namebuffer = filename.getcstr();
+  do {
+#ifdef __WIN32__
+    gdbmfile = gdbm_open (namebuffer, block_size, gdbm_mode, 00664, NULL, (need_filelock) ? 1 : 0);
+#else
+    gdbmfile = gdbm_open (namebuffer, block_size, gdbm_mode, 00664, NULL);
+#endif
+    --num_retrys;
+  } while (num_retrys>0 && gdbmfile==NULL &&
+	   (gdbm_errno==GDBM_CANT_BE_READER || gdbm_errno==GDBM_CANT_BE_WRITER));
+  delete []namebuffer;
+  
+  if (gdbmfile == NULL && logout != NULL) {
+    outconvertclass text_t2ascii;
+    (*logout) << text_t2ascii << "database open failed on: " << filename << "\n";
+  }
+
+  return (gdbmfile != NULL);
+}
+
+
+void gdbmclass::closedatabase ()
+{
+  if (gdbmfile == NULL) return;
+  
+  gdbm_close (gdbmfile);
+  gdbmfile = NULL;
+  openfile.clear();
+}
+
+
+void gdbmclass::deletekey (const text_t &key)
+{
+  if (gdbmfile == NULL) return;
+
+  // get a utf-8 encoded c string of the unicode key
+  datum key_data;
+  key_data.dptr = (to_utf8(key)).getcstr();
+  if (key_data.dptr == NULL) return;
+  key_data.dsize = strlen (key_data.dptr);
+
+  // delete the key
+  gdbm_delete (gdbmfile, key_data);
+
+  // free up the key memory
+  delete []key_data.dptr;
+}
+
+
+// returns file extension string
+text_t gdbmclass::getfileextension ()
+{
+  if (littleEndian()) return ".ldb";
+  return ".bdb";
+}
+
+
+// returns true on success
+bool gdbmclass::getkeydata (const text_t& key, text_t &data)
+{
+  datum key_data;
+  datum return_data;
+
+  if (gdbmfile == NULL) return false;
+  
+  // get a utf-8 encoded c string of the unicode key
+  key_data.dptr = (to_utf8(key)).getcstr();
+  if (key_data.dptr == NULL) {
+    if (logout != NULL) (*logout) << "gdbmclass: out of memory" << endl;
+    return false;
+  }
+  key_data.dsize = strlen (key_data.dptr);
+  
+  // fetch the result
+  return_data = gdbm_fetch (gdbmfile, key_data);
+  delete []key_data.dptr;
+  
+  if (return_data.dptr == NULL) return false;
+
+  data.setcarr (return_data.dptr, return_data.dsize);
+  free (return_data.dptr);
+  data = to_uni(data);  // convert to unicode
+
+  return true;
+}
+
+
+// returns array of keys
+text_tarray gdbmclass::getkeys ()
+{
+  text_tarray keys;
+
+  text_t key = getfirstkey();
+  while (!key.empty())
+  {
+    keys.push_back(key);
+    key = getnextkey(key);
+  }
+
+  return keys;
+}
+
+
+// returns true on success
+bool gdbmclass::setkeydata (const text_t &key, const text_t &data)
+{
+  if (gdbmfile == NULL) return false;
+  
+  // store the value
+  datum key_data;
+  datum data_data;
+
+  // get a utf-8 encoded c string of the unicode key
+  key_data.dptr = (to_utf8(key)).getcstr();
+  if (key_data.dptr == NULL) {
+    if (logout != NULL) (*logout) << "gdbmclass: out of memory" << endl;
+    return false;
+  }
+  key_data.dsize = strlen (key_data.dptr);
+
+  data_data.dptr = (to_utf8(data)).getcstr();
+  if (data_data.dptr == NULL) {
+    if (logout != NULL) (*logout) << "gdbmclass: out of memory" << endl;
+    delete []key_data.dptr;
+    return false;
+  }
+  data_data.dsize = strlen (data_data.dptr);
+
+  int ret = gdbm_store (gdbmfile, key_data, data_data, GDBM_REPLACE);
+  delete []key_data.dptr;
+  delete []data_data.dptr;
+
+  return (ret == 0);
+}
+
+
+// ----------------------------------------------------------------------------------------
+//   GDBM-ONLY FUNCTIONS
+// ----------------------------------------------------------------------------------------
+
+// getfirstkey and getnextkey are used for traversing the database
+// no insertions or deletions should be carried out while traversing
+// the database. when there are no keys left to visit in the database
+// an empty string is returned.
+text_t gdbmclass::getfirstkey ()
+{
+  if (gdbmfile == NULL) return g_EmptyText;
+
+  // get the first key
+  datum firstkey_data = gdbm_firstkey (gdbmfile);
+  if (firstkey_data.dptr == NULL) return g_EmptyText;
+
+  // convert it to text_t
+  text_t firstkey;
+  firstkey.setcarr (firstkey_data.dptr, firstkey_data.dsize);
+  free (firstkey_data.dptr);
+  return to_uni(firstkey);  // convert to unicode
+}
+
+
+text_t gdbmclass::getnextkey (const text_t &key)
+{
+  if (gdbmfile == NULL || key.empty()) return g_EmptyText;
+
+  // get a utf-8 encoded c string of the unicode key
+  datum key_data;
+  key_data.dptr = (to_utf8(key)).getcstr();
+  if (key_data.dptr == NULL) return g_EmptyText;
+  key_data.dsize = strlen (key_data.dptr);
+  
+  // get the next key
+  datum nextkey_data = gdbm_nextkey (gdbmfile, key_data);
+  if (nextkey_data.dptr == NULL) {
+    delete []key_data.dptr;
+    return g_EmptyText;
+  }
+
+  // convert it to text_t
+  text_t nextkey;
+  nextkey.setcarr (nextkey_data.dptr, nextkey_data.dsize);
+  free (nextkey_data.dptr);
+  delete []key_data.dptr;
+  return to_uni(nextkey);  // convert to unicode
+}
+
+
+// DEPRECATED -- No longer necessary now that the GDBM library reads both little-endian and big-endian
+void gdbmclass::generate_from_txtgz (text_t filename)
+{
     // Looking to read in the database
     // => check to see if .ldb/.bdb file already there
     // if not (first time) then generate using txt2db
-    if (!file_exists(filename)) {
 
       // need to generate architecture native GDBM file using txt2db
@@ -138,189 +333,3 @@
 	}	
       }
-    }
-  }
-
-  char *namebuffer = filename.getcstr();
-  do {
-#ifdef __WIN32__
-    gdbmfile = gdbm_open (namebuffer, block_size, gdbm_mode, 00664, NULL, (need_filelock) ? 1 : 0);
-#else
-    gdbmfile = gdbm_open (namebuffer, block_size, gdbm_mode, 00664, NULL);
-#endif
-    --num_retrys;
-  } while (num_retrys>0 && gdbmfile==NULL &&
-	   (gdbm_errno==GDBM_CANT_BE_READER || gdbm_errno==GDBM_CANT_BE_WRITER));
-  delete []namebuffer;
-  
-  if (gdbmfile == NULL && logout != NULL) {
-    outconvertclass text_t2ascii;
-    (*logout) << text_t2ascii << "database open failed on: " << filename << "\n";
-  }
-
-  return (gdbmfile != NULL);
-}
-
-
-void gdbmclass::closedatabase ()
-{
-  if (gdbmfile == NULL) return;
-  
-  gdbm_close (gdbmfile);
-  gdbmfile = NULL;
-  openfile.clear();
-}
-
-
-void gdbmclass::deletekey (const text_t &key)
-{
-  if (gdbmfile == NULL) return;
-
-  // get a utf-8 encoded c string of the unicode key
-  datum key_data;
-  key_data.dptr = (to_utf8(key)).getcstr();
-  if (key_data.dptr == NULL) return;
-  key_data.dsize = strlen (key_data.dptr);
-
-  // delete the key
-  gdbm_delete (gdbmfile, key_data);
-
-  // free up the key memory
-  delete []key_data.dptr;
-}
-
-
-// returns file extension string
-text_t gdbmclass::getfileextension ()
-{
-  if (littleEndian()) return ".ldb";
-  return ".bdb";
-}
-
-
-// returns true on success
-bool gdbmclass::getkeydata (const text_t& key, text_t &data)
-{
-  datum key_data;
-  datum return_data;
-
-  if (gdbmfile == NULL) return false;
-  
-  // get a utf-8 encoded c string of the unicode key
-  key_data.dptr = (to_utf8(key)).getcstr();
-  if (key_data.dptr == NULL) {
-    if (logout != NULL) (*logout) << "gdbmclass: out of memory" << endl;
-    return false;
-  }
-  key_data.dsize = strlen (key_data.dptr);
-  
-  // fetch the result
-  return_data = gdbm_fetch (gdbmfile, key_data);
-  delete []key_data.dptr;
-  
-  if (return_data.dptr == NULL) return false;
-
-  data.setcarr (return_data.dptr, return_data.dsize);
-  free (return_data.dptr);
-  data = to_uni(data);  // convert to unicode
-
-  return true;
-}
-
-
-// returns array of keys
-text_tarray gdbmclass::getkeys ()
-{
-  text_tarray keys;
-
-  text_t key = getfirstkey();
-  while (!key.empty())
-  {
-    keys.push_back(key);
-    key = getnextkey(key);
-  }
-
-  return keys;
-}
-
-
-// returns true on success
-bool gdbmclass::setkeydata (const text_t &key, const text_t &data)
-{
-  if (gdbmfile == NULL) return false;
-  
-  // store the value
-  datum key_data;
-  datum data_data;
-
-  // get a utf-8 encoded c string of the unicode key
-  key_data.dptr = (to_utf8(key)).getcstr();
-  if (key_data.dptr == NULL) {
-    if (logout != NULL) (*logout) << "gdbmclass: out of memory" << endl;
-    return false;
-  }
-  key_data.dsize = strlen (key_data.dptr);
-
-  data_data.dptr = (to_utf8(data)).getcstr();
-  if (data_data.dptr == NULL) {
-    if (logout != NULL) (*logout) << "gdbmclass: out of memory" << endl;
-    delete []key_data.dptr;
-    return false;
-  }
-  data_data.dsize = strlen (data_data.dptr);
-
-  int ret = gdbm_store (gdbmfile, key_data, data_data, GDBM_REPLACE);
-  delete []key_data.dptr;
-  delete []data_data.dptr;
-
-  return (ret == 0);
-}
-
-
-// ----------------------------------------------------------------------------------------
-//   GDBM-ONLY FUNCTIONS
-// ----------------------------------------------------------------------------------------
-
-// getfirstkey and getnextkey are used for traversing the database
-// no insertions or deletions should be carried out while traversing
-// the database. when there are no keys left to visit in the database
-// an empty string is returned.
-text_t gdbmclass::getfirstkey ()
-{
-  if (gdbmfile == NULL) return g_EmptyText;
-
-  // get the first key
-  datum firstkey_data = gdbm_firstkey (gdbmfile);
-  if (firstkey_data.dptr == NULL) return g_EmptyText;
-
-  // convert it to text_t
-  text_t firstkey;
-  firstkey.setcarr (firstkey_data.dptr, firstkey_data.dsize);
-  free (firstkey_data.dptr);
-  return to_uni(firstkey);  // convert to unicode
-}
-
-
-text_t gdbmclass::getnextkey (const text_t &key)
-{
-  if (gdbmfile == NULL || key.empty()) return g_EmptyText;
-
-  // get a utf-8 encoded c string of the unicode key
-  datum key_data;
-  key_data.dptr = (to_utf8(key)).getcstr();
-  if (key_data.dptr == NULL) return g_EmptyText;
-  key_data.dsize = strlen (key_data.dptr);
-  
-  // get the next key
-  datum nextkey_data = gdbm_nextkey (gdbmfile, key_data);
-  if (nextkey_data.dptr == NULL) {
-    delete []key_data.dptr;
-    return g_EmptyText;
-  }
-
-  // convert it to text_t
-  text_t nextkey;
-  nextkey.setcarr (nextkey_data.dptr, nextkey_data.dsize);
-  free (nextkey_data.dptr);
-  delete []key_data.dptr;
-  return to_uni(nextkey);  // convert to unicode
-}
+}
Index: /gsdl/trunk/common-src/src/lib/gdbmclass.h
===================================================================
--- /gsdl/trunk/common-src/src/lib/gdbmclass.h	(revision 18049)
+++ /gsdl/trunk/common-src/src/lib/gdbmclass.h	(revision 18050)
@@ -84,4 +84,7 @@
   text_t getfirstkey ();
   text_t getnextkey (const text_t &key);
+
+  // DEPRECATED -- No longer necessary now that the GDBM library reads both little-endian and big-endian
+  void generate_from_txtgz (text_t filename);
 };
 
