summaryrefslogtreecommitdiff
path: root/src/commands.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-17 02:14:44 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-17 02:14:44 +0000
commitbf6724c049ba0f156544c49aab2008d6280e5ffa (patch)
tree0c56caccf906b87575dfefe52acc526f38c1fc81 /src/commands.cpp
parent62a1eab66838294f2b88d5ea94c1678c167d6189 (diff)
Rewrite ConfigReader again
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11879 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/commands.cpp')
-rw-r--r--src/commands.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index db2074d87..1aeba2d80 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -21,15 +21,15 @@
bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user)
{
- char itrigger[MAXBUF];
long matches = 0;
- if (!Config->ConfValue("insane","trigger", 0, itrigger, MAXBUF))
- strlcpy(itrigger,"95.5",MAXBUF);
+ ConfigTag* insane = Config->ConfValue("insane");
- if (Config->ConfValueBool("insane","hostmasks", 0))
+ if (!insane || !insane->getBool("hostmasks"))
return false;
+ float itrigger = insane->getFloat("trigger", 95.5);
+
for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
{
if ((InspIRCd::Match(u->second->MakeHost(), mask, ascii_case_insensitive_map)) ||
@@ -43,7 +43,7 @@ bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user)
return false;
float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
- if (percent > (float)atof(itrigger))
+ if (percent > itrigger)
{
SNO->WriteToSnoMask('a', "\2WARNING\2: %s tried to set a G/K/E line mask of %s, which covers %.2f%% of the network!",user->nick.c_str(),mask.c_str(),percent);
return true;
@@ -53,15 +53,15 @@ bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user)
bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user)
{
- char itrigger[MAXBUF];
long matches = 0;
- if (!Config->ConfValue("insane","trigger",0,itrigger,MAXBUF))
- strlcpy(itrigger,"95.5",MAXBUF);
+ ConfigTag* insane = Config->ConfValue("insane");
- if (Config->ConfValueBool("insane","ipmasks",0))
+ if (!insane || !insane->getBool("ipmasks"))
return false;
+ float itrigger = insane->getFloat("trigger", 95.5);
+
for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
{
if (InspIRCd::Match(u->second->GetIPString(), ip, ascii_case_insensitive_map))
@@ -72,7 +72,7 @@ bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user)
return false;
float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
- if (percent > (float)atof(itrigger))
+ if (percent > itrigger)
{
SNO->WriteToSnoMask('a', "\2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick.c_str(),ip.c_str(),percent);
return true;
@@ -82,15 +82,15 @@ bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user)
bool InspIRCd::NickMatchesEveryone(const std::string &nick, User* user)
{
- char itrigger[MAXBUF];
long matches = 0;
- if (!Config->ConfValue("insane","trigger",0,itrigger,MAXBUF))
- strlcpy(itrigger,"95.5",MAXBUF);
+ ConfigTag* insane = Config->ConfValue("insane");
- if (Config->ConfValueBool("insane","nickmasks",0))
+ if (!insane || !insane->getBool("nickmasks"))
return false;
+ float itrigger = insane->getFloat("trigger", 95.5);
+
for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
{
if (InspIRCd::Match(u->second->nick, nick))
@@ -101,7 +101,7 @@ bool InspIRCd::NickMatchesEveryone(const std::string &nick, User* user)
return false;
float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
- if (percent > (float)atof(itrigger))
+ if (percent > itrigger)
{
SNO->WriteToSnoMask('a', "\2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick.c_str(),nick.c_str(),percent);
return true;