Index: /main/trunk/greenstone2/perllib/dbutil.pm
===================================================================
--- /main/trunk/greenstone2/perllib/dbutil.pm	(revision 21855)
+++ /main/trunk/greenstone2/perllib/dbutil.pm	(revision 21856)
@@ -226,4 +226,39 @@
 
 
+sub write_infodb_rawentry
+{
+  my $infodb_type = shift(@_);
+  my $infodb_handle = shift(@_);
+  my $infodb_key = shift(@_);
+  my $infodb_val = shift(@_);
+
+  if ($infodb_type eq "sqlite")
+  {
+    require dbutil::sqlite;
+    return &dbutil::sqlite::write_infodb_rawentry($infodb_handle, $infodb_key, $infodb_val, @_);
+  }
+  elsif ($infodb_type eq "gdbm-txtgz")
+  {
+    require dbutil::gdbmtxtgz;
+    return &dbutil::gdbmtxtgz::write_infodb_rawentry($infodb_handle, $infodb_key, $infodb_val, @_);
+  }
+  elsif ($infodb_type eq "jdbm")
+  {
+    require dbutil::jdbm;
+    return &dbutil::jdbm::write_infodb_rawentry($infodb_handle, $infodb_key, $infodb_val, @_);
+  }
+  elsif ($infodb_type eq "mssql")
+  {
+    require dbutil::mssql;
+    return &dbutil::mssql::write_infodb_rawentry($infodb_handle, $infodb_key, $infodb_val, @_);
+  }
+
+  # Use GDBM if the infodb type is empty or not one of the values above
+  require dbutil::gdbm;
+  return &dbutil::gdbm::write_infodb_rawentry($infodb_handle, $infodb_key, $infodb_val, @_);
+}
+
+
+
 sub delete_infodb_entry
 {
Index: /main/trunk/greenstone2/perllib/dbutil/gdbm.pm
===================================================================
--- /main/trunk/greenstone2/perllib/dbutil/gdbm.pm	(revision 21855)
+++ /main/trunk/greenstone2/perllib/dbutil/gdbm.pm	(revision 21856)
@@ -132,4 +132,11 @@
 }
 
