***********************
** 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
*****************************/
-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"
** 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("");
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");