diff options
author | deva <deva> | 2008-08-21 10:00:09 +0000 |
---|---|---|
committer | deva <deva> | 2008-08-21 10:00:09 +0000 |
commit | 8e1f28fdd6908a852dd0d11ea868fef965b89790 (patch) | |
tree | 83046052234ef0b03818541275fd4ffb1aaf51a2 | |
parent | d3ea5701baadcdbc6df8775d88f173e52936307a (diff) |
Made postgres addr, username and password configurable.
-rw-r--r-- | server/src/configuration.cc | 4 | ||||
-rw-r--r-- | server/src/configuration.h | 4 | ||||
-rw-r--r-- | server/src/configurationparser.cc | 19 | ||||
-rw-r--r-- | server/src/database.h | 6 | ||||
-rw-r--r-- | server/src/server.cc | 2 |
5 files changed, 31 insertions, 4 deletions
diff --git a/server/src/configuration.cc b/server/src/configuration.cc index fc2da6a..33f3256 100644 --- a/server/src/configuration.cc +++ b/server/src/configuration.cc @@ -38,3 +38,7 @@ time_t Conf::pentominos_max_ttl = 60 * 60 * 24; std::string Conf::pentominos_addr = "localhost"; port_t Conf::pentominos_port = 11108; + +std::string Conf::database_addr = "localhost"; +std::string Conf::database_user = "pracro"; +std::string Conf::database_passwd = "pracro"; diff --git a/server/src/configuration.h b/server/src/configuration.h index eacac14..fde9bd1 100644 --- a/server/src/configuration.h +++ b/server/src/configuration.h @@ -47,6 +47,10 @@ namespace Conf { extern std::string pentominos_addr; extern port_t pentominos_port; + + extern std::string database_addr; + extern std::string database_user; + extern std::string database_passwd; }; #endif/*__ARTEFACT_CONFIGURATION_H__*/ diff --git a/server/src/configurationparser.cc b/server/src/configurationparser.cc index 3065907..6bab578 100644 --- a/server/src/configurationparser.cc +++ b/server/src/configurationparser.cc @@ -103,4 +103,23 @@ void ConfigurationParser::reload() Conf::pentominos_port = p; } catch( ... ) { } + + try { + std::string a = lookup("database_addr"); + Conf::database_addr = a; + } catch( ... ) { + } + + try { + std::string u = lookup("database_user"); + Conf::database_user = u; + } catch( ... ) { + } + + try { + std::string p = lookup("database_passwd"); + Conf::database_passwd = p; + } catch( ... ) { + } + } diff --git a/server/src/database.h b/server/src/database.h index c15aca5..332907f 100644 --- a/server/src/database.h +++ b/server/src/database.h @@ -50,9 +50,9 @@ typedef std::vector< std::string > Fieldnames; class Database { public: - Database(std::string hostname = "localhost", - std::string user = "pracro", - std::string password = "pracro"); + Database(std::string hostname, + std::string user, + std::string password); ~Database(); // Make a commit to the db diff --git a/server/src/server.cc b/server/src/server.cc index 75dc341..b98cc94 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -79,7 +79,7 @@ static std::string handleTransaction(Transaction &transaction) answer += "<pracro version=\"1.0\">\n"; try { - Database db; + Database db(Conf::database_addr, Conf::database_user, Conf::database_passwd); // // Handle commits |