+sub write_infodb_rawentry
+{
+  # With infodb_handle already set up, works the same as _gdbm_txtgz version
+  &dbutil::gdbmtxtgz::write_infodb_rawentry(@_);
+}
+
+
 sub delete_infodb_entry
 {
Index: /main/trunk/greenstone2/perllib/dbutil/gdbmtxtgz.pm
===================================================================
--- /main/trunk/greenstone2/perllib/dbutil/gdbmtxtgz.pm	(revision 21855)
+++ /main/trunk/greenstone2/perllib/dbutil/gdbmtxtgz.pm	(revision 21856)
@@ -138,4 +138,19 @@
 
 
+    
+sub write_infodb_rawentry
+{
+
+  my $infodb_handle = shift(@_);
+  my $infodb_key = shift(@_);
+  my $infodb_val = shift(@_);
+  
+  print $infodb_handle "[$infodb_key]\n";
+  print $infodb_handle "$infodb_val\n";
+  print $infodb_handle '-' x 70, "\n";
+}
+
+
+
 sub delete_infodb_entry
 {
Index: /main/trunk/greenstone2/perllib/dbutil/jdbm.pm
===================================================================
--- /main/trunk/greenstone2/perllib/dbutil/jdbm.pm	(revision 21855)
+++ /main/trunk/greenstone2/perllib/dbutil/jdbm.pm	(revision 21856)
@@ -181,4 +181,17 @@
 
 
+sub write_infodb_rawentry
+{
+
+  my $infodb_handle = shift(@_);
+  my $infodb_key = shift(@_);
+  my $infodb_val = shift(@_);
+  
+  print $infodb_handle "[$infodb_key]\n";
+  print $infodb_handle "$infodb_val\n";
+  print $infodb_handle '-' x 70, "\n";
+}
+
+
 sub delete_infodb_entry
 {
Index: /main/trunk/greenstone2/perllib/dbutil/mssql.pm
===================================================================
--- /main/trunk/greenstone2/perllib/dbutil/mssql.pm	(revision 21855)
+++ /main/trunk/greenstone2/perllib/dbutil/mssql.pm	(revision 21856)
@@ -140,5 +140,6 @@
   my $infodb_map = shift(@_);
 
-  # !! TO IMPLEMENT
+  print STDERR "******* mssql::read_infodb_file() TO BE IMPLEMENTED!\n";
+  print STDERR "******* See sqlite.pm for comparable implementation that has been coded up!\n";
 }
 
@@ -199,4 +200,17 @@
 }
 
+
+sub write_infodb_rawentry
+{
+  my $infodb_handle = shift(@_);
+  my $infodb_key = shift(@_);
+  my $infodb_val = shift(@_);
+  
+  # Prepare the query
+  my $safe_infodb_key = &mssql_safe($infodb_key);
+  my $query = "INSERT INTO " . $mssql_data_table_name . " (one_key, one_value) VALUES (N'" . $safe_infodb_key . "', N'" . &mssql_safe($infodb_val) . "')";
+  dbquery($infodb_handle, $query);
+}
+
 sub delete_infodb_entry
 {
Index: /main/trunk/greenstone2/perllib/dbutil/sqlite.pm
===================================================================
--- /main/trunk/greenstone2/perllib/dbutil/sqlite.pm	(revision 21855)
+++ /main/trunk/greenstone2/perllib/dbutil/sqlite.pm	(revision 21856)
@@ -72,4 +72,33 @@
 
 
+sub read_infodb_cmd
+{
+  my $infodb_file_path = shift(@_);
+  my $sqlcmd = shift(@_);
+
+  my $result = "";
+
+  my $sqlite3_exe = &util::filename_cat($ENV{'GSDLHOME'},"bin",$ENV{'GSDLOS'}, "sqlite3" . &util::get_os_exe());
+  my $infodb_handle = undef;
+  my $cmd = "echo \"$sqlcmd\" | \"$sqlite3_exe\" \"$infodb_file_path\"";
+
+  if (!-e "$sqlite3_exe" || !open($infodb_handle, "$cmd |"))
+  {
+      print STDERR "Unable to execute: $cmd\n";
+      print STDERR "$!\n";
+  }
+  else {
+
+      my $line;
+      while (defined($line=<$infodb_handle>)) {
+	  $result .= $line;
+      }
+
+      close($infodb_handle);
+  }
+
+  return $result;
+}
+
 sub get_infodb_file_path
 {
@@ -88,5 +117,19 @@
   my $infodb_map = shift(@_);
 
-  # !! TO IMPLEMENT
+
+  my $keys_str = read_infodb_cmd($infodb_file_path,"SELECT key FROM data;");
+
+  my @keys = split(/\n/,$keys_str);
+
+  foreach my $k (@keys) {
+      
+      my $k_safe = &sqlite_safe($k);
+      my $select_val_cmd = "SELECT value FROM data WHERE key='$k_safe';";
+
+      my $val_str = read_infodb_cmd($infodb_file_path,$select_val_cmd);
+
+      $infodb_map->{$k} = $val_str;
+  }
+
 }
 
@@ -146,4 +189,16 @@
 
 
+sub write_infodb_rawentry
+{
+  my $infodb_handle = shift(@_);
+  my $infodb_key = shift(@_);
+  my $infodb_val = shift(@_);
+
+  my $safe_infodb_key = &sqlite_safe($infodb_key);
+  print $infodb_handle "INSERT OR REPLACE INTO data (key, value) VALUES ('" . $safe_infodb_key . "', '" . &sqlite_safe($infodb_val) . "');\n";
+}
+
+
+
 sub delete_infodb_entry
 {
