From: danieldg Date: Wed, 2 Sep 2009 00:47:45 +0000 (+0000) Subject: Remove calls to strdup() in core, it is not better than std::string X-Git-Tag: v2.0.23~1619 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=94bb5343b1464cbec9f58ee9d90a3deae3ac5308;p=user%2Fhenk%2Fcode%2Finspircd.git Remove calls to strdup() in core, it is not better than std::string git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11623 e03df62e-2008-0410-955e-edbf42e46eb7 --- diff --git a/include/commands/cmd_whowas.h b/include/commands/cmd_whowas.h index c2e83a634..9788b3d33 100644 --- a/include/commands/cmd_whowas.h +++ b/include/commands/cmd_whowas.h @@ -102,19 +102,19 @@ class WhoWasGroup : public classbase public: /** Real host */ - char* host; + std::string host; /** Displayed host */ - char* dhost; + std::string dhost; /** Ident */ - char* ident; + std::string ident; /** Server name */ const char* server; /** Fullname (GECOS) */ - char* gecos; + std::string gecos; /** Signon time */ time_t signon; diff --git a/include/xline.h b/include/xline.h index 8ac21f988..e2915e024 100644 --- a/include/xline.h +++ b/include/xline.h @@ -48,11 +48,9 @@ class CoreExport XLine : public classbase * @param re The reason of the xline * @param t The line type, should be set by the derived class constructor */ - XLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const std::string &t) - : ServerInstance(Instance), set_time(s_time), duration(d), type(t) + XLine(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, const std::string &t) + : ServerInstance(Instance), set_time(s_time), duration(d), source(src), reason(re), type(t) { - source = strdup(src); - reason = strdup(re); expiry = set_time + duration; } @@ -60,8 +58,6 @@ class CoreExport XLine : public classbase */ virtual ~XLine() { - free(reason); - free(source); } /** Change creation time of an xline. Updates expiry @@ -128,11 +124,11 @@ class CoreExport XLine : public classbase /** Source of the ban. This can be a servername or an oper nickname */ - char* source; + std::string source; /** Reason for the ban */ - char* reason; + std::string reason; /** Expiry time. Does not contain useful data if the duration is 0. */ @@ -160,10 +156,9 @@ class CoreExport KLine : public XLine * @param ident Ident to match * @param host Host to match */ - KLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* ident, const char* host) : XLine(Instance, s_time, d, src, re, "K") + KLine(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string ident, std::string host) + : XLine(Instance, s_time, d, src, re, "K"), identmask(ident), hostmask(host) { - identmask = strdup(ident); - hostmask = strdup(host); matchtext = this->identmask; matchtext.append("@").append(this->hostmask); } @@ -172,8 +167,6 @@ class CoreExport KLine : public XLine */ ~KLine() { - free(identmask); - free(hostmask); } virtual bool Matches(User *u); @@ -190,10 +183,10 @@ class CoreExport KLine : public XLine /** Ident mask (ident part only) */ - char* identmask; + std::string identmask; /** Host mask (host part only) */ - char* hostmask; + std::string hostmask; std::string matchtext; }; @@ -211,10 +204,9 @@ class CoreExport GLine : public XLine * @param ident Ident to match * @param host Host to match */ - GLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* ident, const char* host) : XLine(Instance, s_time, d, src, re, "G") + GLine(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string ident, std::string host) + : XLine(Instance, s_time, d, src, re, "G"), identmask(ident), hostmask(host) { - identmask = strdup(ident); - hostmask = strdup(host); matchtext = this->identmask; matchtext.append("@").append(this->hostmask); } @@ -223,8 +215,6 @@ class CoreExport GLine : public XLine */ ~GLine() { - free(identmask); - free(hostmask); } virtual bool Matches(User *u); @@ -239,10 +229,10 @@ class CoreExport GLine : public XLine /** Ident mask (ident part only) */ - char* identmask; + std::string identmask; /** Host mask (host part only) */ - char* hostmask; + std::string hostmask; std::string matchtext; }; @@ -260,18 +250,15 @@ class CoreExport ELine : public XLine * @param ident Ident to match * @param host Host to match */ - ELine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* ident, const char* host) : XLine(Instance, s_time, d, src, re, "E") + ELine(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string ident, std::string host) + : XLine(Instance, s_time, d, src, re, "E"), identmask(ident), hostmask(host) { - identmask = strdup(ident); - hostmask = strdup(host); matchtext = this->identmask; matchtext.append("@").append(this->hostmask); } ~ELine() { - free(identmask); - free(hostmask); } virtual bool Matches(User *u); @@ -288,10 +275,10 @@ class CoreExport ELine : public XLine /** Ident mask (ident part only) */ - char* identmask; + std::string identmask; /** Host mask (host part only) */ - char* hostmask; + std::string hostmask; std::string matchtext; }; @@ -308,16 +295,15 @@ class CoreExport ZLine : public XLine * @param re The reason of the xline * @param ip IP to match */ - ZLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* ip) : XLine(Instance, s_time, d, src, re, "Z") + ZLine(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string ip) + : XLine(Instance, s_time, d, src, re, "Z"), ipaddr(ip) { - ipaddr = strdup(ip); } /** Destructor */ ~ZLine() { - free(ipaddr); } virtual bool Matches(User *u); @@ -332,7 +318,7 @@ class CoreExport ZLine : public XLine /** IP mask (no ident part) */ - char* ipaddr; + std::string ipaddr; }; /** QLine class @@ -347,17 +333,15 @@ class CoreExport QLine : public XLine * @param re The reason of the xline * @param nickname Nickname to match */ - QLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* nickname) : XLine(Instance, s_time, d, src, re, "Q") + QLine(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string nickname) + : XLine(Instance, s_time, d, src, re, "Q"), nick(nickname) { - nick = strdup(nickname); } /** Destructor */ ~QLine() { - free(nick); - } virtual bool Matches(User *u); @@ -371,7 +355,7 @@ class CoreExport QLine : public XLine /** Nickname mask */ - char* nick; + std::string nick; }; /** Contains an ident and host split into two strings @@ -413,7 +397,7 @@ class CoreExport XLineFactory : public classbase * @param xline_specific_mask The mask string for the line, specific to the XLine type being created. * @return A specialized XLine class of the given type for this factory. */ - virtual XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) = 0; + virtual XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) = 0; virtual bool AutoApplyToUserList(XLine* x) { return true; } @@ -611,10 +595,10 @@ class CoreExport GLineFactory : public XLineFactory /** Generate a GLine */ - XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) + XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) { IdentHostPair ih = ServerInstance->XLines->IdentSplit(xline_specific_mask); - return new GLine(ServerInstance, set_time, duration, source, reason, ih.first.c_str(), ih.second.c_str()); + return new GLine(ServerInstance, set_time, duration, source, reason, ih.first, ih.second); } }; @@ -627,10 +611,10 @@ class CoreExport ELineFactory : public XLineFactory /** Generate an ELine */ - XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) + XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) { IdentHostPair ih = ServerInstance->XLines->IdentSplit(xline_specific_mask); - return new ELine(ServerInstance, set_time, duration, source, reason, ih.first.c_str(), ih.second.c_str()); + return new ELine(ServerInstance, set_time, duration, source, reason, ih.first, ih.second); } }; @@ -643,10 +627,10 @@ class CoreExport KLineFactory : public XLineFactory /** Generate a KLine */ - XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) + XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) { IdentHostPair ih = ServerInstance->XLines->IdentSplit(xline_specific_mask); - return new KLine(ServerInstance, set_time, duration, source, reason, ih.first.c_str(), ih.second.c_str()); + return new KLine(ServerInstance, set_time, duration, source, reason, ih.first, ih.second); } }; @@ -659,7 +643,7 @@ class CoreExport QLineFactory : public XLineFactory /** Generate a QLine */ - XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) + XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) { return new QLine(ServerInstance, set_time, duration, source, reason, xline_specific_mask); } @@ -674,7 +658,7 @@ class CoreExport ZLineFactory : public XLineFactory /** Generate a ZLine */ - XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) + XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) { return new ZLine(ServerInstance, set_time, duration, source, reason, xline_specific_mask); } diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp index a92691375..44ccffbac 100644 --- a/src/commands/cmd_nick.cpp +++ b/src/commands/cmd_nick.cpp @@ -98,9 +98,10 @@ CmdResult CommandNick::Handle (const std::vector& parameters, User { if (user->registered == REG_ALL) { - ServerInstance->SNO->WriteToSnoMask('x', "Q-Lined nickname %s from %s!%s@%s: %s", parameters[0].c_str(), user->nick.c_str(), user->ident.c_str(), user->host.c_str(), mq->reason); + ServerInstance->SNO->WriteToSnoMask('x', "Q-Lined nickname %s from %s!%s@%s: %s", + parameters[0].c_str(), user->nick.c_str(), user->ident.c_str(), user->host.c_str(), mq->reason.c_str()); } - user->WriteNumeric(432, "%s %s :Invalid nickname: %s",user->nick.c_str(), parameters[0].c_str(), mq->reason); + user->WriteNumeric(432, "%s %s :Invalid nickname: %s",user->nick.c_str(), parameters[0].c_str(), mq->reason.c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp index 71b228070..e5542d16e 100644 --- a/src/commands/cmd_whowas.cpp +++ b/src/commands/cmd_whowas.cpp @@ -55,18 +55,19 @@ CmdResult CommandWhowas::Handle (const std::vector& parameters, Use WhoWasGroup* u = *ux; time_t rawtime = u->signon; tm *timeinfo; - char b[MAXBUF]; + char b[25]; timeinfo = localtime(&rawtime); - /* XXX - 'b' could be only 25 chars long and then strlcpy() would terminate it for us too? */ - strlcpy(b,asctime(timeinfo),MAXBUF); + strncpy(b,asctime(timeinfo),24); b[24] = 0; - user->WriteNumeric(314, "%s %s %s %s * :%s",user->nick.c_str(),parameters[0].c_str(),u->ident,u->dhost,u->gecos); + user->WriteNumeric(314, "%s %s %s %s * :%s",user->nick.c_str(),parameters[0].c_str(), + u->ident.c_str(),u->dhost.c_str(),u->gecos.c_str()); if (user->HasPrivPermission("users/auspex")) - user->WriteNumeric(379, "%s %s :was connecting from *@%s", user->nick.c_str(), parameters[0].c_str(), u->host); + user->WriteNumeric(379, "%s %s :was connecting from *@%s", + user->nick.c_str(), parameters[0].c_str(), u->host.c_str()); if (*ServerInstance->Config->HideWhoisServer && !user->HasPrivPermission("servers/auspex")) user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), ServerInstance->Config->HideWhoisServer, b); @@ -315,25 +316,13 @@ CommandWhowas::~CommandWhowas() } } -WhoWasGroup::WhoWasGroup(User* user) : host(NULL), dhost(NULL), ident(NULL), server(NULL), gecos(NULL), signon(user->signon) +WhoWasGroup::WhoWasGroup(User* user) : host(user->host), dhost(user->dhost), ident(user->ident), + server(user->server), gecos(user->fullname), signon(user->signon) { - this->host = strdup(user->host.c_str()); - this->dhost = strdup(user->dhost.c_str()); - this->ident = strdup(user->ident.c_str()); - this->server = user->server; - this->gecos = strdup(user->fullname.c_str()); } WhoWasGroup::~WhoWasGroup() { - if (host) - free(host); - if (dhost) - free(dhost); - if (ident) - free(ident); - if (gecos) - free(gecos); } /* every hour, run this function which removes all entries older than Config->WhoWasMaxKeep */ diff --git a/src/inspircd.cpp b/src/inspircd.cpp index b8192d387..cedb8a20e 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -135,8 +135,8 @@ void InspIRCd::Cleanup() /* Delete objects dynamically allocated in constructor (destructor would be more appropriate, but we're likely exiting) */ /* Must be deleted before modes as it decrements modelines */ - DeleteZero(this->Users); DeleteZero(this->FakeClient); + DeleteZero(this->Users); DeleteZero(this->Modes); DeleteZero(this->XLines); DeleteZero(this->Parser); diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index 11bd32c8a..a815cf35f 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -23,9 +23,10 @@ class CBan : public XLine public: irc::string matchtext; - CBan(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char *ch) : XLine(Instance, s_time, d, src, re, "CBAN") + CBan(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string ch) + : XLine(Instance, s_time, d, src, re, "CBAN") { - this->matchtext = ch; + this->matchtext = ch.c_str(); } ~CBan() @@ -47,8 +48,9 @@ public: void DisplayExpiry() { - ServerInstance->SNO->WriteToSnoMask('x',"Removing expired CBan %s (set by %s %ld seconds ago)", this->matchtext.c_str(), this->source, (long int)(ServerInstance->Time() - this->set_time)); - ServerInstance->PI->SendSNONotice("x", "Removing expired CBan " + assign(this->matchtext) + " (set by " + std::string(this->source) + " " + ConvToStr(ServerInstance->Time() - this->set_time) + " seconds ago)"); + ServerInstance->SNO->WriteToSnoMask('x',"Removing expired CBan %s (set by %s %ld seconds ago)", + this->matchtext.c_str(), this->source.c_str(), (long int)(ServerInstance->Time() - this->set_time)); + ServerInstance->PI->SendSNONotice("x", "Removing expired CBan " + assign(this->matchtext) + " (set by " + this->source + " " + ConvToStr(ServerInstance->Time() - this->set_time) + " seconds ago)"); } const char* Displayable() @@ -66,7 +68,7 @@ class CBanFactory : public XLineFactory /** Generate a shun */ - XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) + XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) { return new CBan(ServerInstance, set_time, duration, source, reason, xline_specific_mask); } @@ -191,9 +193,10 @@ class ModuleCBan : public Module if (rl) { // Channel is banned. - user->WriteServ( "384 %s %s :Cannot join channel, CBANed (%s)", user->nick.c_str(), cname, rl->reason); - ServerInstance->SNO->WriteToSnoMask('a', "%s tried to join %s which is CBANed (%s)", user->nick.c_str(), cname, rl->reason); - ServerInstance->PI->SendSNONotice("A", user->nick + " tried to join " + std::string(cname) + " which is CBANed (" + std::string(rl->reason) + ")"); + user->WriteServ( "384 %s %s :Cannot join channel, CBANed (%s)", user->nick.c_str(), cname, rl->reason.c_str()); + ServerInstance->SNO->WriteToSnoMask('a', "%s tried to join %s which is CBANed (%s)", + user->nick.c_str(), cname, rl->reason.c_str()); + ServerInstance->PI->SendSNONotice("A", user->nick + " tried to join " + std::string(cname) + " which is CBANed (" + rl->reason + ")"); return 1; } diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 824d6229a..26c6f0ab8 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -32,7 +32,8 @@ class RLine : public XLine * @param regex Pattern to match with * @ */ - RLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* regexs) : XLine(Instance, s_time, d, src, re, "R") + RLine(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string regexs) + : XLine(Instance, s_time, d, src, re, "R") { matchtext = regexs; @@ -76,7 +77,8 @@ class RLine : public XLine void DisplayExpiry() { - ServerInstance->SNO->WriteToSnoMask('x',"Removing expired R-Line %s (set by %s %ld seconds ago)", this->matchtext.c_str(), this->source, (long int)(ServerInstance->Time() - this->set_time)); + ServerInstance->SNO->WriteToSnoMask('x',"Removing expired R-Line %s (set by %s %ld seconds ago)", + this->matchtext.c_str(), this->source.c_str(), (long int)(ServerInstance->Time() - this->set_time)); } const char* Displayable() @@ -101,7 +103,7 @@ class RLineFactory : public XLineFactory /** Generate a RLine */ - XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) + XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) { return new RLine(ServerInstance, set_time, duration, source, reason, xline_specific_mask); } diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index f4532ecd1..8a0ca2aa3 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -21,7 +21,8 @@ class Shun : public XLine public: std::string matchtext; - Shun(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char *shunmask) : XLine(Instance, s_time, d, src, re, "SHUN") + Shun(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string shunmask) + : XLine(Instance, s_time, d, src, re, "SHUN") { this->matchtext = shunmask; } @@ -56,7 +57,8 @@ public: void DisplayExpiry() { - ServerInstance->SNO->WriteToSnoMask('x',"Removing expired shun %s (set by %s %ld seconds ago)", this->matchtext.c_str(), this->source, (long int)(ServerInstance->Time() - this->set_time)); + ServerInstance->SNO->WriteToSnoMask('x',"Removing expired shun %s (set by %s %ld seconds ago)", + this->matchtext.c_str(), this->source.c_str(), (long int)(ServerInstance->Time() - this->set_time)); } const char* Displayable() @@ -74,7 +76,7 @@ class ShunFactory : public XLineFactory /** Generate a shun */ - XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) + XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) { return new Shun(ServerInstance, set_time, duration, source, reason, xline_specific_mask); } diff --git a/src/modules/m_spanningtree/addline.cpp b/src/modules/m_spanningtree/addline.cpp index 858abe3a6..fe7ef6845 100644 --- a/src/modules/m_spanningtree/addline.cpp +++ b/src/modules/m_spanningtree/addline.cpp @@ -50,7 +50,7 @@ bool TreeSocket::AddLine(const std::string &prefix, parameterlist ¶ms) XLine* xl = NULL; try { - xl = xlf->Generate(ServerInstance->Time(), atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); + xl = xlf->Generate(ServerInstance->Time(), atoi(params[4].c_str()), params[2], params[5], params[1]); } catch (ModuleException &e) { diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 2ecbd8a88..cb9d53b32 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -788,7 +788,7 @@ void ModuleSpanningTree::OnAddLine(User* user, XLine *x) char data[MAXBUF]; snprintf(data,MAXBUF,"%s %s %s %lu %lu :%s", x->type.c_str(), x->Displayable(), - ServerInstance->Config->ServerName, (unsigned long)x->set_time, (unsigned long)x->duration, x->reason); + ServerInstance->Config->ServerName, (unsigned long)x->set_time, (unsigned long)x->duration, x->reason.c_str()); parameterlist params; params.push_back(data); diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index eda627e3f..93e698dd4 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -193,10 +193,10 @@ void TreeSocket::SendXLines(TreeServer* Current) continue; snprintf(data,MAXBUF,":%s ADDLINE %s %s %s %lu %lu :%s",sn, it->c_str(), i->second->Displayable(), - i->second->source, + i->second->source.c_str(), (unsigned long)i->second->set_time, (unsigned long)i->second->duration, - i->second->reason); + i->second->reason.c_str()); this->WriteLine(data); } } diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index 276fef038..eae168d6b 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -23,9 +23,10 @@ class SVSHold : public XLine public: irc::string nickname; - SVSHold(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char *nick) : XLine(Instance, s_time, d, src, re, "SVSHOLD") + SVSHold(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string nick) + : XLine(Instance, s_time, d, src, re, "SVSHOLD") { - this->nickname = nick; + this->nickname = nick.c_str(); } ~SVSHold() @@ -48,7 +49,8 @@ public: void DisplayExpiry() { - ServerInstance->SNO->WriteToSnoMask('x',"Removing expired SVSHOLD %s (set by %s %ld seconds ago)", this->nickname.c_str(), this->source, (long int)(ServerInstance->Time() - this->set_time)); + ServerInstance->SNO->WriteToSnoMask('x',"Removing expired SVSHOLD %s (set by %s %ld seconds ago)", + this->nickname.c_str(), this->source.c_str(), (long int)(ServerInstance->Time() - this->set_time)); } const char* Displayable() @@ -66,7 +68,7 @@ class SVSHoldFactory : public XLineFactory /** Generate a shun */ - XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask) + XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) { return new SVSHold(ServerInstance, set_time, duration, source, reason, xline_specific_mask); } @@ -171,7 +173,7 @@ class ModuleSVSHold : public Module if (rl) { - user->WriteServ( "432 %s %s :Services reserved nickname: %s", user->nick.c_str(), newnick.c_str(), rl->reason); + user->WriteServ( "432 %s %s :Services reserved nickname: %s", user->nick.c_str(), newnick.c_str(), rl->reason.c_str()); return 1; } diff --git a/src/modules/m_xline_db.cpp b/src/modules/m_xline_db.cpp index d3a75a64c..bde54a110 100644 --- a/src/modules/m_xline_db.cpp +++ b/src/modules/m_xline_db.cpp @@ -118,7 +118,7 @@ class ModuleXLineDB : public Module { line = (*i); fprintf(f, "LINE %s %s %s %lu %lu :%s\n", line->type.c_str(), line->Displayable(), - ServerInstance->Config->ServerName, (unsigned long)line->set_time, (unsigned long)line->duration, line->reason); + ServerInstance->Config->ServerName, (unsigned long)line->set_time, (unsigned long)line->duration, line->reason.c_str()); } ServerInstance->Logs->Log("m_xline_db",DEBUG, "xlinedb: Finished writing XLines. Checking for error.."); @@ -191,7 +191,7 @@ class ModuleXLineDB : public Module while (tokens.GetToken(tmp) && (items < MAXPARAMETERS)) { - command_p[items] = tmp.c_str(); + command_p[items] = tmp; items++; } @@ -222,7 +222,7 @@ class ModuleXLineDB : public Module continue; } - XLine* xl = xlf->Generate(ServerInstance->Time(), atoi(command_p[5].c_str()), command_p[3].c_str(), command_p[6].c_str(), command_p[2].c_str()); + XLine* xl = xlf->Generate(ServerInstance->Time(), atoi(command_p[5].c_str()), command_p[3], command_p[6], command_p[2]); xl->SetCreateTime(atoi(command_p[4].c_str())); if (ServerInstance->XLines->AddLine(xl, NULL)) diff --git a/src/xline.cpp b/src/xline.cpp index 0424e7a09..33219b612 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -442,7 +442,7 @@ bool XLine::IsBurstable() void XLine::DefaultApply(User* u, const std::string &line, bool bancache) { char sreason[MAXBUF]; - snprintf(sreason, MAXBUF, "%s-Lined: %s", line.c_str(), this->reason); + snprintf(sreason, MAXBUF, "%s-Lined: %s", line.c_str(), this->reason.c_str()); if (*ServerInstance->Config->MoronBanner) u->WriteServ("NOTICE %s :*** %s", u->nick.c_str(), ServerInstance->Config->MoronBanner); @@ -481,7 +481,7 @@ bool KLine::Matches(User *u) void KLine::Apply(User* u) { - DefaultApply(u, "K", (strcmp(this->identmask, "*") == 0) ? true : false); + DefaultApply(u, "K", (this->identmask == "*") ? true : false); } bool GLine::Matches(User *u) @@ -503,7 +503,7 @@ bool GLine::Matches(User *u) void GLine::Apply(User* u) { - DefaultApply(u, "G", (strcmp(this->identmask, "*") == 0) ? true : false); + DefaultApply(u, "G", (this->identmask == "*") ? true : false); } bool ELine::Matches(User *u) @@ -599,27 +599,32 @@ void ELine::OnAdd() void ELine::DisplayExpiry() { - ServerInstance->SNO->WriteToSnoMask('x',"Removing expired E-Line %s@%s (set by %s %ld seconds ago)",this->identmask,this->hostmask,this->source,(long int)(ServerInstance->Time() - this->set_time)); + ServerInstance->SNO->WriteToSnoMask('x',"Removing expired E-Line %s@%s (set by %s %ld seconds ago)", + identmask.c_str(),hostmask.c_str(),source.c_str(),(long)(ServerInstance->Time() - this->set_time)); } void QLine::DisplayExpiry() { - ServerInstance->SNO->WriteToSnoMask('x',"Removing expired Q-Line %s (set by %s %ld seconds ago)",this->nick,this->source,(long int)(ServerInstance->Time() - this->set_time)); + ServerInstance->SNO->WriteToSnoMask('x',"Removing expired Q-Line %s (set by %s %ld seconds ago)", + nick.c_str(),source.c_str(),(long)(ServerInstance->Time() - this->set_time)); } void ZLine::DisplayExpiry() { - ServerInstance->SNO->WriteToSnoMask('x',"Removing expired Z-Line %s (set by %s %ld seconds ago)",this->ipaddr,this->source,(long int)(ServerInstance->Time() - this->set_time)); + ServerInstance->SNO->WriteToSnoMask('x',"Removing expired Z-Line %s (set by %s %ld seconds ago)", + ipaddr.c_str(),source.c_str(),(long)(ServerInstance->Time() - this->set_time)); } void KLine::DisplayExpiry() { - ServerInstance->SNO->WriteToSnoMask('x',"Removing expired K-Line %s@%s (set by %s %ld seconds ago)",this->identmask,this->hostmask,this->source,(long int)(ServerInstance->Time() - this->set_time)); + ServerInstance->SNO->WriteToSnoMask('x',"Removing expired K-Line %s@%s (set by %s %ld seconds ago)", + identmask.c_str(),hostmask.c_str(),source.c_str(),(long)(ServerInstance->Time() - this->set_time)); } void GLine::DisplayExpiry() { - ServerInstance->SNO->WriteToSnoMask('x',"Removing expired G-Line %s@%s (set by %s %ld seconds ago)",this->identmask,this->hostmask,this->source,(long int)(ServerInstance->Time() - this->set_time)); + ServerInstance->SNO->WriteToSnoMask('x',"Removing expired G-Line %s@%s (set by %s %ld seconds ago)", + identmask.c_str(),hostmask.c_str(),source.c_str(),(long)(ServerInstance->Time() - this->set_time)); } const char* ELine::Displayable() @@ -639,12 +644,12 @@ const char* GLine::Displayable() const char* ZLine::Displayable() { - return ipaddr; + return ipaddr.c_str(); } const char* QLine::Displayable() { - return nick; + return nick.c_str(); } bool KLine::IsBurstable()