summaryrefslogtreecommitdiff
path: root/modules/extra/m_mysql.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/extra/m_mysql.cpp')
-rw-r--r--modules/extra/m_mysql.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp
index e072f8dfe..a61f11e8b 100644
--- a/modules/extra/m_mysql.cpp
+++ b/modules/extra/m_mysql.cpp
@@ -1,9 +1,9 @@
/* RequiredLibraries: mysqlclient */
#include "module.h"
+#include "modules/sql.h"
#define NO_CLIENT_LONG_LONG
#include <mysql/mysql.h>
-#include "sql.h"
using namespace SQL;
@@ -165,7 +165,7 @@ class ModuleSQL : public Module, public Pipe
/* The thread used to execute queries */
DispatcherThread *DThread;
- ModuleSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED)
+ ModuleSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
{
me = this;
@@ -174,8 +174,6 @@ class ModuleSQL : public Module, public Pipe
DThread = new DispatcherThread();
DThread->Start();
-
- OnReload();
}
~ModuleSQL()
@@ -190,9 +188,9 @@ class ModuleSQL : public Module, public Pipe
delete DThread;
}
- void OnReload() anope_override
+ void OnReload(Configuration::Conf *conf) anope_override
{
- ConfigReader config;
+ Configuration::Block *config = Config->GetModule(this);
int i, num;
for (std::map<Anope::string, MySQLService *>::iterator it = this->MySQLServices.begin(); it != this->MySQLServices.end();)
@@ -201,13 +199,9 @@ class ModuleSQL : public Module, public Pipe
MySQLService *s = it->second;
++it;
- for (i = 0, num = config.Enumerate("mysql"); i < num; ++i)
- {
- if (config.ReadValue("mysql", "name", "main", i) == cname)
- {
+ for (i = 0; i < Config->CountBlock("mysql"); ++i)
+ if (Config->GetBlock("mysql", i)->Get<const Anope::string>("name", "main") == cname)
break;
- }
- }
if (i == num)
{
@@ -218,17 +212,18 @@ class ModuleSQL : public Module, public Pipe
}
}
- for (i = 0, num = config.Enumerate("mysql"); i < num; ++i)
+ for (i = 0; i < Config->CountBlock("mysql"); ++i)
{
- Anope::string connname = config.ReadValue("mysql", "name", "mysql/main", i);
+ Configuration::Block *block = Config->GetBlock("mysql", i);
+ const Anope::string &connname = block->Get<const Anope::string>("name", "mysql/main");
if (this->MySQLServices.find(connname) == this->MySQLServices.end())
{
- Anope::string database = config.ReadValue("mysql", "database", "anope", i);
- Anope::string server = config.ReadValue("mysql", "server", "127.0.0.1", i);
- Anope::string user = config.ReadValue("mysql", "username", "anope", i);
- Anope::string password = config.ReadValue("mysql", "password", "", i);
- int port = config.ReadInteger("mysql", "port", "3306", i, true);
+ const Anope::string &database = block->Get<const Anope::string>("database", "anope");
+ const Anope::string &server = block->Get<const Anope::string>("server", "127.0.0.1");
+ const Anope::string &user = block->Get<const Anope::string>("username", "anope");
+ const Anope::string &password = block->Get<const Anope::string>("password");
+ int port = block->Get<int>("port", "3306");
try
{