summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-06-09 12:32:34 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-06-09 12:32:34 +0000
commit52acbb466b84a1cd161b1c111f855d6f0419fff3 (patch)
tree75c047fe70b522a23699f9b2d74c868822850f3f /src/modules/m_spanningtree
parent0161215f42ccbfe45d1aef626f830d39486ef699 (diff)
A ton more clear() and empty() stuff thats been lingering on the long term todo for too long a term :p
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7264 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r--src/modules/m_spanningtree/main.cpp4
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp10
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp33
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp32
-rw-r--r--src/modules/m_spanningtree/utils.cpp14
5 files changed, 43 insertions, 50 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 99041dc0d..573126ad3 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -979,7 +979,7 @@ void ModuleSpanningTree::OnUserPart(userrec* user, chanrec* channel, const std::
{
std::deque<std::string> params;
params.push_back(channel->name);
- if (partmessage != "")
+ if (!partmessage.empty())
params.push_back(":"+partmessage);
Utils->DoOneToMany(user->nick,"PART",params);
}
@@ -1073,7 +1073,7 @@ void ModuleSpanningTree::OnRemoteKill(userrec* source, userrec* dest, const std:
void ModuleSpanningTree::OnRehash(userrec* user, const std::string &parameter)
{
- if (parameter != "")
+ if (!parameter.empty())
{
std::deque<std::string> params;
params.push_back(parameter);
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index 1eb1c7bfd..b5cac1802 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -31,9 +31,9 @@
TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance) : ServerInstance(Instance), Utils(Util)
{
Parent = NULL;
- ServerName = "";
- ServerDesc = "";
- VersionString = "";
+ ServerName.clear();
+ ServerDesc.clear();
+ VersionString.clear();
UserCount = OperCount = 0;
rtt = LastPing = 0;
Hidden = false;
@@ -47,7 +47,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance) : Server
TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc) : ServerInstance(Instance), ServerName(Name.c_str()), ServerDesc(Desc), Utils(Util)
{
Parent = NULL;
- VersionString = "";
+ VersionString.clear();
UserCount = ServerInstance->UserCount();
OperCount = ServerInstance->OperCount();
VersionString = ServerInstance->GetVersionString();
@@ -65,7 +65,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::str
TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, TreeServer* Above, TreeSocket* Sock, bool Hide)
: ServerInstance(Instance), Parent(Above), ServerName(Name.c_str()), ServerDesc(Desc), Socket(Sock), Utils(Util), Hidden(Hide)
{
- VersionString = "";
+ VersionString.clear();
UserCount = OperCount = 0;
this->SetNextPingTime(time(NULL) + 60);
this->SetPingFlag();
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index d1dad0914..168ca9e99 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -46,7 +46,8 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, std::string ho
{
myhost = host;
this->LinkState = LISTENER;
- theirchallenge = ourchallenge = "";
+ theirchallenge.clear();
+ ourchallenge.clear();
if (listening && Hook)
InspSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send();
}
@@ -55,7 +56,8 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, std::string ho
: InspSocket(SI, host, port, listening, maxtime, bindto), Utils(Util), Hook(HookMod)
{
myhost = ServerName;
- theirchallenge = ourchallenge = "";
+ theirchallenge.clear();
+ ourchallenge.clear();
this->LinkState = CONNECTING;
if (Hook)
InspSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send();
@@ -69,7 +71,8 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, int newfd, cha
: InspSocket(SI, newfd, ip), Utils(Util), Hook(HookMod)
{
this->LinkState = WAIT_AUTH_1;
- theirchallenge = ourchallenge = "";
+ theirchallenge.clear();
+ ourchallenge.clear();
/* If we have a transport module hooked to the parent, hook the same module to this
* socket, and set a timer waiting for handshake before we send CAPAB etc.
*/
@@ -274,7 +277,7 @@ void TreeSocket::SendServers(TreeServer* Current, TreeServer* s, int hops)
std::string TreeSocket::MyCapabilities()
{
std::vector<std::string> modlist;
- std::string capabilities = "";
+ std::string capabilities;
for (int i = 0; i <= this->Instance->GetModuleCount(); i++)
{
if (this->Instance->modules[i]->GetVersion().Flags & VF_COMMON)
@@ -386,7 +389,7 @@ std::string TreeSocket::ListDifference(const std::string &one, const std::string
{
irc::commasepstream list_one(one);
std::string item = "*";
- std::string result = "";
+ std::string result;
while ((item = list_one.GetToken()) != "")
{
if (!HasItem(two, item))
@@ -416,12 +419,12 @@ bool TreeSocket::Capab(const std::deque<std::string> &params)
}
if (params[0] == "START")
{
- this->ModuleList = "";
+ this->ModuleList.clear();
this->CapKeys.clear();
}
else if (params[0] == "END")
{
- std::string reason = "";
+ std::string reason;
int ip6support = 0;
#ifdef SUPPORT_IP6LINKS
ip6support = 1;
@@ -998,16 +1001,14 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c)
char list[MAXBUF];
std::string individual_halfops = std::string(":")+this->Instance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age);
- Instance->Log(DEBUG,"Sending FJOINs for %s", c->name);
-
size_t dlen, curlen;
dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->ServerName,c->name,(unsigned long)c->age);
int numusers = 0;
char* ptr = list + dlen;
CUList *ulist = c->GetUsers();
- std::string modes = "";
- std::string params = "";
+ std::string modes;
+ std::string params;
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
@@ -1021,7 +1022,6 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c)
if (curlen > (480-NICKMAX))
{
- Instance->Log(DEBUG,"Flushing FJOIN buffer: %s", list);
buffer.append(list).append("\r\n");
dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->ServerName,c->name,(unsigned long)c->age);
ptr = list + dlen;
@@ -1030,13 +1030,8 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c)
}
}
- Instance->Log(DEBUG,"%d users remaining to be flushed", list);
-
if (numusers)
- {
- Instance->Log(DEBUG,"Flushing final FJOIN buffer: %s", list);
buffer.append(list).append("\r\n");
- }
buffer.append(":").append(this->Instance->Config->ServerName).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(c->ChanModes(true)).append("\r\n");
@@ -1055,8 +1050,8 @@ void TreeSocket::SendFJoins(TreeServer* Current, chanrec* c)
{
/* Wrap at MAXMODES */
buffer.append(":").append(this->Instance->Config->ServerName).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params).append("\r\n");
- modes = "";
- params = "";
+ modes.clear();
+ params.clear();
linesize = 1;
}
}
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 7df022b85..02affd097 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -49,7 +49,7 @@ bool TreeSocket::Error(std::deque<std::string> &params)
{
if (params.size() < 1)
return false;
- this->Instance->SNO->WriteToSnoMask('l',"ERROR from %s: %s",(InboundServerName != "" ? InboundServerName.c_str() : myhost.c_str()),params[0].c_str());
+ this->Instance->SNO->WriteToSnoMask('l',"ERROR from %s: %s",(!InboundServerName.empty() ? InboundServerName.c_str() : myhost.c_str()),params[0].c_str());
/* we will return false to cause the socket to close. */
return false;
}
@@ -1182,7 +1182,7 @@ bool TreeSocket::ProcessLine(std::string &line)
*/
command = "MODE";
}
- std::string target = "";
+ std::string target;
/* Yes, know, this is a mess. Its reasonably fast though as we're
* working with std::string here.
*/
@@ -1254,7 +1254,7 @@ bool TreeSocket::ProcessLine(std::string &line)
}
else if (command == "PING")
{
- if (prefix == "")
+ if (prefix.empty())
prefix = this->GetName();
/*
* We just got a ping from a server that's bursting.
@@ -1276,7 +1276,7 @@ bool TreeSocket::ProcessLine(std::string &line)
}
else if (command == "PONG")
{
- if (prefix == "")
+ if (prefix.empty())
prefix = this->GetName();
/*
* We just got a pong from a server that's bursting.
@@ -1317,7 +1317,7 @@ bool TreeSocket::ProcessLine(std::string &line)
}
else if (command == "SVSNICK")
{
- if (prefix == "")
+ if (prefix.empty())
{
prefix = this->GetName();
}
@@ -1361,7 +1361,7 @@ bool TreeSocket::ProcessLine(std::string &line)
delete chan;
}
}
- if (this->InboundServerName != "")
+ if (!this->InboundServerName.empty())
{
sourceserv = this->InboundServerName;
}
@@ -1369,7 +1369,7 @@ bool TreeSocket::ProcessLine(std::string &line)
}
else if (command == "SVSJOIN")
{
- if (prefix == "")
+ if (prefix.empty())
{
prefix = this->GetName();
}
@@ -1386,7 +1386,7 @@ bool TreeSocket::ProcessLine(std::string &line)
else if (command == "OPERNOTICE")
{
std::string sourceserv = this->myhost;
- if (this->InboundServerName != "")
+ if (!this->InboundServerName.empty())
sourceserv = this->InboundServerName;
if (params.size() >= 1)
Instance->WriteOpers("*** From " + sourceserv + ": " + params[0]);
@@ -1395,7 +1395,7 @@ bool TreeSocket::ProcessLine(std::string &line)
else if (command == "MODENOTICE")
{
std::string sourceserv = this->myhost;
- if (this->InboundServerName != "")
+ if (!this->InboundServerName.empty())
sourceserv = this->InboundServerName;
if (params.size() >= 2)
{
@@ -1406,7 +1406,7 @@ bool TreeSocket::ProcessLine(std::string &line)
else if (command == "SNONOTICE")
{
std::string sourceserv = this->myhost;
- if (this->InboundServerName != "")
+ if (!this->InboundServerName.empty())
sourceserv = this->InboundServerName;
if (params.size() >= 2)
{
@@ -1420,10 +1420,8 @@ bool TreeSocket::ProcessLine(std::string &line)
Instance->XLines->apply_lines(Utils->lines_to_apply);
Utils->lines_to_apply = 0;
std::string sourceserv = this->myhost;
- if (this->InboundServerName != "")
- {
+ if (!this->InboundServerName.empty())
sourceserv = this->InboundServerName;
- }
this->Instance->SNO->WriteToSnoMask('l',"Received end of netburst from \2%s\2",sourceserv.c_str());
Event rmode((char*)sourceserv.c_str(), (Module*)Utils->Creator, "new_server");
@@ -1438,7 +1436,7 @@ bool TreeSocket::ProcessLine(std::string &line)
// this saves us having a huge ugly parser.
userrec* who = this->Instance->FindNick(prefix);
std::string sourceserv = this->myhost;
- if (this->InboundServerName != "")
+ if (!this->InboundServerName.empty())
{
sourceserv = this->InboundServerName;
}
@@ -1527,7 +1525,7 @@ bool TreeSocket::ProcessLine(std::string &line)
std::string TreeSocket::GetName()
{
std::string sourceserv = this->myhost;
- if (this->InboundServerName != "")
+ if (!this->InboundServerName.empty())
{
sourceserv = this->InboundServerName;
}
@@ -1551,7 +1549,7 @@ void TreeSocket::OnClose()
// If the connection is fully up (state CONNECTED)
// then propogate a netsplit to all peers.
std::string quitserver = this->myhost;
- if (this->InboundServerName != "")
+ if (!this->InboundServerName.empty())
{
quitserver = this->InboundServerName;
}
@@ -1561,7 +1559,7 @@ void TreeSocket::OnClose()
Squit(s,"Remote host closed the connection");
}
- if (quitserver != "")
+ if (!quitserver.empty())
{
this->Instance->SNO->WriteToSnoMask('l',"Connection to '\2%s\2' failed.",quitserver.c_str());
time_t server_uptime = Instance->Time() - this->age;
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 6c4001503..8b191fa03 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -409,7 +409,7 @@ void SpanningTreeUtilities::RefreshIPCache()
ValidIPs.clear();
for (std::vector<Link>::iterator L = LinkBlocks.begin(); L != LinkBlocks.end(); L++)
{
- if ((L->IPAddr != "") && (L->RecvPass != "") && (L->SendPass != "") && (L->Name != "") && (L->Port))
+ if ((!L->IPAddr.empty()) && (!L->RecvPass.empty()) && (!L->SendPass.empty()) && (!L->Name.empty()) && (L->Port))
{
ValidIPs.push_back(L->IPAddr);
@@ -468,7 +468,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
while ((portno = portrange.GetToken()))
{
if (IP == "*")
- IP = "";
+ IP.clear();
if ((!transport.empty()) && (hooks.find(transport.c_str()) == hooks.end()))
{
@@ -536,7 +536,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
/* Bugfix by brain, do not allow people to enter bad configurations */
if (L.Name != ServerInstance->Config->ServerName)
{
- if ((L.IPAddr != "") && (L.RecvPass != "") && (L.SendPass != "") && (L.Name != "") && (L.Port))
+ if ((!L.IPAddr.empty()) && (!L.RecvPass.empty()) && (!L.SendPass.empty()) && (!L.Name.empty()) && (L.Port))
{
ValidIPs.push_back(L.IPAddr);
@@ -583,19 +583,19 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
}
else
{
- if (L.IPAddr == "")
+ if (L.IPAddr.empty())
{
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', IP address not defined!",L.Name.c_str());
}
- else if (L.RecvPass == "")
+ else if (L.RecvPass.empty())
{
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', recvpass not defined!",L.Name.c_str());
}
- else if (L.SendPass == "")
+ else if (L.SendPass.empty())
{
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', sendpass not defined!",L.Name.c_str());
}
- else if (L.Name == "")
+ else if (L.Name.empty())
{
ServerInstance->Log(DEFAULT,"Invalid configuration, link tag without a name!");
}