2 /**************************************************************************
3 ** (c) Copyright 2002, Andromeda Technology & Automation
4 ** This is free software; you can redistribute it and/or modify it under the
5 ** terms of the GNU General Public License, see the file COPYING.
6 ***************************************************************************
7 ** MODULE INFORMATION *
8 ***********************
9 ** FILE NAME : gnucomo_config.cpp
10 ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
11 ** VERSION NUMBER : $Revision: 1.4 $
13 ** DESCRIPTION : Implementation of the gnucomo_config class.
18 ***************************************************************************
19 ** ADMINISTRATIVE INFORMATION *
20 ********************************
21 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
22 ** CREATION DATE : Jul 24, 2002
23 ** LAST UPDATE : Nov 02, 2002
25 **************************************************************************/
27 /*****************************
28 $Log: gnucomo_config.cpp,v $
29 Revision 1.4 2002-12-06 22:32:11 arjen
30 Added new arguments to gnucomo_config::Database(): user and password.
31 If empty, default values are taken from the config file.
33 Revision 1.3 2002/11/09 08:04:27 arjen
34 Added a reference to the GPL
36 Revision 1.2 2002/11/04 10:13:36 arjen
37 Use proper namespace for iostream classes
39 Revision 1.1 2002/10/05 10:25:49 arjen
40 Creation of gcm_input and a first approach to a web interface
42 *****************************/
44 static const char *RCSID = "$Id: gnucomo_config.cpp,v 1.4 2002-12-06 22:32:11 arjen Exp $";
46 #include "gnucomo_config.h"
50 /*=========================================================================
52 ** SYNOPSIS : String gnucomo_config::Database()
54 ** RETURN VALUE : The database access string
56 ** DESCRIPTION : If the parameters 'usr' and 'pw' are empty, the
57 ** username and password from the configuration file
64 ** LAST MODIFIED : Nov 21, 2002
65 **=========================================================================
68 String gnucomo_config::Database(String usr, String pw)
71 String access_string("");
73 param = find_parameter("database", "name");
76 access_string += "dbname=" + param;
81 param = find_parameter("database", "user");
84 access_string += " user=" + param;
89 access_string += " user=" + usr;
94 param = find_parameter("database", "password");
97 access_string += " password=" + param;
102 access_string += " password=" + pw;
105 param = find_parameter("database", "host");
108 access_string += " host=" + param;
110 param = find_parameter("database", "port");
113 access_string += " port=" + param;
115 return access_string;