diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-03-21 19:57:14 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-03-21 19:57:14 +0000 |
commit | 287169d6e8a0aefe12dac1df04778fa73b792682 (patch) | |
tree | 36d2172300fed75d6a1671c248704cffa1798456 | |
parent | fc05827621fe0c623d2fedf9dcb47c17d57bea16 (diff) |
Made the database file name configurable
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2830 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | Changes.conf | 1 | ||||
-rw-r--r-- | data/example.conf | 8 | ||||
-rw-r--r-- | include/config.h | 3 | ||||
-rw-r--r-- | src/core/db_plain.cpp | 21 |
4 files changed, 24 insertions, 9 deletions
diff --git a/Changes.conf b/Changes.conf index ccf9c7576..eecebc1af 100644 --- a/Changes.conf +++ b/Changes.conf @@ -7,6 +7,7 @@ options:database added for the database modules options:botmodes added to configure modes BotServ bots should use options:userlen added to configure maxiumum ident length options:hostlen added to configure maximum hostname length +db_plain:database added to configure what database file to use ** MODIFIED CONFIGURATION DIRECTIVES ** options:encryption added enc_sha256 diff --git a/data/example.conf b/data/example.conf index 4ddaa3ec7..cdfe7c6b0 100644 --- a/data/example.conf +++ b/data/example.conf @@ -1494,6 +1494,14 @@ module { name = "hs_request" } * The following blocks are used for options pertaining to modules and are not part of the core. * Unless otherwise stated, most of the options are optional. */ +db_plain +{ + /* + * The database db_plain should use + */ + database = "anope.db" +} + hs_request { /* diff --git a/include/config.h b/include/config.h index 601013e86..320c43d57 100644 --- a/include/config.h +++ b/include/config.h @@ -25,9 +25,6 @@ /* Name of configuration file (in Services directory) */ #define SERVICES_CONF "services.conf" -/* Name of anope datbase */ -#define DATABASE_FILE "anope.db" - /* Name of log file (in Services directory) */ #define LOG_FILENAME "services.log" diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index dd257c035..89fc8d469 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -16,6 +16,7 @@ #include "module.h" std::fstream db; +std::string DatabaseFile; /** Enum used for what METADATA type we are reading */ @@ -43,11 +44,11 @@ static void ReadDatabase(Module *m = NULL) EventReturn MOD_RESULT; MDType Type = MD_NONE; - db.open(DATABASE_FILE, std::ios_base::in); + db.open(DatabaseFile.c_str(), std::ios_base::in); if (!db.is_open()) { - ircdproto->SendGlobops(NULL, "Unable to open %s for reading!", DATABASE_FILE); + ircdproto->SendGlobops(NULL, "Unable to open %s for reading!", DatabaseFile.c_str()); return; } @@ -519,8 +520,16 @@ class DBPlain : public Module this->SetVersion("$Id$"); this->SetType(DATABASE); - Implementation i[] = { I_OnDatabaseRead, I_OnLoadDatabase, I_OnDatabaseReadMetadata, I_OnSaveDatabase, I_OnModuleLoad }; - ModuleManager::Attach(i, this, 5); + Implementation i[] = { I_OnReload, I_OnDatabaseRead, I_OnLoadDatabase, I_OnDatabaseReadMetadata, I_OnSaveDatabase, I_OnModuleLoad }; + ModuleManager::Attach(i, this, 6); + + OnReload(true); + } + + void OnReload(bool) + { + ConfigReader config; + DatabaseFile = config.ReadValue("db_plain", "database", "anope.db", 0); } EventReturn OnDatabaseRead(const std::vector<std::string> ¶ms) @@ -832,11 +841,11 @@ class DBPlain : public Module EventReturn OnSaveDatabase() { - db.open(DATABASE_FILE, std::ios_base::out | std::ios_base::trunc); + db.open(DatabaseFile.c_str(), std::ios_base::out | std::ios_base::trunc); if (!db.is_open()) { - ircdproto->SendGlobops(NULL, "Unable to open %s for writing!", DATABASE_FILE); + ircdproto->SendGlobops(NULL, "Unable to open %s for writing!", DatabaseFile.c_str()); return EVENT_CONTINUE; } |