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;
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();
{
private:
ResultQueue results;
- InspIRCd* ServerInstance;
Module* mod;
SQLhost host;
TDSLOGIN* login;
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())
{
{
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;
}
{
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;
}
QueryThread* queryDispatcher;
public:
- ModuleMsSQL(InspIRCd* Me)
- : Module(Me), currid(0)
+ ModuleMsSQL()
+ : currid(0)
{
LoggingMutex = new Mutex();
ResultsMutex = new Mutex();
ReadConf();
- queryDispatcher = new QueryThread(ServerInstance, this);
+ queryDispatcher = new QueryThread(this);
ServerInstance->Threads->Start(queryDispatcher);
ServerInstance->Modules->PublishInterface("SQL", this);
bool HostInConf(const SQLhost &h)
{
- ConfigReader conf(ServerInstance);
+ ConfigReader conf;
for(int i = 0; i < conf.Enumerate("database"); i++)
{
SQLhost host;
{
ClearOldConnections();
- ConfigReader conf(ServerInstance);
+ ConfigReader conf;
for(int i = 0; i < conf.Enumerate("database"); i++)
{
SQLhost host;
SQLConn* newconn;
- newconn = new SQLConn(ServerInstance, this, hi);
+ newconn = new SQLConn(this, hi);
connections.insert(std::make_pair(hi.id, newconn));
}
virtual Version GetVersion()
{
- return Version("$Id$", VF_VENDOR | VF_SERVICEPROVIDER, API_VERSION);
+ return Version("MsSQL provider", VF_VENDOR | VF_SERVICEPROVIDER, API_VERSION);
}
};