summaryrefslogtreecommitdiff
path: root/src/modules/extra
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2006-04-06 02:25:20 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2006-04-06 02:25:20 +0000
commita7b0c26a4c56440e4bc5ddc6d3ecfeb36089dbb2 (patch)
treeba6da52898a7ce1e157bef549647664c5258fe48 /src/modules/extra
parentec48546cd05136c61f85d669a3dc49a874935a89 (diff)
Holy christ that was a LOT OF SPACES. TABS, USE THEM, LOVE THEM, APPRECIATE THEM - we now have no stupid spaces. This was mostly a mass find/replace, so some indentation may be stuffed. Minor issue, though.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3838 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra')
-rw-r--r--src/modules/extra/m_filter_pcre.cpp40
-rw-r--r--src/modules/extra/m_sql.cpp18
-rw-r--r--src/modules/extra/m_sqllog.cpp149
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp2
4 files changed, 115 insertions, 94 deletions
diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp
index ade243fb4..267fc71b4 100644
--- a/src/modules/extra/m_filter_pcre.cpp
+++ b/src/modules/extra/m_filter_pcre.cpp
@@ -95,10 +95,10 @@ class ModuleFilterPCRE : public Module
delete Conf;
}
- void Implements(char* List)
- {
- List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnRehash] = 1;
- }
+ void Implements(char* List)
+ {
+ List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnRehash] = 1;
+ }
// format of a config entry is <keyword pattern="^regexp$" reason="Some reason here" action="kill/block">
@@ -170,22 +170,22 @@ class ModuleFilterPCRE : public Module
}
Srv->Log(DEFAULT,std::string("m_filter_pcre: read configuration from ")+filterfile);
- filters.clear();
- for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
- {
- std::string pattern = MyConf->ReadValue("keyword","pattern",index);
- re = pcre_compile(pattern.c_str(),0,&error,&erroffset,NULL);
- if (!re)
- {
- log(DEFAULT,"Error in regular expression: %s at offset %d: %s\n", pattern.c_str(), erroffset, error);
- log(DEFAULT,"Regular expression %s not loaded.", pattern.c_str());
- }
- else
- {
- filters.push_back(re);
- log(DEFAULT,"Regular expression %s loaded.", pattern.c_str());
- }
- }
+ filters.clear();
+ for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
+ {
+ std::string pattern = MyConf->ReadValue("keyword","pattern",index);
+ re = pcre_compile(pattern.c_str(),0,&error,&erroffset,NULL);
+ if (!re)
+ {
+ log(DEFAULT,"Error in regular expression: %s at offset %d: %s\n", pattern.c_str(), erroffset, error);
+ log(DEFAULT,"Regular expression %s not loaded.", pattern.c_str());
+ }
+ else
+ {
+ filters.push_back(re);
+ log(DEFAULT,"Regular expression %s loaded.", pattern.c_str());
+ }
+ }
}
diff --git a/src/modules/extra/m_sql.cpp b/src/modules/extra/m_sql.cpp
index 515ce792d..ef3fbf21d 100644
--- a/src/modules/extra/m_sql.cpp
+++ b/src/modules/extra/m_sql.cpp
@@ -92,15 +92,15 @@ class SQLConnection
// the number of effected rows is returned in the return value.
unsigned long QueryCount(std::string query)
{
- int r = mysql_query(&connection, query.c_str());
- if (!r)
- {
- res = mysql_store_result(&connection);
- unsigned long rows = mysql_affected_rows(&connection);
- mysql_free_result(res);
- return rows;
- }
- return 0;
+ int r = mysql_query(&connection, query.c_str());
+ if (!r)
+ {
+ res = mysql_store_result(&connection);
+ unsigned long rows = mysql_affected_rows(&connection);
+ mysql_free_result(res);
+ return rows;
+ }
+ return 0;
}
// This method fetches a row, if available from the database. You must issue a query
diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp
index c9a86e9bc..845c3e0d9 100644
--- a/src/modules/extra/m_sqllog.cpp
+++ b/src/modules/extra/m_sqllog.cpp
@@ -57,8 +57,7 @@ class ModuleSQLLog : public Module
return (SQLModule);
}
- ModuleSQLLog(Server* Me)
- : Module::Module(Me)
+ ModuleSQLLog(Server* Me) : Module::Module(Me)
{
Srv = Me;
ReadConfig();
@@ -67,7 +66,7 @@ class ModuleSQLLog : public Module
void Implements(char* List)
{
List[I_OnRehash] = List[I_OnOper] = List[I_OnGlobalOper] = List[I_OnKill] = 1;
- List[I_OnPreCommand] = List[I_OnUserConnect] = List[I_OnGlobalConnect] = 1;
+ List[I_OnPreCommand] = List[I_OnUserConnect] = List[I_OnGlobalConnect] = 1;
List[I_OnUserQuit] = List[I_OnLoadModule] = 1;
}
@@ -79,40 +78,49 @@ class ModuleSQLLog : public Module
long InsertNick(const std::string &nick)
{
long nid = -1;
- SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,actor FROM ircd_log_actors WHERE actor='"+nick+"'");
- Request queryrequest((char*)query, this, SQLModule);
- SQLResult* result = (SQLResult*)queryrequest.Send();
- if (result->GetType() == SQL_OK)
- {
- SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,"");
- Request rowquery((char*)rowrequest, this, SQLModule);
- SQLResult* rowresult = (SQLResult*)rowquery.Send();
- if (rowresult->GetType() == SQL_ROW)
- {
- nid = atoi(rowresult->GetField("id").c_str());
- delete rowresult;
- }
- delete rowrequest;
- delete result;
- }
- query->SetQueryType(SQL_DONE);
- query->SetConnID(dbid);
- Request donerequest((char*)query, this, SQLModule);
- donerequest.Send();
- delete query;
+
+ SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,actor FROM ircd_log_actors WHERE actor='"+nick+"'");
+ Request queryrequest((char*)query, this, SQLModule);
+ SQLResult* result = (SQLResult*)queryrequest.Send();
+
+ if (result->GetType() == SQL_OK)
+ {
+ SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,"");
+ Request rowquery((char*)rowrequest, this, SQLModule);
+ SQLResult* rowresult = (SQLResult*)rowquery.Send();
+
+ if (rowresult->GetType() == SQL_ROW)
+ {
+ nid = atoi(rowresult->GetField("id").c_str());
+ delete rowresult;
+ }
+
+ delete rowrequest;
+ delete result;
+ }
+
+ query->SetQueryType(SQL_DONE);
+ query->SetConnID(dbid);
+ Request donerequest((char*)query, this, SQLModule);
+ donerequest.Send();
+ delete query;
+
if (nid < 1)
{
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: " + result2->GetError());
- }
+
+ if (result2->GetType() == SQL_ERROR)
+ {
+ Srv->Log(DEFAULT,"SQL log error: " + result2->GetError());
+ }
+
if (result2)
delete result;
if (query2)
delete query2;
+
nid = InsertNick(nick);
}
return nid;
@@ -121,61 +129,74 @@ class ModuleSQLLog : public Module
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('',%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();
+
if (result->GetType() == SQL_ERROR)
{
Srv->Log(DEFAULT,"SQL log error: " + result->GetError());
}
+
if (result)
delete result;
if (query)
delete query;
+
return;
}
long InsertHost(const std::string &host)
{
- long hid = -1;
- SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,hostname FROM ircd_log_hosts WHERE hostname='"+host+"'");
- Request queryrequest((char*)query, this, SQLModule);
- SQLResult* result = (SQLResult*)queryrequest.Send();
- if (result->GetType() == SQL_OK)
- {
- SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,"");
- Request rowquery((char*)rowrequest, this, SQLModule);
- SQLResult* rowresult = (SQLResult*)rowquery.Send();
- if (rowresult->GetType() == SQL_ROW)
- {
- hid = atoi(rowresult->GetField("id").c_str());
- delete rowresult;
- }
- delete rowrequest;
- delete result;
- }
- query->SetQueryType(SQL_DONE);
- query->SetConnID(dbid);
- Request donerequest((char*)query, this, SQLModule);
- donerequest.Send();
- delete query;
- if (hid < 1)
- {
- 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: " + result2->GetError());
- }
- if (result)
- delete result2;
+ long hid = -1;
+
+ SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,hostname FROM ircd_log_hosts WHERE hostname='"+host+"'");
+ Request queryrequest((char*)query, this, SQLModule);
+ SQLResult* result = (SQLResult*)queryrequest.Send();
+
+ if (result->GetType() == SQL_OK)
+ {
+ SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,"");
+ Request rowquery((char*)rowrequest, this, SQLModule);
+ SQLResult* rowresult = (SQLResult*)rowquery.Send();
+
+ if (rowresult->GetType() == SQL_ROW)
+ {
+ hid = atoi(rowresult->GetField("id").c_str());
+ delete rowresult;
+ }
+
+ delete rowrequest;
+ delete result;
+ }
+
+ query->SetQueryType(SQL_DONE);
+ query->SetConnID(dbid);
+ Request donerequest((char*)query, this, SQLModule);
+ donerequest.Send();
+ delete query;
+
+ if (hid < 1)
+ {
+ 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: " + result2->GetError());
+ }
+
+ if (result)
+ delete result2;
if (query)
delete query2;
- hid = InsertHost(host);
- }
- return hid;
+ hid = InsertHost(host);
+ }
+
+ return hid;
}
void AddLogEntry(int category, const std::string &nick, const std::string &host, const std::string &source)
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 109be1e3d..27e6e3f02 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -189,7 +189,7 @@ class ModuleSSLOpenSSL : public Module
{
log(DEFAULT, "m_ssl_openssl.so: Can't read CA list from ", cafile.c_str());
}
-
+
FILE* dhpfile = fopen(dhfile.c_str(), "r");
DH* ret;