From 1d0bb9b26b7ad58ab0bf979ac046f4511b3bf12b Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 5 May 2013 01:55:04 -0400 Subject: Rework the config file reader to be much more flexible and move many configuration directives to the actual modules they are used in. --- modules/extra/m_mysql.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'modules/extra/m_mysql.cpp') diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index c41ba37a8..372cb6982 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -188,8 +188,9 @@ class ModuleSQL : public Module, public Pipe delete DThread; } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { + Configuration::Block *config = Config->GetModule(this); int i, num; for (std::map::iterator it = this->MySQLServices.begin(); it != this->MySQLServices.end();) @@ -198,13 +199,9 @@ class ModuleSQL : public Module, public Pipe MySQLService *s = it->second; ++it; - for (i = 0, num = reader.Enumerate("mysql"); i < num; ++i) - { - if (reader.ReadValue("mysql", "name", "main", i) == cname) - { + for (i = 0; i < Config->CountBlock("mysql"); ++i) + if (Config->GetBlock("mysql", i)->Get("name", "main") == cname) break; - } - } if (i == num) { @@ -215,17 +212,18 @@ class ModuleSQL : public Module, public Pipe } } - for (i = 0, num = reader.Enumerate("mysql"); i < num; ++i) + for (i = 0; i < Config->CountBlock("mysql"); ++i) { - Anope::string connname = reader.ReadValue("mysql", "name", "mysql/main", i); + Configuration::Block *block = Config->GetBlock("mysql", i); + const Anope::string &connname = block->Get("name", "mysql/main"); if (this->MySQLServices.find(connname) == this->MySQLServices.end()) { - Anope::string database = reader.ReadValue("mysql", "database", "anope", i); - Anope::string server = reader.ReadValue("mysql", "server", "127.0.0.1", i); - Anope::string user = reader.ReadValue("mysql", "username", "anope", i); - Anope::string password = reader.ReadValue("mysql", "password", "", i); - int port = reader.ReadInteger("mysql", "port", "3306", i, true); + const Anope::string &database = block->Get("database", "anope"); + const Anope::string &server = block->Get("server", "127.0.0.1"); + const Anope::string &user = block->Get("username", "anope"); + const Anope::string &password = block->Get("password"); + int port = block->Get("port", "3306"); try { -- cgit