1
0
mirror of https://github.com/anope/anope.git synced 2026-07-03 22:03:14 +02:00

Made the database file name configurable

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2830 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
Adam-
2010-03-21 19:57:14 +00:00
parent fc05827621
commit 287169d6e8
4 changed files with 24 additions and 9 deletions
+1
View File
@@ -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
+8
View File
@@ -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
{
/*
-3
View File
@@ -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"
+15 -6
View File
@@ -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> &params)
@@ -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;
}