summaryrefslogtreecommitdiff
path: root/src/modules/extra
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-26 00:58:31 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-04-26 00:58:31 +0000
commitb6f5d703b010fa5e4cd1d082ea70fe0cc27fb9e9 (patch)
treea4968276af8ce4ab6d5281af8355cbab96b67934 /src/modules/extra
parent566a3fe5ca4cf41e17b529a7c288aeecf6dda8de (diff)
Major code tidyup (-W) - expect a few belches
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1190 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra')
-rw-r--r--src/modules/extra/m_sql.cpp16
-rw-r--r--src/modules/extra/m_sqllog.cpp36
2 files changed, 27 insertions, 25 deletions
diff --git a/src/modules/extra/m_sql.cpp b/src/modules/extra/m_sql.cpp
index 45421e334..dd0cbdc1d 100644
--- a/src/modules/extra/m_sql.cpp
+++ b/src/modules/extra/m_sql.cpp
@@ -56,7 +56,9 @@ class SQLConnection
this->pass = thispass;
this->db = thisdb;
this->id = myid;
+ unsigned int timeout = 1;
mysql_init(&connection);
+ mysql_options(&connection,MYSQL_OPT_CONNECT_TIMEOUT,(char*)&timeout);
}
// This method connects to the database using the credentials supplied to the constructor, and returns
@@ -187,18 +189,18 @@ class ModuleSQL : public Module
}
}
- void LoadDatabases(ConfigReader* Conf)
+ void LoadDatabases(ConfigReader* ThisConf)
{
Srv->Log(DEFAULT,"SQL: Loading database settings");
Connections.clear();
Srv->Log(DEBUG,"Cleared connections");
- for (int j =0; j < Conf->Enumerate("database"); j++)
+ for (int j =0; j < ThisConf->Enumerate("database"); j++)
{
- std::string db = Conf->ReadValue("database","name",j);
- std::string user = Conf->ReadValue("database","username",j);
- std::string pass = Conf->ReadValue("database","password",j);
- std::string host = Conf->ReadValue("database","hostname",j);
- std::string id = Conf->ReadValue("database","id",j);
+ std::string db = ThisConf->ReadValue("database","name",j);
+ std::string user = ThisConf->ReadValue("database","username",j);
+ std::string pass = ThisConf->ReadValue("database","password",j);
+ std::string host = ThisConf->ReadValue("database","hostname",j);
+ std::string id = ThisConf->ReadValue("database","id",j);
Srv->Log(DEBUG,"Read database settings");
if ((db != "") && (host != "") && (user != "") && (id != "") && (pass != ""))
{
diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp
index 55343e96d..035012650 100644
--- a/src/modules/extra/m_sqllog.cpp
+++ b/src/modules/extra/m_sqllog.cpp
@@ -100,26 +100,26 @@ class ModuleSQLLog : public Module
delete query;
if (nid < 1)
{
- SQLRequest* query = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_actors VALUES('','"+nick+"')");
- Request queryrequest((char*)query, this, SQLModule);
- SQLResult* result = (SQLResult*)queryrequest.Send();
- if (result->GetType() == SQL_ERROR)
+ SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_actors VALUES('','"+nick+"')");
+ Request queryrequest2((char*)query2, this, SQLModule);
+ SQLResult* result2 = (SQLResult*)queryrequest2.Send();
+ if (result2->GetType() == SQL_ERROR)
{
- Srv->Log(DEFAULT,"SQL log error: " + result->GetError());
+ Srv->Log(DEFAULT,"SQL log error: " + result2->GetError());
}
- if (result)
+ if (result2)
delete result;
- if (query)
- delete query;
+ if (query2)
+ delete query2;
nid = InsertNick(nick);
}
return nid;
}
- void InsertEntry(long category,long nickid,long hostid,long sourceid,unsigned long date)
+ void InsertEntry(unsigned long category,unsigned long nickid,unsigned long hostid,unsigned long sourceid,unsigned long date)
{
char querybuffer[MAXBUF];
- snprintf(querybuffer,MAXBUF,"INSERT INTO ircd_log VALUES('',%d,%d,%d,%d,%lu)",category,nickid,hostid,sourceid,date);
+ snprintf(querybuffer,MAXBUF,"INSERT INTO ircd_log VALUES('',%lu,%lu,%lu,%lu,%lu)",(unsigned long)category,(unsigned long)nickid,(unsigned long)hostid,(unsigned long)sourceid,(unsigned long)date);
SQLRequest* query = new SQLRequest(SQL_COUNT,dbid,querybuffer);
Request queryrequest((char*)query, this, SQLModule);
SQLResult* result = (SQLResult*)queryrequest.Send();
@@ -160,17 +160,17 @@ class ModuleSQLLog : public Module
delete query;
if (hid < 1)
{
- SQLRequest* query = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_hosts VALUES('','"+host+"')");
- Request queryrequest((char*)query, this, SQLModule);
- SQLResult* result = (SQLResult*)queryrequest.Send();
- if (result->GetType() == SQL_ERROR)
+ SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_hosts VALUES('','"+host+"')");
+ Request queryrequest2((char*)query2, this, SQLModule);
+ SQLResult* result2 = (SQLResult*)queryrequest2.Send();
+ if (result2->GetType() == SQL_ERROR)
{
- Srv->Log(DEFAULT,"SQL log error: " + result->GetError());
+ Srv->Log(DEFAULT,"SQL log error: " + result2->GetError());
}
if (result)
- delete result;
+ delete result2;
if (query)
- delete query;
+ delete query2;
hid = InsertHost(host);
}
return hid;
@@ -185,7 +185,7 @@ class ModuleSQLLog : public Module
long nickid = InsertNick(nick);
long sourceid = InsertNick(source);
long hostid = InsertHost(host);
- InsertEntry(category,nickid,hostid,sourceid,time(NULL));
+ InsertEntry((unsigned)category,(unsigned)nickid,(unsigned)hostid,(unsigned)sourceid,(unsigned long)time(NULL));
}
virtual void OnOper(userrec* user)