summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2013-05-05 19:36:46 +0100
committerPeter Powell <petpow@saberuk.com>2013-05-21 22:11:27 +0100
commit48033e9b3a708f265c0bc2d62460a6cefa70dd45 (patch)
treef0f10444087fcf5b5c63c7ed1a672cb6ff550f5a
parent994787e907cee7f6ed1b8f0ddbec95900a0f470a (diff)
Convert XLine::Displayable to return a std::string.
-rw-r--r--include/xline.h14
-rw-r--r--src/modules/m_cban.cpp9
-rw-r--r--src/modules/m_rline.cpp4
-rw-r--r--src/modules/m_shun.cpp4
-rw-r--r--src/modules/m_spanningtree/netburst.cpp6
-rw-r--r--src/modules/m_svshold.cpp12
-rw-r--r--src/modules/m_xline_db.cpp8
-rw-r--r--src/xline.cpp26
8 files changed, 45 insertions, 38 deletions
diff --git a/include/xline.h b/include/xline.h
index 119e29dc1..5403a0933 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -107,9 +107,9 @@ class CoreExport XLine : public classbase
* in a form which can be used to construct an entire derived xline,
* even if it is stored differently internally (e.g. GLine stores the
* ident and host parts seperately but will still return ident\@host
- * for its Displayable() method)
+ * for its Displayable() method).
*/
- virtual const char* Displayable() = 0;
+ virtual const std::string& Displayable() = 0;
/** Called when the xline has just been added.
*/
@@ -176,7 +176,7 @@ class CoreExport KLine : public XLine
virtual void Apply(User* u);
- virtual const char* Displayable();
+ virtual const std::string& Displayable();
virtual bool IsBurstable();
@@ -222,7 +222,7 @@ class CoreExport GLine : public XLine
virtual void Apply(User* u);
- virtual const char* Displayable();
+ virtual const std::string& Displayable();
/** Ident mask (ident part only)
*/
@@ -266,7 +266,7 @@ class CoreExport ELine : public XLine
virtual void OnAdd();
- virtual const char* Displayable();
+ virtual const std::string& Displayable();
/** Ident mask (ident part only)
*/
@@ -307,7 +307,7 @@ class CoreExport ZLine : public XLine
virtual void Apply(User* u);
- virtual const char* Displayable();
+ virtual const std::string& Displayable();
/** IP mask (no ident part)
*/
@@ -342,7 +342,7 @@ class CoreExport QLine : public XLine
virtual void Apply(User* u);
- virtual const char* Displayable();
+ virtual const std::string& Displayable();
/** Nickname mask
*/
diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp
index 044aa45a5..5e629ed42 100644
--- a/src/modules/m_cban.cpp
+++ b/src/modules/m_cban.cpp
@@ -29,12 +29,15 @@
*/
class CBan : public XLine
{
-public:
+private:
+ std::string displaytext;
irc::string matchtext;
+public:
CBan(time_t s_time, long d, std::string src, std::string re, std::string ch)
: XLine(s_time, d, src, re, "CBAN")
{
+ this->displaytext = ch;
this->matchtext = ch.c_str();
}
@@ -51,9 +54,9 @@ public:
return false;
}
- const char* Displayable()
+ const std::string& Displayable()
{
- return matchtext.c_str();
+ return displaytext;
}
};
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp
index 161cd4d0f..aa96d4951 100644
--- a/src/modules/m_rline.cpp
+++ b/src/modules/m_rline.cpp
@@ -92,9 +92,9 @@ class RLine : public XLine
DefaultApply(u, "R", false);
}
- const char* Displayable()
+ const std::string& Displayable()
{
- return matchtext.c_str();
+ return matchtext;
}
std::string matchtext;
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index e7dc3086d..6da24208a 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -56,9 +56,9 @@ public:
return false;
}
- const char* Displayable()
+ const std::string& Displayable()
{
- return matchtext.c_str();
+ return matchtext;
}
};
diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp
index c22ad3acb..639a397c6 100644
--- a/src/modules/m_spanningtree/netburst.cpp
+++ b/src/modules/m_spanningtree/netburst.cpp
@@ -120,7 +120,6 @@ void TreeSocket::SendFJoins(Channel* c)
void TreeSocket::SendXLines()
{
char data[MAXBUF];
- const char* sn = ServerInstance->Config->GetSID().c_str();
std::vector<std::string> types = ServerInstance->XLines->GetAllTypes();
@@ -140,7 +139,10 @@ void TreeSocket::SendXLines()
if (!i->second->IsBurstable())
break;
- snprintf(data,MAXBUF,":%s ADDLINE %s %s %s %lu %lu :%s",sn, it->c_str(), i->second->Displayable(),
+ snprintf(data, MAXBUF, ":%s ADDLINE %s %s %s %lu %lu :%s",
+ ServerInstance->Config->GetSID().c_str(),
+ it->c_str(),
+ i->second->Displayable().c_str(),
i->second->source.c_str(),
(unsigned long)i->second->set_time,
(unsigned long)i->second->duration,
diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp
index bd80bb048..d35d5f3ba 100644
--- a/src/modules/m_svshold.cpp
+++ b/src/modules/m_svshold.cpp
@@ -30,12 +30,12 @@
class SVSHold : public XLine
{
public:
- irc::string nickname;
+ std::string nickname;
SVSHold(time_t s_time, long d, std::string src, std::string re, std::string nick)
: XLine(s_time, d, src, re, "SVSHOLD")
{
- this->nickname = nick.c_str();
+ this->nickname = nick;
}
bool Matches(User *u)
@@ -47,14 +47,12 @@ public:
bool Matches(const std::string &s)
{
- if (nickname == s)
- return true;
- return false;
+ return InspIRCd::Match(s, nickname);
}
- const char* Displayable()
+ const std::string& Displayable()
{
- return nickname.c_str();
+ return nickname;
}
};
diff --git a/src/modules/m_xline_db.cpp b/src/modules/m_xline_db.cpp
index 020095f7c..021f2e78d 100644
--- a/src/modules/m_xline_db.cpp
+++ b/src/modules/m_xline_db.cpp
@@ -125,8 +125,12 @@ class ModuleXLineDB : public Module
for (LookupIter i = lookup->begin(); i != lookup->end(); ++i)
{
XLine* line = i->second;
- fprintf(f, "LINE %s %s %s %lu %lu :%s\n", line->type.c_str(), line->Displayable(),
- ServerInstance->Config->ServerName.c_str(), (unsigned long)line->set_time, (unsigned long)line->duration, line->reason.c_str());
+ fprintf(f, "LINE %s %s %s %lu %lu :%s\n",
+ line->type.c_str(),
+ line->Displayable().c_str(),
+ ServerInstance->Config->ServerName.c_str(),
+ (unsigned long)line->set_time,
+ (unsigned long)line->duration, line->reason.c_str());
}
}
diff --git a/src/xline.cpp b/src/xline.cpp
index d347e3763..4bb9551ec 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -259,7 +259,7 @@ bool XLineManager::AddLine(XLine* line, User* user)
ContainerIter x = lookup_lines.find(line->type);
if (x != lookup_lines.end())
{
- LookupIter i = x->second.find(line->Displayable());
+ LookupIter i = x->second.find(line->Displayable().c_str());
if (i != x->second.end())
{
// XLine propagation bug was here, if the line to be added already exists and
@@ -281,7 +281,7 @@ bool XLineManager::AddLine(XLine* line, User* user)
if (xlf->AutoApplyToUserList(line))
pending_lines.push_back(line);
- lookup_lines[line->type][line->Displayable()] = line;
+ lookup_lines[line->type][line->Displayable().c_str()] = line;
line->OnAdd();
FOREACH_MOD(I_OnAddLine,OnAddLine(user, line));
@@ -692,32 +692,32 @@ void XLine::DisplayExpiry()
{
bool onechar = (type.length() == 1);
ServerInstance->SNO->WriteToSnoMask('x', "Removing expired %s%s %s (set by %s %ld seconds ago)",
- type.c_str(), (onechar ? "-Line" : ""), Displayable(), source.c_str(), (long)(ServerInstance->Time() - set_time));
+ type.c_str(), (onechar ? "-Line" : ""), Displayable().c_str(), source.c_str(), (long)(ServerInstance->Time() - set_time));
}
-const char* ELine::Displayable()
+const std::string& ELine::Displayable()
{
- return matchtext.c_str();
+ return matchtext;
}
-const char* KLine::Displayable()
+const std::string& KLine::Displayable()
{
- return matchtext.c_str();
+ return matchtext;
}
-const char* GLine::Displayable()
+const std::string& GLine::Displayable()
{
- return matchtext.c_str();
+ return matchtext;
}
-const char* ZLine::Displayable()
+const std::string& ZLine::Displayable()
{
- return ipaddr.c_str();
+ return ipaddr;
}
-const char* QLine::Displayable()
+const std::string& QLine::Displayable()
{
- return nick.c_str();
+ return nick;
}
bool KLine::IsBurstable()