Added new arguments to gnucomo_config::Database(): user and password.
authorarjen <arjen>
Fri, 6 Dec 2002 22:30:50 +0000 (22:30 +0000)
committerarjen <arjen>
Fri, 6 Dec 2002 22:30:50 +0000 (22:30 +0000)
If empty, default values are taken from the config file.

src/include/gnucomo_config.h
src/lib/gnucomo_config.cpp
src/phpclasses/gnucomo_config.php
src/web/classes/gnucomo_config.php

index ade6ac3..68558f7 100644 (file)
@@ -8,7 +8,7 @@
 ***********************
 **      FILE NAME      : gnucomo.h
 **      SYSTEM NAME    : 
-**      VERSION NUMBER : $Revision: 1.2 $
+**      VERSION NUMBER : $Revision: 1.3 $
 **
 **  DESCRIPTION      :  
 **
 
 /*****************************
    $Log: gnucomo_config.h,v $
-   Revision 1.2  2002-11-09 08:04:27  arjen
+   Revision 1.3  2002-12-06 22:30:50  arjen
+   Added new arguments to gnucomo_config::Database(): user and password.
+   If empty, default values are taken from the config file.
+
+   Revision 1.2  2002/11/09 08:04:27  arjen
    Added a reference to the GPL
 
    Revision 1.1  2002/10/05 10:25:49  arjen
@@ -34,7 +38,7 @@
 
 *****************************/
 
-/* static const char *RCSID = "$Id: gnucomo_config.h,v 1.2 2002-11-09 08:04:27 arjen Exp $"; */
+/* static const char *RCSID = "$Id: gnucomo_config.h,v 1.3 2002-12-06 22:30:50 arjen Exp $"; */
 
 #include <AXE/configuration.h>
 
@@ -50,7 +54,7 @@
 //
 //  RELATIONS      :
 //  SEE ALSO       :
-//  LAST MODIFIED  :
+//  LAST MODIFIED  : Nov 21, 2002
 ///////////////////////////////////////////////////////////////////////////
 */
 
@@ -59,6 +63,6 @@ class gnucomo_config : public configuration
 
 public:
 
-   String   Database();  // Return the database access string.
+   String   Database(String usr="", String pw="");  // Return the database access string.
 };
 
index 4e45b82..f1cb57d 100644 (file)
@@ -8,7 +8,7 @@
 ***********************
 **      FILE NAME      : gnucomo_config.cpp
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.3 $
+**      VERSION NUMBER : $Revision: 1.4 $
 **
 **  DESCRIPTION      :  Implementation of the gnucomo_config class.
 **
 
 /*****************************
    $Log: gnucomo_config.cpp,v $
-   Revision 1.3  2002-11-09 08:04:27  arjen
+   Revision 1.4  2002-12-06 22:32:11  arjen
+   Added new arguments to gnucomo_config::Database(): user and password.
+   If empty, default values are taken from the config file.
+
+   Revision 1.3  2002/11/09 08:04:27  arjen
    Added a reference to the GPL
 
    Revision 1.2  2002/11/04 10:13:36  arjen
@@ -37,7 +41,7 @@
 
 *****************************/
 
-static const char *RCSID = "$Id: gnucomo_config.cpp,v 1.3 2002-11-09 08:04:27 arjen Exp $";
+static const char *RCSID = "$Id: gnucomo_config.cpp,v 1.4 2002-12-06 22:32:11 arjen Exp $";
 
 #include "gnucomo_config.h"
 
@@ -49,17 +53,19 @@ static const char *RCSID = "$Id: gnucomo_config.cpp,v 1.3 2002-11-09 08:04:27 ar
 **  PARAMETERS     : 
 **  RETURN VALUE   : The database access string
 **
-**  DESCRIPTION    : 
+**  DESCRIPTION    : If the parameters 'usr' and 'pw' are empty, the
+**                   username and password from the configuration file
+**                   are used.
 **
 **  VARS USED      :
 **  VARS CHANGED   :
 **  FUNCTIONS USED :
 **  SEE ALSO       :
