summaryrefslogtreecommitdiff
path: root/src/common/configuration.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-11-01 13:44:38 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-11-01 17:13:46 +0100
commit5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed (patch)
tree19d2d94b8c90ccb9a24529102431e6a68c0b7a4b /src/common/configuration.cpp
parentfba5a19e5885e3f4ddca2c249a96fbbe24c846b8 (diff)
downloadmanaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.tar.gz
manaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.tar.bz2
manaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.tar.xz
manaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.zip
Have one place where the Configuration is initialized
Also, removed the fallback to the standard config file path when a config file path is specified on the command line. Surely that's not what you would want to happen. Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/common/configuration.cpp')
-rw-r--r--src/common/configuration.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/common/configuration.cpp b/src/common/configuration.cpp
index 89b77e32..15ce6763 100644
--- a/src/common/configuration.cpp
+++ b/src/common/configuration.cpp
@@ -29,20 +29,25 @@
#include "utils/xml.h"
#include "utils/string.h"
+#define DEFAULT_CONFIG_FILE "manaserv.xml"
+
/**< Persistent configuration. */
static std::map< std::string, std::string > options;
/**< Location of config file. */
static std::string configPath;
-bool Configuration::initialize(const std::string &filename)
+bool Configuration::initialize(const std::string &fileName)
{
- configPath = filename;
+ if (fileName.empty())
+ configPath = DEFAULT_CONFIG_FILE;
+ else
+ configPath = fileName;
- XML::Document doc(filename, false);
+ XML::Document doc(configPath, false);
xmlNodePtr node = doc.rootNode();
if (!node || !xmlStrEqual(node->name, BAD_CAST "configuration")) {
- LOG_WARN("No configuration file '" << filename.c_str() << "'.");
+ LOG_WARN("No configuration file '" << configPath.c_str() << "'.");
return false;
}
@@ -60,6 +65,8 @@ bool Configuration::initialize(const std::string &filename)
options[key] = value;
}
+ LOG_INFO("Using config file: " << configPath);
+
return true;
}