summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_cban.cpp17
-rw-r--r--src/modules/m_filter.h17
-rw-r--r--src/modules/m_svshold.cpp14
3 files changed, 24 insertions, 24 deletions
diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp
index 04a99674d..3b6c4eccd 100644
--- a/src/modules/m_cban.cpp
+++ b/src/modules/m_cban.cpp
@@ -202,20 +202,19 @@ class ModuleCBan : public Module
std::string EncodeCBan(const CBan &ban)
{
std::ostringstream stream;
- stream << ban.chname << " " << ban.set_by << " " << ban.set_on << " " << ban.length << " " << ban.reason;
- return stream.str();
+ stream << ban.chname << " " << ban.set_by << " " << ban.set_on << " " << ban.length << " :" << ban.reason;
+ return stream.str();
}
CBan DecodeCBan(const std::string &data)
{
CBan res;
- std::istringstream stream(data);
- stream >> res.chname;
- stream >> res.set_by;
- stream >> res.set_on;
- stream >> res.length;
- res.reason = stream.str();
-
+ irc::tokenstream tokens(data);
+ tokens.GetToken(res.chname);
+ tokens.GetToken(res.set_by);
+ tokens.GetToken(res.set_on);
+ tokens.GetToken(res.length);
+ tokens.GetToken(res.reason);
return res;
}
diff --git a/src/modules/m_filter.h b/src/modules/m_filter.h
index 6bf112107..f2986804c 100644
--- a/src/modules/m_filter.h
+++ b/src/modules/m_filter.h
@@ -402,28 +402,29 @@ std::string FilterBase::EncodeFilter(FilterResult* filter)
std::ostringstream stream;
std::string x = filter->freeform;
+ /* Hax to allow spaces in the freeform without changing the design of the irc protocol */
for (std::string::iterator n = x.begin(); n != x.end(); n++)
if (*n == ' ')
*n = '\7';
- stream << x << " " << filter->action << " " << (filter->flags.empty() ? "-" : filter->flags) << " " << filter->gline_time << " " << filter->reason;
+ stream << x << " " << filter->action << " " << (filter->flags.empty() ? "-" : filter->flags) << " " << filter->gline_time << " :" << filter->reason;
return stream.str();
}
FilterResult FilterBase::DecodeFilter(const std::string &data)
{
FilterResult res;
- std::istringstream stream(data);
-
- stream >> res.freeform;
- stream >> res.action;
- stream >> res.flags;
+ irc::tokenstream tokens(data);
+ tokens.GetToken(res.freeform);
+ tokens.GetToken(res.action);
+ tokens.GetToken(res.flags);
if (res.flags == "-")
res.flags = "";
res.FillFlags(res.flags);
- stream >> res.gline_time;
- res.reason = stream.str();
+ tokens.GetToken(res.gline_time);
+ tokens.GetToken(res.reason);
+ /* Hax to allow spaces in the freeform without changing the design of the irc protocol */
for (std::string::iterator n = res.freeform.begin(); n != res.freeform.end(); n++)
if (*n == '\7')
*n = ' ';
diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp
index 25df81f7b..7a164d920 100644
--- a/src/modules/m_svshold.cpp
+++ b/src/modules/m_svshold.cpp
@@ -238,19 +238,19 @@ class ModuleSVSHold : public Module
std::string EncodeSVSHold(const SVSHold* ban)
{
std::ostringstream stream;
- stream << ban->nickname << " " << ban->set_by << " " << ban->set_on << " " << ban->length << " " << ban->reason;
+ stream << ban->nickname << " " << ban->set_by << " " << ban->set_on << " " << ban->length << " :" << ban->reason;
return stream.str();
}
SVSHold* DecodeSVSHold(const std::string &data)
{
SVSHold* res = new SVSHold();
- std::istringstream stream(data);
- stream >> res->nickname;
- stream >> res->set_by;
- stream >> res->set_on;
- stream >> res->length;
- res->reason = stream.str();
+ irc::tokenstream tokens(data);
+ tokens.GetToken(res->nickname);
+ tokens.GetToken(res->set_by);
+ tokens.GetToken(res->set_on);
+ tokens.GetToken(res->length);
+ tokens.GetToken(res->reason);
return res;
}