-**  LAST MODIFIED  : Nov 02, 2002
+**  LAST MODIFIED  : Nov 21, 2002
 **=========================================================================
 */
 
-String gnucomo_config::Database()
+String gnucomo_config::Database(String usr, String pw)
 {
    String param;
    String access_string("");
@@ -70,15 +76,30 @@ String gnucomo_config::Database()
       access_string += "dbname=" + param;
    }
 
-   param = find_parameter("database", "user");
-   if (param != "")
+   if (usr == "")
    {
-      access_string += " user=" + param;
+      param = find_parameter("database", "user");
+      if (param != "")
+      {
+         access_string += " user=" + param;
+      }
    }
-   param = find_parameter("database", "password");
-   if (param != "")
+   else
+   {
+      access_string += " user=" + usr;
+   }
+
+   if (pw == "")
+   {
+      param = find_parameter("database", "password");
+      if (param != "")
+      {
+         access_string += " password=" + param;
+      }
+   }
+   else
    {
-      access_string += " password=" + param;
+      access_string += " password=" + pw;
    }
 
    param = find_parameter("database", "host");
index 8453adb..507a462 100644 (file)
@@ -19,7 +19,7 @@ require_once('configuration.class.php');
 //
 //  RELATIONS      :
 //  SEE ALSO       :
-//  LAST MODIFIED  : Sep 26, 2002
+//  LAST MODIFIED  : Nov 21, 2002
 ///////////////////////////////////////////////////////////////////////////
 */
 
@@ -28,7 +28,7 @@ class gnucomo_config extends configuration
 
    // Return the database access string.
 
-   function Database()
+   function Database($usr = "", $pw = "")
    {
       $access_string = "";
 
@@ -38,16 +38,30 @@ class gnucomo_config extends configuration
          $access_string .= "dbname=" . $param;
       }
 
-      $param = $this->find_parameter("database", "user");
-      if ($param != "")
+      if ($usr == "")
+      {
+         $param = $this->find_parameter("database", "user");
+         if ($param != "")
+         {
+            $access_string .= " user=" . $param;
+         }
+      }
+      else
       {
-         $access_string .= " user=" . $param;
+         $access_string .= " user=" . $usr;
       }
 
-      $param = $this->find_parameter("database", "password");
-      if ($param != "")
+      if ($pw == "")
+      {
+         $param = $this->find_parameter("database", "password");
+         if ($param != "")
+         {
+            $access_string .= " password=" . $param;
+         }
+      }
+      else
       {
-         $access_string .= " password=" . $param;
+         $access_string .= " password=" . $pw;
       }
 
       $param = $this->find_parameter("database", "host");
index 8453adb..507a462 100644 (file)
@@ -19,7 +19,7 @@ require_once('configuration.class.php');
 //
 //  RELATIONS      :
 //  SEE ALSO       :
-//  LAST MODIFIED  : Sep 26, 2002
+//  LAST MODIFIED  : Nov 21, 2002
 ///////////////////////////////////////////////////////////////////////////
 */
 
@@ -28,7 +28,7 @@ class gnucomo_config extends configuration
 
    // Return the database access string.
 
-   function Database()
+   function Database($usr = "", $pw = "")
    {
       $access_string = "";
 
@@ -38,16 +38,30 @@ class gnucomo_config extends configuration
          $access_string .= "dbname=" . $param;
       }
 
-      $param = $this->find_parameter("database", "user");
-      if ($param != "")
+      if ($usr == "")
+      {
+         $param = $this->find_parameter("database", "user");
+         if ($param != "")
+         {
+            $access_string .= " user=" . $param;
+         }
+      }
+      else
       {
-         $access_string .= " user=" . $param;
+         $access_string .= " user=" . $usr;
       }
 
-      $param = $this->find_parameter("database", "password");
-      if ($param != "")
+      if ($pw == "")
+      {
+         $param = $this->find_parameter("database", "password");
+         if ($param != "")
+         {
+            $access_string .= " password=" . $param;
+         }
+      }
+      else
       {
-         $access_string .= " password=" . $param;
+         $access_string .= " password=" . $pw;
       }
 
       $param = $this->find_parameter("database", "host");