summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorNaram Qashat <cyberbotx@cyberbotx.com>2010-06-27 23:15:05 -0400
committerNaram Qashat <cyberbotx@cyberbotx.com>2010-06-27 23:15:05 -0400
commit28e12bc24a9c85f4f0d1e37567618ec39cb501f6 (patch)
treecc70ebeef95a9d95174afe3ef038b0d673346f58 /src/modules
parent051ebe3eea0f8529b64c0e443c61103ba2f7dee8 (diff)
The next of a few "CBX OCDing over code style" commits, maybe the last.
NOTES: I have been unable to compile the db_mysql_* functions on my system here, so those are untested. db-convert seems to be badly programmed and needs more work in my opinion.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/cs_appendtopic.cpp30
-rw-r--r--src/modules/cs_enforce.cpp31
-rw-r--r--src/modules/cs_tban.cpp18
-rw-r--r--src/modules/hs_request.cpp81
-rw-r--r--src/modules/mysql/db_mysql.h16
-rw-r--r--src/modules/mysql/db_mysql_execute.cpp4
-rw-r--r--src/modules/mysql/db_mysql_read.cpp130
-rw-r--r--src/modules/mysql/db_mysql_write.cpp131
-rw-r--r--src/modules/ns_maxemail.cpp12
-rw-r--r--src/modules/os_info.cpp33
-rw-r--r--src/modules/ssl/m_ssl.cpp18
11 files changed, 177 insertions, 327 deletions
diff --git a/src/modules/cs_appendtopic.cpp b/src/modules/cs_appendtopic.cpp
index a1c84d0ab..03f20ba6c 100644
--- a/src/modules/cs_appendtopic.cpp
+++ b/src/modules/cs_appendtopic.cpp
@@ -12,8 +12,8 @@
* Send bug reports to the Anope Coder instead of the module
* author, because any changes since the inclusion into anope
* are not supported by the original author.
- *
*/
+
/*************************************************************************/
#include "module.h"
@@ -41,11 +41,13 @@
/* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */
/* ---------------------------------------------------------------------- */
-#define LNG_NUM_STRINGS 3
-
-#define LNG_CHAN_HELP 0
-#define LNG_CHAN_HELP_APPENDTOPIC 1
-#define LNG_APPENDTOPIC_SYNTAX 2
+enum
+{
+ LNG_CHAN_HELP,
+ LNG_CHAN_HELP_APPENDTOPIC,
+ LNG_APPENDTOPIC_SYNTAX,
+ LNG_NUM_STRINGS
+};
static Module *me;
@@ -96,20 +98,14 @@ class CommandCSAppendTopic : public Command
if (!check_access(u, ci, CA_TOPIC))
Alog() << Config.s_ChanServ << ": " << u->GetMask() << " changed topic of " << c->name << " as services admin.";
- if (ircd->join2set)
+ if (ircd->join2set && whosends(ci) == ChanServ)
{
- if (whosends(ci) == ChanServ)
- {
- ChanServ->Join(c);
- ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ); // XXX
- }
+ ChanServ->Join(c);
+ ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ); // XXX
}
ircdproto->SendTopic(whosends(ci), c, u->nick.c_str(), topic);
- if (ircd->join2set)
- {
- if (whosends(ci) == ChanServ)
- ChanServ->Part(c);
- }
+ if (ircd->join2set && whosends(ci) == ChanServ)
+ ChanServ->Part(c);
}
return MOD_CONT;
}
diff --git a/src/modules/cs_enforce.cpp b/src/modules/cs_enforce.cpp
index a3be24c7a..c4cfbecc9 100644
--- a/src/modules/cs_enforce.cpp
+++ b/src/modules/cs_enforce.cpp
@@ -17,14 +17,16 @@
#define AUTHOR "Anope"
-#define LNG_NUM_STRINGS 6
-
-#define LNG_CHAN_HELP 0
-#define LNG_ENFORCE_SYNTAX 1
-#define LNG_CHAN_HELP_ENFORCE 2
-#define LNG_CHAN_HELP_ENFORCE_R_ENABLED 3
-#define LNG_CHAN_HELP_ENFORCE_R_DISABLED 4
-#define LNG_CHAN_RESPONSE 5
+enum
+{
+ LNG_CHAN_HELP,
+ LNG_ENFORCE_SYNTAX,
+ LNG_CHAN_HELP_ENFORCE,
+ LNG_CHAN_HELP_ENFORCE_R_ENABLED,
+ LNG_CHAN_HELP_ENFORCE_R_DISABLED,
+ LNG_CHAN_RESPONSE,
+ LNG_NUM_STRINGS
+};
static Module *me;
@@ -71,7 +73,7 @@ class CommandCSEnforce : public Command
hadsecureops = true;
}
- for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it)
+ for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
UserContainer *uc = *it;
@@ -79,10 +81,7 @@ class CommandCSEnforce : public Command
}
if (hadsecureops)
- {
ci->UnsetFlag(CI_SECUREOPS);
- }
-
}
void DoRestricted(Channel *c)
@@ -101,7 +100,7 @@ class CommandCSEnforce : public Command
if (ci->levels[CA_NOJOIN] < 0)
ci->levels[CA_NOJOIN] = 0;
- for (CUserList::iterator it = c->users.begin(); it != c->users.end();)
+ for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
{
UserContainer *uc = *it++;
@@ -128,18 +127,16 @@ class CommandCSEnforce : public Command
Alog(LOG_DEBUG) << "[cs_enforce] Enforcing mode +R on " << c->name;
- for (CUserList::iterator it = c->users.begin(); it != c->users.end();)
+ for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
{
UserContainer *uc = *it++;
-
+
if (!uc->user->IsIdentified())
{
get_idealban(ci, uc->user, mask, sizeof(mask));
reason = getstring(uc->user, CHAN_NOT_ALLOWED_TO_JOIN);
if (!c->HasMode(CMODE_REGISTERED))
- {
c->SetMode(NULL, CMODE_BAN, mask);
- }
c->Kick(NULL, uc->user, "%s", reason);
}
}
diff --git a/src/modules/cs_tban.cpp b/src/modules/cs_tban.cpp
index 88e541ac8..844606222 100644
--- a/src/modules/cs_tban.cpp
+++ b/src/modules/cs_tban.cpp
@@ -12,7 +12,6 @@
* Send bug reports to the Anope Coder instead of the module
* author, because any changes since the inclusion into anope
* are not supported by the original author.
- *
*/
/*************************************************************************/
@@ -29,11 +28,14 @@ void mAddLanguages();
static Module *me = NULL;
-#define LANG_NUM_STRINGS 4
-#define TBAN_HELP 0
-#define TBAN_SYNTAX 1
-#define TBAN_HELP_DETAIL 2
-#define TBAN_RESPONSE 3
+enum
+{
+ TBAN_HELP,
+ TBAN_SYNTAX,
+ TBAN_HELP_DETAIL,
+ TBAN_RESPONSE,
+ LANG_NUM_STRINGS
+};
class CommandCSTBan : public Command
{
@@ -57,14 +59,12 @@ class CommandCSTBan : public Command
else if (!(u2 = finduser(nick)))
notice_lang(Config.s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
else
- {
if (canBanUser(c, u, u2))
{
get_idealban(c->ci, u2, mask, sizeof(mask));
addBan(c, dotime(time), mask);
mySendResponse(u, chan, mask, time);
}
- }
return MOD_CONT;
}
@@ -179,9 +179,7 @@ class TempBan : public CallBack
Channel *c;
if ((c = findchan(chan)) && c->ci)
- {
c->RemoveMode(NULL, CMODE_BAN, mask);
- }
}
};
diff --git a/src/modules/hs_request.cpp b/src/modules/hs_request.cpp
index 05e5969f2..5399140bc 100644
--- a/src/modules/hs_request.cpp
+++ b/src/modules/hs_request.cpp
@@ -25,29 +25,31 @@ int HSRequestMemoOper = 0;
int HSRequestMemoSetters = 0;
/* Language defines */
-#define LNG_NUM_STRINGS 21
-
-#define LNG_REQUEST_SYNTAX 0
-#define LNG_REQUESTED 1
-#define LNG_REQUEST_WAIT 2
-#define LNG_REQUEST_MEMO 3
-#define LNG_ACTIVATE_SYNTAX 4
-#define LNG_ACTIVATED 5
-#define LNG_ACTIVATE_MEMO 6
-#define LNG_REJECT_SYNTAX 7
-#define LNG_REJECTED 8
-#define LNG_REJECT_MEMO 9
-#define LNG_REJECT_MEMO_REASON 10
-#define LNG_NO_REQUEST 11
-#define LNG_HELP 12
-#define LNG_HELP_SETTER 13
-#define LNG_HELP_REQUEST 14
-#define LNG_HELP_ACTIVATE 15
-#define LNG_HELP_ACTIVATE_MEMO 16
-#define LNG_HELP_REJECT 17
-#define LNG_HELP_REJECT_MEMO 18
-#define LNG_WAITING_SYNTAX 19
-#define LNG_HELP_WAITING 20
+enum
+{
+ LNG_REQUEST_SYNTAX,
+ LNG_REQUESTED,
+ LNG_REQUEST_WAIT,
+ LNG_REQUEST_MEMO,
+ LNG_ACTIVATE_SYNTAX,
+ LNG_ACTIVATED,
+ LNG_ACTIVATE_MEMO,
+ LNG_REJECT_SYNTAX,
+ LNG_REJECTED,
+ LNG_REJECT_MEMO,
+ LNG_REJECT_MEMO_REASON,
+ LNG_NO_REQUEST,
+ LNG_HELP,
+ LNG_HELP_SETTER,
+ LNG_HELP_REQUEST,
+ LNG_HELP_ACTIVATE,
+ LNG_HELP_ACTIVATE_MEMO,
+ LNG_HELP_REJECT,
+ LNG_HELP_REJECT_MEMO,
+ LNG_WAITING_SYNTAX,
+ LNG_HELP_WAITING,
+ LNG_NUM_STRINGS
+};
void my_add_host_request(char *nick, char *vIdent, char *vhost, char *creator, time_t tmp_time);
int my_isvalidchar(const char c);
@@ -107,9 +109,7 @@ class CommandHSRequest : public Command
return MOD_CONT;
}
else
- {
for (s = vIdent; *s; ++s)
- {
if (!my_isvalidchar(*s))
{
notice_lang(Config.s_HostServ, u, HOST_SET_IDENT_ERROR);
@@ -118,8 +118,6 @@ class CommandHSRequest : public Command
delete [] hostmask;
return MOD_CONT;
}
- }
- }
if (!ircd->vident)
{
notice_lang(Config.s_HostServ, u, HOST_NO_VIDENT);
@@ -157,20 +155,17 @@ class CommandHSRequest : public Command
if ((na = findnick(nick)))
{
- if (HSRequestMemoOper || HSRequestMemoSetters)
+ if ((HSRequestMemoOper || HSRequestMemoSetters) && Config.MSSendDelay > 0 && u && u->lastmemosend + Config.MSSendDelay > now)
{
- if (Config.MSSendDelay > 0 && u && u->lastmemosend + Config.MSSendDelay > now)
+ me->NoticeLang(Config.s_HostServ, u, LNG_REQUEST_WAIT, Config.MSSendDelay);
+ u->lastmemosend = now;
+ if (vIdent)
{
- me->NoticeLang(Config.s_HostServ, u, LNG_REQUEST_WAIT, Config.MSSendDelay);
- u->lastmemosend = now;
- if (vIdent)
- {
- delete [] vIdent;
- delete [] rawhostmask;
- }
- delete [] hostmask;
- return MOD_CONT;
+ delete [] vIdent;
+ delete [] rawhostmask;
}
+ delete [] hostmask;
+ return MOD_CONT;
}
my_add_host_request(const_cast<char *>(nick), vIdent, hostmask, const_cast<char *>(u->nick.c_str()), now);
@@ -328,7 +323,7 @@ class HSListBase : public Command
unsigned display_counter = 0;
tm *tm;
- for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(); it != Requests.end(); ++it)
+ for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end; ++it)
{
HostRequest *hr = it->second;
if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < Config.NSListMax)
@@ -721,7 +716,7 @@ class HSRequest : public Module
void OnDatabaseWrite(void (*Write)(const std::string &))
{
- for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(); it != Requests.end(); ++it)
+ for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end; ++it)
{
HostRequest *hr = it->second;
std::stringstream buf;
@@ -779,7 +774,7 @@ void req_send_memos(User *u, char *vIdent, char *vHost)
{
int z = 2;
char host[BUFSIZE];
- std::list<std::pair<ci::string, ci::string> >::iterator it;
+ std::list<std::pair<ci::string, ci::string> >::iterator it, it_end;
if (vIdent)
snprintf(host, sizeof(host), "%s@%s", vIdent, vHost);
@@ -787,13 +782,11 @@ void req_send_memos(User *u, char *vIdent, char *vHost)
snprintf(host, sizeof(host), "%s", vHost);
if (HSRequestMemoOper == 1)
- {
- for (it = Config.Opers.begin(); it != Config.Opers.end(); ++it)
+ for (it = Config.Opers.begin(), it_end = Config.Opers.end(); it != it_end; ++it)
{
ci::string nick = it->first;
my_memo_lang(u, nick.c_str(), z, LNG_REQUEST_MEMO, host);
}
- }
if (HSRequestMemoSetters == 1)
{
/* Needs to be rethought because of removal of HostSetters in favor of opertype priv -- CyberBotX
diff --git a/src/modules/mysql/db_mysql.h b/src/modules/mysql/db_mysql.h
index f2885408f..34ae50931 100644
--- a/src/modules/mysql/db_mysql.h
+++ b/src/modules/mysql/db_mysql.h
@@ -1,3 +1,6 @@
+#ifndef DB_MYSQL_H
+#define DB_MYSQL_H
+
#include "module.h"
struct NickAliasFlagInfo
@@ -117,15 +120,15 @@ MemoFlagInfo MemoFlags[] = {
#define MYSQLPP_MYSQL_HEADERS_BURIED
#include <mysql++/mysql++.h>
-inline std::string SQLAssign(const mysqlpp::String& s) { return s.c_str(); }
+inline std::string SQLAssign(const mysqlpp::String &s) { return s.c_str(); }
class DBMySQL;
static DBMySQL *me;
-bool ExecuteQuery(mysqlpp::Query& query)
+bool ExecuteQuery(mysqlpp::Query &query)
{
Alog(LOG_DEBUG) << "MySQL: " << query.str();
-
+
if (!query.execute())
{
Alog() << "MySQL: error executing query: " << query.error();
@@ -135,15 +138,13 @@ bool ExecuteQuery(mysqlpp::Query& query)
return true;
}
-mysqlpp::StoreQueryResult StoreQuery(mysqlpp::Query& query)
+mysqlpp::StoreQueryResult StoreQuery(mysqlpp::Query &query)
{
Alog(LOG_DEBUG) << "MySQL: " << query.str();
mysqlpp::StoreQueryResult result = query.store();
if (!result)
- {
Alog() << "MySQL: error executing query: " << query.error();
- }
return result;
}
@@ -195,7 +196,7 @@ class DBMySQL : public Module
delete Con;
throw ModuleException(Error.c_str());
}
-
+
mysqlpp::Query query(Con);
query << "SET NAMES 'utf8'";
ExecuteQuery(query);
@@ -208,3 +209,4 @@ class DBMySQL : public Module
}
};
+#endif // DB_MYSQL_H
diff --git a/src/modules/mysql/db_mysql_execute.cpp b/src/modules/mysql/db_mysql_execute.cpp
index 2313edd37..2cc6ab6df 100644
--- a/src/modules/mysql/db_mysql_execute.cpp
+++ b/src/modules/mysql/db_mysql_execute.cpp
@@ -75,7 +75,7 @@ class SQLTimer : public Timer
if (qres && qres.num_rows())
{
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
User *u;
NickAlias *na = NULL;
@@ -149,7 +149,7 @@ class DBMySQLExecute : public DBMySQL
{
_SQLTimer = new SQLTimer();
}
-
+
~DBMySQLExecute()
{
delete _SQLTimer;
diff --git a/src/modules/mysql/db_mysql_read.cpp b/src/modules/mysql/db_mysql_read.cpp
index 3c5fb359a..3ffc82366 100644
--- a/src/modules/mysql/db_mysql_read.cpp
+++ b/src/modules/mysql/db_mysql_read.cpp
@@ -34,8 +34,7 @@ static void LoadDatabase()
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc = new NickCore(SQLAssign(qres[i]["display"]));
nc->pass = SQLAssign(qres[i]["pass"]);
@@ -51,28 +50,20 @@ static void LoadDatabase()
spacesepstream sep(SQLAssign(qres[i]["flags"]));
std::string buf;
while (sep.GetToken(buf))
- {
for (int j = 0; NickCoreFlags[j].Flag != -1; ++j)
- {
if (NickCoreFlags[j].Name == buf)
- {
nc->SetFlag(NickCoreFlags[j].Flag);
- }
- }
- }
nc->language = atoi(qres[i]["language"].c_str());
nc->channelcount = atoi(qres[i]["channelcount"].c_str());
nc->memos.memomax = atoi(qres[i]["memomax"].c_str());
}
- }
query << "SELECT * FROM `anope_ns_access`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc = findcore(qres[i]["display"].c_str());
if (!nc)
@@ -83,14 +74,12 @@ static void LoadDatabase()
nc->AddAccess(SQLAssign(qres[i]["access"]));
}
- }
query << "SELECT * FROM `anope_ns_core_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc = findcore(qres[i]["display"].c_str());
if (!nc)
@@ -102,14 +91,12 @@ static void LoadDatabase()
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(nc, SQLAssign(qres[i]["name"]), Params));
}
- }
query << "SELECT * FROM `anope_ns_alias`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc = findcore(qres[i]["display"].c_str());
if (!nc)
@@ -128,24 +115,16 @@ static void LoadDatabase()
spacesepstream sep(SQLAssign(qres[i]["flags"]));
std::string buf;
while (sep.GetToken(buf))
- {
for (int j = 0; NickAliasFlags[j].Flag != -1; ++j)
- {
if (NickAliasFlags[j].Name == buf)
- {
na->SetFlag(NickAliasFlags[j].Flag);
- }
- }
- }
}
- }
query << "SELECT * FROM `anope_ns_alias_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickAlias *na = findnick(SQLAssign(qres[i]["nick"]));
if (!na)
@@ -157,14 +136,12 @@ static void LoadDatabase()
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(na, SQLAssign(qres[i]["name"]), Params));
}
- }
query << "SELECT * FROM `anope_bs_core`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
BotInfo *bi = findbot(SQLAssign(qres[i]["nick"]));
if (!bi)
@@ -178,28 +155,22 @@ static void LoadDatabase()
spacesepstream sep(SQLAssign(qres[i]["flags"]));
std::string buf;
while (sep.GetToken(buf))
- {
for (unsigned j = 0; BotServFlags[j].Flag != -1; ++j)
- {
if (buf == BotServFlags[j].Name)
{
bi->SetFlag(BotServFlags[j].Flag);
break;
}
- }
- }
}
bi->created = atol(qres[i]["created"]);
bi->chancount = atol(qres[i]["chancount"]);
}
- }
query << "SELECT * FROM `anope_bs_info_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
BotInfo *bi = findbot(SQLAssign(qres[i]["botname"]));
if (!bi)
@@ -212,14 +183,12 @@ static void LoadDatabase()
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(bi, SQLAssign(qres[i]["name"]), Params));
}
- }
query << "SELECT * FROM `anope_cs_info`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc;
if (qres[i]["founder"].size())
@@ -254,16 +223,12 @@ static void LoadDatabase()
std::string buf;
spacesepstream sep(SQLAssign(qres[i]["flags"]));
while (sep.GetToken(buf))
- {
for (int j = 0; ChannelFlags[j].Flag != -1; ++j)
- {
if (buf == ChannelFlags[j].Name)
{
ci->SetFlag(ChannelFlags[j].Flag);
break;
}
- }
- }
}
if (qres[i]["forbidby"].size())
ci->forbidby = sstrdup(qres[i]["forbidby"].c_str());
@@ -316,16 +281,12 @@ static void LoadDatabase()
std::string buf;
spacesepstream sep(SQLAssign(qres[i]["botflags"]));
while (sep.GetToken(buf))
- {
for (int j = 0; BotFlags[j].Flag != -1; ++j)
- {
if (buf == BotFlags[j].Name)
{
ci->botflags.SetFlag(BotFlags[j].Flag);
break;
}
- }
- }
}
}
if (qres[i]["capsmin"].size())
@@ -339,14 +300,12 @@ static void LoadDatabase()
if (qres[i]["repeattimes"].size())
ci->repeattimes = atoi(qres[i]["repeattimes"].c_str());
}
- }
query << "SELECT * FROM `anope_cs_ttb";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -357,14 +316,12 @@ static void LoadDatabase()
ci->ttb[atoi(qres[i]["ttb_id"].c_str())] = atoi(qres[i]["value"].c_str());
}
- }
query << "SELECT * FROM `anope_bs_badwords`";
qres = StoreQuery(query);
-
+
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -372,7 +329,7 @@ static void LoadDatabase()
Alog() << "MySQL: Channel badwords entry for nonexistant channel " << qres[i]["channel"];
continue;
}
-
+
BadWordType BWTYPE = BW_ANY;
if (qres[i]["type"] == "SINGLE")
BWTYPE = BW_SINGLE;
@@ -382,14 +339,12 @@ static void LoadDatabase()
BWTYPE = BW_END;
ci->AddBadWord(SQLAssign(qres[i]["word"]), BWTYPE);
}
- }
query << "SELECT * FROM `anope_cs_access`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -406,14 +361,12 @@ static void LoadDatabase()
ci->AddAccess(nc, atoi(qres[i]["level"]), SQLAssign(qres[i]["creator"]), atol(qres[i]["last_seen"]));
}
- }
query << "SELECT * FROM `anope_cs_akick`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -426,12 +379,10 @@ static void LoadDatabase()
std::string flag, mask;
bool stuck = false;
while (sep.GetToken(flag))
- {
if (flag == "ISNICK")
nc = findcore(qres[i]["mask"]);
else if (flag == "STUCK")
stuck = true;
- }
AutoKick *ak;
if (nc)
ak = ci->AddAkick(SQLAssign(qres[i]["creator"]), nc, SQLAssign(qres[i]["reason"]), atol(qres[i]["created"].c_str()), atol(qres[i]["last_used"].c_str()));
@@ -442,14 +393,12 @@ static void LoadDatabase()
if (nc)
ak->SetFlag(AK_ISNICK);
}
- }
query << "SELECT * FROM `anope_cs_levels`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -459,14 +408,12 @@ static void LoadDatabase()
}
ci->levels[atoi(qres[i]["position"])] = atoi(qres[i]["level"]);
}
- }
query << "SELECT * FROM `anope_cs_info_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -474,19 +421,17 @@ static void LoadDatabase()
Alog() << "MySQL: Channel metadata for nonexistant channel " << qres[i]["channel"];
continue;
}
-
+
EventReturn MOD_RESULT;
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(ci, SQLAssign(qres[i]["name"]), Params));
}
- }
query << "SELECT * FROM `anope_ns_request`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickRequest *nr = new NickRequest(qres[i]["nick"].c_str());
nr->passcode = SQLAssign(qres[i]["passcode"]);
@@ -494,27 +439,23 @@ static void LoadDatabase()
nr->email = sstrdup(qres[i]["email"].c_str());
nr->requested = atol(qres[i]["requested"].c_str());
}
- }
EventReturn MOD_RESULT;
query << "SELECT * FROM `anope_extra`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
std::vector<std::string> params = MakeVector(SQLAssign(qres[i]["data"]));
FOREACH_RESULT(I_OnDatabaseRead, OnDatabaseRead(params));
}
- }
query << "SELECT * FROM `anope_ns_core_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc = findcore(qres[i]["nick"].c_str());
if (nc)
@@ -523,14 +464,12 @@ static void LoadDatabase()
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(nc, SQLAssign(qres[i]["name"]), params));
}
}
- }
query << "SELECT * FROM `anope_ns_alias_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickAlias *na = findnick(SQLAssign(qres[i]["nick"]));
if (na)
@@ -539,14 +478,12 @@ static void LoadDatabase()
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(na, SQLAssign(qres[i]["name"]), params));
}
}
- }
query << "SELECT * FROM `anope_cs_info_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (ci)
@@ -555,14 +492,12 @@ static void LoadDatabase()
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(ci, SQLAssign(qres[i]["name"]), params));
}
}
- }
query << "SELECT * FROM `anope_ms_info`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
MemoInfo *mi = NULL;
if (qres[i]["serv"] == "NICK")
@@ -592,37 +527,27 @@ static void LoadDatabase()
}
}
else
- {
m->number = 1;
- }
m->time = atol(qres[i]["time"].c_str());
m->text = sstrdup(qres[i]["text"].c_str());
-
+
if (qres[i]["flags"].size())
{
spacesepstream sep(SQLAssign(qres[i]["flags"]));
std::string buf;
while (sep.GetToken(buf))
- {
for (unsigned j = 0; MemoFlags[j].Flag != -1; ++j)
- {
if (MemoFlags[j].Name == buf)
- {
m->SetFlag(MemoFlags[j].Flag);
- }
- }
- }
}
}
}
- }
query << "SELECT * FROM `anope_os_akills`";
qres = StoreQuery(query);
if (qres && SGLine)
- {
- for (size_t i = 0; i < qres.size(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ci::string user = qres[i]["user"].c_str();
ci::string host = qres[i]["host"].c_str();
@@ -638,14 +563,12 @@ static void LoadDatabase()
x->Created = seton;
}
}
- }
query << "SELECT * FROM `anope_os_xlines`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.size(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ci::string mask = qres[i]["mask"].c_str();
ci::string by = qres[i]["xby"].c_str();
@@ -666,7 +589,6 @@ static void LoadDatabase()
x->Created = seton;
}
}
- }
}
class DBMySQLRead : public DBMySQL
diff --git a/src/modules/mysql/db_mysql_write.cpp b/src/modules/mysql/db_mysql_write.cpp
index b5686fa2f..c5c002a7e 100644
--- a/src/modules/mysql/db_mysql_write.cpp
+++ b/src/modules/mysql/db_mysql_write.cpp
@@ -7,12 +7,8 @@ static std::string BuildFlagsList(ChannelInfo *ci)
std::string ret;
for (int i = 0; ChannelFlags[i].Flag != -1; ++i)
- {
if (ci->HasFlag(ChannelFlags[i].Flag))
- {
ret += " " + ChannelFlags[i].Name;
- }
- }
if (!ret.empty())
ret.erase(ret.begin());
@@ -25,12 +21,8 @@ static std::string BuildFlagsList(NickAlias *na)
std::string ret;
for (int i = 0; NickAliasFlags[i].Flag != -1; ++i)
- {
if (na->HasFlag(NickAliasFlags[i].Flag))
- {
ret += " " + NickAliasFlags[i].Name;
- }
- }
if (!ret.empty())
ret.erase(ret.begin());
@@ -43,12 +35,8 @@ static std::string BuildFlagsList(NickCore *nc)
std::string ret;
for (int i = 0; NickCoreFlags[i].Flag != -1; ++i)
- {
if (nc->HasFlag(NickCoreFlags[i].Flag))
- {
ret += " " + NickCoreFlags[i].Name;
- }
- }
if (!ret.empty())
ret.erase(ret.begin());
@@ -61,16 +49,12 @@ static std::string BuildFlagsList(Memo *m)
std::string ret;
for (int i = 0; MemoFlags[i].Flag != -1; ++i)
- {
if (m->HasFlag(MemoFlags[i].Flag))
- {
ret += " " + MemoFlags[i].Name;
- }
- }
if (!ret.empty())
ret.erase(ret.begin());
-
+
return ret;
}
@@ -78,16 +62,14 @@ static std::string MakeMLock(ChannelInfo *ci, bool status)
{
std::string ret;
- for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
+ for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(), it_end = ModeManager::Modes.end(); it != it_end; ++it)
{
if ((*it)->Class == MC_CHANNEL)
{
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
if (ci->HasMLock(cm->Name, status))
- {
ret += " " + cm->NameAsString;
- }
}
}
@@ -111,17 +93,15 @@ static std::string GetMLockParams(ChannelInfo *ci)
{
std::string ret;
- for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
+ for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(), it_end = ModeManager::Modes.end(); it != it_end; ++it)
{
if ((*it)->Class == MC_CHANNEL)
{
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
-
+
std::string param;
if (ci->GetParam(cm->Name, param))
- {
ret += " " + cm->NameAsString + " " + param;
- }
}
}
@@ -136,12 +116,8 @@ static std::string GetBotFlags(Flags<BotServFlag>& Flags)
std::string buf;
for (int i = 0; BotFlags[i].Flag != -1; ++i)
- {
if (Flags.HasFlag(BotFlags[i].Flag))
- {
buf += " " + BotFlags[i].Name;
- }
- }
if (!buf.empty())
buf.erase(buf.begin());
@@ -154,16 +130,12 @@ static std::string GetBotServFlags(BotInfo *bi)
std::string buf;
for (int i = 0; BotServFlags[i].Flag != -1; ++i)
- {
if (bi->HasFlag(BotServFlags[i].Flag))
- {
buf += " " + BotServFlags[i].Name;
- }
- }
if (!buf.empty())
buf.erase(buf.begin());;
-
+
return buf;
}
@@ -200,7 +172,7 @@ void WriteCoreMetadata(const std::string &key, const std::string &data)
{
if (!CurCore)
throw CoreException("WritCoreMetadata without a core to write");
-
+
mysqlpp::Query query(me->Con);
query << "INSERT DELAYED INTO `anope_ns_core_metadata` (nick, name, value) VALUES(" << mysqlpp::quote << CurCore->display << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")";
ExecuteQuery(query);
@@ -220,7 +192,7 @@ void WriteBotMetadata(const std::string &key, const std::string &data)
{
if (!CurBot)
throw CoreException("WriteBotMetadata without a bot to write");
-
+
mysqlpp::Query query(me->Con);
query << "INSERT DELAYED INTO `anope_bs_info_metadata` (botname, name, value) VALUES(" << mysqlpp::quote << CurBot->nick << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")";
ExecuteQuery(query);
@@ -233,27 +205,25 @@ static void SaveDatabases()
query << "TRUNCATE TABLE `anope_ns_alias`";
ExecuteQuery(query);
- for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
- {
+ for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
me->OnNickRegister(it->second);
- }
query << "TRUNCATE TABLE `anope_ns_core`";
ExecuteQuery(query);
query << "TRUNCATE TABLE `anope_ms_info`";
ExecuteQuery(query);
-
- for (nickcore_map::const_iterator nit = NickCoreList.begin(); nit != NickCoreList.end(); ++nit)
+
+ for (nickcore_map::const_iterator nit = NickCoreList.begin(), nit_end = NickCoreList.end(); nit != nit_end; ++nit)
{
NickCore *nc = nit->second;
-
- for (std::vector<std::string>::iterator it = nc->access.begin(); it != nc->access.end(); ++it)
+
+ for (std::vector<std::string>::iterator it = nc->access.begin(), it_end = nc->access.end(); it != it_end; ++it)
{
query << "INSERT DELAYED INTO `anope_ns_access` (display, access) VALUES(" << mysqlpp::quote << nc->display << ", " << mysqlpp::quote << *it << ")";
ExecuteQuery(query);
}
- for (unsigned j = 0; j < nc->memos.memos.size(); ++j)
+ for (unsigned j = 0, end = nc->memos.memos.size(); j < end; ++j)
{
Memo *m = nc->memos.memos[j];
@@ -264,11 +234,9 @@ static void SaveDatabases()
query << "TRUNCATE TABLE `anope_bs_core`";
ExecuteQuery(query);
-
- for (botinfo_map::const_iterator it = BotListByNick.begin(); it != BotListByNick.end(); ++it)
- {
+
+ for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
me->OnBotCreate(it->second);
- }
query << "TRUNCATE TABLE `anope_cs_info`";
ExecuteQuery(query);
@@ -281,20 +249,20 @@ static void SaveDatabases()
query << "TRUNCATE TABLE `anope_cs_levels`";
ExecuteQuery(query);
- for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
{
ChannelInfo *ci = it->second;
-
+
me->OnChanRegistered(ci);
- for (unsigned j = 0; j < ci->GetBadWordCount(); ++j)
+ for (unsigned j = 0, end = ci->GetBadWordCount(); j < end; ++j)
{
BadWord *bw = ci->GetBadWord(j);
me->OnBadWordAdd(ci, bw);
}
- for (unsigned j = 0; j < ci->GetAccessCount(); ++j)
+ for (unsigned j = 0, end = ci->GetAccessCount(); j < end; ++j)
{
ChanAccess *access = ci->GetAccess(j);
@@ -302,20 +270,20 @@ static void SaveDatabases()
ExecuteQuery(query);
}
- for (unsigned j = 0; j < ci->GetAkickCount(); ++j)
+ for (unsigned j = 0, end = ci->GetAkickCount(); j < end; ++j)
{
AutoKick *ak = ci->GetAkick(j);
me->OnAkickAdd(NULL, ci, ak);
}
-
+
for (int k = 0; k < CA_SIZE; ++k)
{
query << "INSERT DELAYED INTO `anope_cs_levels` (channel, position, level) VALUES(" << mysqlpp::quote << ci->name << ", '" << k << "', '" << ci->levels[k] << "') ON DUPLICATE KEY UPDATE position=VALUES(position), level=VALUES(level)";
ExecuteQuery(query);
}
- for (unsigned j = 0; j < ci->memos.memos.size(); ++j)
+ for (unsigned j = 0, end = ci->memos.memos.size(); j < end; ++j)
{
Memo *m = ci->memos.memos[j];
@@ -326,42 +294,24 @@ static void SaveDatabases()
query << "TRUNCATE TABLE `anope_ns_request`";
ExecuteQuery(query);
- for (nickrequest_map::const_iterator it = NickRequestList.begin(); it != NickRequestList.end(); ++it)
- {
+ for (nickrequest_map::const_iterator it = NickRequestList.begin(), it_end = NickRequestList.end(); it != it_end; ++it)
me->OnMakeNickRequest(it->second);
- }
if (SGLine)
- {
- for (unsigned i = 0; i < SGLine->GetCount(); ++i)
- {
+ for (unsigned i = 0, end = SGLine->GetCount(); i < end; ++i)
me->OnAddAkill(NULL, SGLine->GetEntry(i));
- }
- }
if (SZLine)
- {
- for (unsigned i = 0; i < SZLine->GetCount(); ++i)
- {
+ for (unsigned i = 0, end = SZLine->GetCount(); i < end; ++i)
me->OnAddXLine(NULL, SZLine->GetEntry(i), X_SZLINE);
- }
- }
if (SQLine)
- {
- for (unsigned i = 0; i < SQLine->GetCount(); ++i)
- {
+ for (unsigned i = 0, end = SQLine->GetCount(); i < end; ++i)
me->OnAddXLine(NULL, SQLine->GetEntry(i), X_SQLINE);
- }
- }
if (SNLine)
- {
- for (unsigned i = 0; i < SNLine->GetCount(); ++i)
- {
+ for (unsigned i = 0, end = SNLine->GetCount(); i < end; ++i)
me->OnAddXLine(NULL, SNLine->GetEntry(i), X_SNLINE);
- }
- }
for (int i = 0; i < nexceptions; ++i)
{
@@ -408,7 +358,7 @@ class DBMySQLWrite : public DBMySQL
ModuleManager::Attach(I_OnServerConnect, this);
this->AddCommand(OperServ, new CommandSyncSQL("SQLSYNC"));
-
+
if (uplink_server)
OnServerConnect();
}
@@ -454,25 +404,25 @@ class DBMySQLWrite : public DBMySQL
query << maxusercnt << ", " << maxusertime << ", " << (SGLine ? SGLine->GetCount() : 0) << ", " << (SQLine ? SQLine->GetCount() : 0) << ", " << (SNLine ? SNLine->GetCount() : 0) << ", " << (SZLine ? SZLine->GetCount() : 0) << ")";
ExecuteQuery(query);
- for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
+ for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != end; ++it)
{
CurCore = it->second;
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteCoreMetadata, CurCore));
}
- for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
+ for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
{
CurNick = it->second;
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteNickMetadata, CurNick));
}
- for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChanelList.end(); it != it_end; ++it)
{
CurChannel = it->second;
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, CurChannel));
}
-
- for (botinfo_map::const_iterator it = BotListByNick.begin(); it != BotListByNick.end(); ++it)
+
+ for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
{
CurBot = it->second;
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteBotMetadata, CurBot));
@@ -608,8 +558,7 @@ class DBMySQLWrite : public DBMySQL
return;
if (!check_access(u, ci, CA_SET) && !u->Account()->HasPriv("botserv/administration"))
return;
- if (params[1] == "BADWORDS" || params[1] == "BOLDS" || params[1] == "CAPS" || params[1] == "COLORS"
- || params[1] == "FLOOD" || params[1] == "REPEAT" || params[1] == "REVERSES" || params[1] == "UNDERLINES")
+ if (params[1] == "BADWORDS" || params[1] == "BOLDS" || params[1] == "CAPS" || params[1] == "COLORS" || params[1] == "FLOOD" || params[1] == "REPEAT" || params[1] == "REVERSES" || params[1] == "UNDERLINES")
{
if (params[2] == "ON" || params[2] == "OFF")
{
@@ -654,8 +603,7 @@ class DBMySQLWrite : public DBMySQL
}
else if (!ci)
return;
- else if (params[1] == "DONTKICKOPS" || params[1] == "DONTKICKVOICES" || params[1] == "FANTASY" || params[1] == "GREET"
- || params[1] == "SYMBIOSIS" || params[1] == "NOBOT")
+ else if (params[1] == "DONTKICKOPS" || params[1] == "DONTKICKVOICES" || params[1] == "FANTASY" || params[1] == "GREET" || params[1] == "SYMBIOSIS" || params[1] == "NOBOT")
{
query << "UPDATE `anope_cs_info` SET `botflags` = '" << GetBotFlags(ci->botflags) << "' WHERE `name` = " << mysqlpp::quote << ci->name;
ExecuteQuery(query);
@@ -714,7 +662,7 @@ class DBMySQLWrite : public DBMySQL
{
OnNickRegister(findnick(u->nick));
}
-
+
void OnMakeNickRequest(NickRequest *nr)
{
mysqlpp::Query query(me->Con);
@@ -784,7 +732,7 @@ class DBMySQLWrite : public DBMySQL
void OnAccessAdd(ChannelInfo *ci, User *u, NickAlias *na, int level)
{
mysqlpp::Query query(me->Con);
- query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES (" << level << ", " << mysqlpp::quote << na->nc->display << ", " << mysqlpp::quote << ci->name << ", " << time(NULL) << ", " << mysqlpp::quote << u->nick << ")";
+ query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES (" << level << ", " << mysqlpp::quote << na->nc->display << ", " << mysqlpp::quote << ci->name << ", " << time(NULL) << ", " << mysqlpp::quote << u->nick << ")";
ExecuteQuery(query);
}
@@ -819,13 +767,11 @@ class DBMySQLWrite : public DBMySQL
ExecuteQuery(query);
}
else
- {
for (int i = 0; i < CA_SIZE; ++i)
{
query << "UPDATE `anope_cs_levels` SET `level` = " << ci->levels[i] << " WHERE `channel` = " << mysqlpp::quote << ci->name << " AND `position` = " << i;
ExecuteQuery(query);
}
- }
}
void OnChanForbidden(ChannelInfo *ci)
@@ -852,7 +798,7 @@ class DBMySQLWrite : public DBMySQL
query << "DELETE FROM `anope_bs_badwords` WHERE `channel` = " << mysqlpp::quote << ci->name;
ExecuteQuery(query);
}
-
+
void OnChanRegistered(ChannelInfo *ci)
{
mysqlpp::Query query(me->Con);
@@ -1092,4 +1038,3 @@ class DBMySQLWrite : public DBMySQL
};
MODULE_INIT(DBMySQLWrite)
-
diff --git a/src/modules/ns_maxemail.cpp b/src/modules/ns_maxemail.cpp
index 1d89a28e3..89ffd90da 100644
--- a/src/modules/ns_maxemail.cpp
+++ b/src/modules/ns_maxemail.cpp
@@ -23,9 +23,12 @@ bool check_email_limit_reached(const char *email, User * u);
int NSEmailMax = 0;
-#define LNG_NUM_STRINGS 2
-#define LNG_NSEMAILMAX_REACHED 0
-#define LNG_NSEMAILMAX_REACHED_ONE 1
+enum
+{
+ LNG_NSEMAILMAX_REACHED,
+ LNG_NSEMAILMAX_REACHED_ONE,
+ LNG_NUM_STRINGS
+};
static Module *me;
@@ -122,7 +125,6 @@ class NSMaxEmail : public Module
}
};
-
int count_email_in_use(const char *email, User * u)
{
int count = 0;
@@ -130,7 +132,7 @@ int count_email_in_use(const char *email, User * u)
if (!email)
return 0;
- for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
+ for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it)
{
NickCore *nc = it->second;
diff --git a/src/modules/os_info.cpp b/src/modules/os_info.cpp
index 1b4075f63..c9e98ecbc 100644
--- a/src/modules/os_info.cpp
+++ b/src/modules/os_info.cpp
@@ -12,7 +12,6 @@
* Send bug reports to the Anope Coder instead of the module
* author, because any changes since the inclusion into anope
* are not supported by the original author.
- *
*/
/*************************************************************************/
@@ -21,18 +20,20 @@
#define AUTHOR "Rob"
/* Multi-language stuff */
-#define LANG_NUM_STRINGS 10
-
-#define OINFO_SYNTAX 0
-#define OINFO_ADD_SUCCESS 1
-#define OINFO_DEL_SUCCESS 2
-#define OCINFO_SYNTAX 3
-#define OCINFO_ADD_SUCCESS 4
-#define OCINFO_DEL_SUCCESS 5
-#define OINFO_HELP 6
-#define OCINFO_HELP 7
-#define OINFO_HELP_CMD 8
-#define OCINFO_HELP_CMD 9
+enum
+{
+ OINFO_SYNTAX,
+ OINFO_ADD_SUCCESS,
+ OINFO_DEL_SUCCESS,
+ OCINFO_SYNTAX,
+ OCINFO_ADD_SUCCESS,
+ OCINFO_DEL_SUCCESS,
+ OINFO_HELP,
+ OCINFO_HELP,
+ OINFO_HELP_CMD,
+ OCINFO_HELP_CMD,
+ LANG_NUM_STRINGS
+};
/*************************************************************************/
@@ -425,14 +426,14 @@ class OSInfo : public Module
{
OnSaveDatabase();
- for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
+ for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it)
{
NickCore *nc = it->second;
nc->Shrink("os_info");
}
- for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
{
ChannelInfo *ci = it->second;
@@ -503,7 +504,7 @@ class OSInfo : public Module
{
ci->Shrink("os_info");
ci->Extend("os_info", new ExtensibleItemPointerArray<char>(sstrdup(params[0].c_str())));
-
+
return EVENT_STOP;
}
diff --git a/src/modules/ssl/m_ssl.cpp b/src/modules/ssl/m_ssl.cpp
index be3e5da1f..5bc9870da 100644
--- a/src/modules/ssl/m_ssl.cpp
+++ b/src/modules/ssl/m_ssl.cpp
@@ -2,6 +2,7 @@
#include "module.h"
+#define OPENSSL_NO_SHA512
#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
@@ -31,7 +32,7 @@ class SSLSocket : public Socket
SSLSocket(const std::string &nTargetHost, int nPort, const std::string &nBindHost = "", bool nIPv6 = false) : Socket(nTargetHost, nPort, nBindHost, nIPv6)
{
sslsock = SSL_new(ctx);
-
+
if (!sslsock)
throw CoreException("Unable to initialize SSL socket");
@@ -62,20 +63,13 @@ class SSLModule : public Module
public:
SSLModule(const std::string &modname, const std::string &creator) : Module(modname, creator)
{
- this->SetAuthor("Anope");
- this->SetVersion("$Id$");
- this->SetType(SUPPORTED);
- this->SetPermanent(true);
-
SSL_load_error_strings();
SSLeay_add_ssl_algorithms();
ctx = SSL_CTX_new(SSLv23_client_method());
if (!ctx)
- {
throw ModuleException("Error initializing SSL CTX");
- }
if (IsFile(CERTFILE))
{
@@ -86,9 +80,7 @@ class SSLModule : public Module
}
}
else
- {
Alog() << "m_ssl: No certificate file found";
- }
if (IsFile(KEYFILE))
{
@@ -106,11 +98,13 @@ class SSLModule : public Module
throw ModuleException("Error loading private key - file not found");
}
else
- {
Alog() << "m_ssl: No private key found";
- }
}
+ this->SetAuthor("Anope");
+ this->SetType(SUPPORTED);
+ this->SetPermanent(true);
+
SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2);
SSL_CTX_set_options(ctx, SSL_OP_TLS_ROLLBACK_BUG | SSL_OP_ALL);