X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fextra%2Fm_mssql.cpp;h=598f9aac9c88ae5ef4045a327d7ae180d5d331f8;hb=a5d110282a864fd2e91b51ce360a977cd0643657;hp=25c4952a9207746f6a799320a418cc358c2ac9ca;hpb=57e908f8ce297c38e31843057226b737aa9fc6d2;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/extra/m_mssql.cpp b/src/modules/extra/m_mssql.cpp index 25c4952a9..598f9aac9 100644 --- a/src/modules/extra/m_mssql.cpp +++ b/src/modules/extra/m_mssql.cpp @@ -1,16 +1,26 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2008-2009 Dennis Friis + * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2008-2009 Craig Edwards + * Copyright (C) 2008 Robin Burchell + * Copyright (C) 2008 Pippijn van Steenhoven * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "inspircd.h" #include #include @@ -636,29 +646,26 @@ class ModuleMsSQL : public Module private: unsigned long currid; QueryThread* queryDispatcher; + ServiceProvider sqlserv; public: ModuleMsSQL() - : currid(0) + : currid(0), sqlserv(this, "SQL/mssql", SERVICE_DATA) { LoggingMutex = new Mutex(); ResultsMutex = new Mutex(); + queryDispatcher = new QueryThread(this); + } - ServerInstance->Modules->UseInterface("SQLutils"); - - if (!ServerInstance->Modules->PublishFeature("SQL", this)) - { - throw ModuleException("m_mssql: Unable to publish feature 'SQL'"); - } - + void init() + { ReadConf(); - queryDispatcher = new QueryThread(this); ServerInstance->Threads->Start(queryDispatcher); - ServerInstance->Modules->PublishInterface("SQL", this); Implementation eventlist[] = { I_OnRehash }; - ServerInstance->Modules->Attach(eventlist, this, 1); + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); + ServerInstance->Modules->AddService(sqlserv); } virtual ~ModuleMsSQL() @@ -668,10 +675,6 @@ class ModuleMsSQL : public Module ClearQueue(); ClearAllConnections(); - ServerInstance->Modules->UnpublishInterface("SQL", this); - ServerInstance->Modules->UnpublishFeature("SQL"); - ServerInstance->Modules->DoneWithInterface("SQLutils"); - delete LoggingMutex; delete ResultsMutex; } @@ -704,16 +707,17 @@ class ModuleMsSQL : public Module bool HostInConf(const SQLhost &h) { - ConfigReader conf; - for(int i = 0; i < conf.Enumerate("database"); i++) + ConfigTagList tags = ServerInstance->Config->ConfTags("database"); + for (ConfigIter i = tags.first; i != tags.second; ++i) { + ConfigTag* tag = i->second; SQLhost host; - host.id = conf.ReadValue("database", "id", i); - host.host = conf.ReadValue("database", "hostname", i); - host.port = conf.ReadInteger("database", "port", "1433", i, true); - host.name = conf.ReadValue("database", "name", i); - host.user = conf.ReadValue("database", "username", i); - host.pass = conf.ReadValue("database", "password", i); + host.id = tag->getString("id"); + host.host = tag->getString("hostname"); + host.port = tag->getInt("port", 1433); + host.name = tag->getString("name"); + host.user = tag->getString("username"); + host.pass = tag->getString("password"); if (h == host) return true; } @@ -724,17 +728,18 @@ class ModuleMsSQL : public Module { ClearOldConnections(); - ConfigReader conf; - for(int i = 0; i < conf.Enumerate("database"); i++) + ConfigTagList tags = ServerInstance->Config->ConfTags("database"); + for (ConfigIter i = tags.first; i != tags.second; ++i) { + ConfigTag* tag = i->second; SQLhost host; - host.id = conf.ReadValue("database", "id", i); - host.host = conf.ReadValue("database", "hostname", i); - host.port = conf.ReadInteger("database", "port", "1433", i, true); - host.name = conf.ReadValue("database", "name", i); - host.user = conf.ReadValue("database", "username", i); - host.pass = conf.ReadValue("database", "password", i); + host.id = tag->getString("id"); + host.host = tag->getString("hostname"); + host.port = tag->getInt("port", 1433); + host.name = tag->getString("name"); + host.user = tag->getString("username"); + host.pass = tag->getString("password"); if (HasHost(host)) continue; @@ -777,12 +782,9 @@ class ModuleMsSQL : public Module void ClearAllConnections() { - ConnMap::iterator i; - while ((i = connections.begin()) != connections.end()) - { - connections.erase(i); + for(ConnMap::iterator i = connections.begin(); i != connections.end(); ++i) delete i->second; - } + connections.clear(); } virtual void OnRehash(User* user) @@ -825,7 +827,7 @@ class ModuleMsSQL : public Module virtual Version GetVersion() { - return Version("MsSQL provider", VF_VENDOR | VF_SERVICEPROVIDER, API_VERSION); + return Version("MsSQL provider", VF_VENDOR); } };