]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_mssql.cpp
Update Event and Request APIs
[user/henk/code/inspircd.git] / src / modules / extra / m_mssql.cpp
index 9cc7a567c80afaf5153e563fbfcdb0c45f5b961b..43d546819fb26200c6dd58b5bab9e4c254d088ca 100644 (file)
@@ -35,7 +35,7 @@ typedef std::deque<MsSQLResult*> ResultQueue;
 unsigned long count(const char * const str, char a)
 {
        unsigned long n = 0;
-       for (const char *p = reinterpret_cast<const char *>(str); *p; ++p)
+       for (const char *p = str; *p; ++p)
        {
                if (*p == '?')
                        ++n;
@@ -50,13 +50,9 @@ Mutex* LoggingMutex;
 class QueryThread : public SocketThread
 {
   private:
-       ModuleMsSQL* Parent;
-       InspIRCd* ServerInstance;
+       ModuleMsSQL* const Parent;
   public:
-       QueryThread(InspIRCd* si, ModuleMsSQL* mod)
-       : SocketThread(si), Parent(mod), ServerInstance(si)
-       {
-       }
+       QueryThread(ModuleMsSQL* mod) : Parent(mod) { }
        ~QueryThread() { }
        virtual void Run();
        virtual void OnNotify();
@@ -232,7 +228,6 @@ class SQLConn : public classbase
 {
  private:
        ResultQueue results;
-       InspIRCd* ServerInstance;
        Module* mod;
        SQLhost host;
        TDSLOGIN* login;
@@ -242,8 +237,8 @@ class SQLConn : public classbase
  public:
        QueryQueue queue;
 
-       SQLConn(InspIRCd* SI, Module* m, const SQLhost& hi)
-       : ServerInstance(SI), mod(m), host(hi), login(NULL), sock(NULL), context(NULL)
+       SQLConn(Module* m, const SQLhost& hi)
+       : mod(m), host(hi), login(NULL), sock(NULL), context(NULL)
        {
                if (OpenDB())
                {
@@ -511,7 +506,7 @@ class SQLConn : public classbase
        {
                SQLConn* sc = (SQLConn*)pContext->parent;
                LoggingMutex->Lock();
-               sc->ServerInstance->Logs->Log("m_mssql", DEBUG, "Message for DB with id: %s -> %s", sc->host.id.c_str(), pMessage->message);
+               ServerInstance->Logs->Log("m_mssql", DEBUG, "Message for DB with id: %s -> %s", sc->host.id.c_str(), pMessage->message);
                LoggingMutex->Unlock();
                return 0;
        }
@@ -520,7 +515,7 @@ class SQLConn : public classbase
        {
                SQLConn* sc = (SQLConn*)pContext->parent;
                LoggingMutex->Lock();
-               sc->ServerInstance->Logs->Log("m_mssql", DEFAULT, "Error for DB with id: %s -> %s", sc->host.id.c_str(), pMessage->message);
+               ServerInstance->Logs->Log("m_mssql", DEFAULT, "Error for DB with id: %s -> %s", sc->host.id.c_str(), pMessage->message);
                LoggingMutex->Unlock();
                return 0;
        }
@@ -643,8 +638,8 @@ class ModuleMsSQL : public Module
        QueryThread* queryDispatcher;
 
  public:
-       ModuleMsSQL(InspIRCd* Me)
-       : Module(Me), currid(0)
+       ModuleMsSQL()
+       : currid(0)
        {
                LoggingMutex = new Mutex();
                ResultsMutex = new Mutex();
@@ -658,7 +653,7 @@ class ModuleMsSQL : public Module
 
                ReadConf();
 
-               queryDispatcher = new QueryThread(ServerInstance, this);
+               queryDispatcher = new QueryThread(this);
                ServerInstance->Threads->Start(queryDispatcher);
 
                ServerInstance->Modules->PublishInterface("SQL", this);
@@ -709,7 +704,7 @@ class ModuleMsSQL : public Module
 
        bool HostInConf(const SQLhost &h)
        {
-               ConfigReader conf(ServerInstance);
+               ConfigReader conf;
                for(int i = 0; i < conf.Enumerate("database"); i++)
                {
                        SQLhost host;
@@ -729,7 +724,7 @@ class ModuleMsSQL : public Module
        {
                ClearOldConnections();
 
-               ConfigReader conf(ServerInstance);
+               ConfigReader conf;
                for(int i = 0; i < conf.Enumerate("database"); i++)
                {
                        SQLhost host;
@@ -760,7 +755,7 @@ class ModuleMsSQL : public Module
 
                SQLConn* newconn;
 
-               newconn = new SQLConn(ServerInstance, this, hi);
+               newconn = new SQLConn(this, hi);
 
                connections.insert(std::make_pair(hi.id, newconn));
        }
@@ -837,7 +832,7 @@ class ModuleMsSQL : public Module
 
        virtual Version GetVersion()
        {
-               return Version("$Id$", VF_VENDOR | VF_SERVICEPROVIDER, API_VERSION);
+               return Version("MsSQL provider", VF_VENDOR | VF_SERVICEPROVIDER, API_VERSION);
        }
 
 };