]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Remove calls to strdup() in core, it is not better than std::string
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 2 Sep 2009 00:47:45 +0000 (00:47 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 2 Sep 2009 00:47:45 +0000 (00:47 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11623 e03df62e-2008-0410-955e-edbf42e46eb7

14 files changed:
include/commands/cmd_whowas.h
include/xline.h
src/commands/cmd_nick.cpp
src/commands/cmd_whowas.cpp
src/inspircd.cpp
src/modules/m_cban.cpp
src/modules/m_rline.cpp
src/modules/m_shun.cpp
src/modules/m_spanningtree/addline.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/netburst.cpp
src/modules/m_svshold.cpp
src/modules/m_xline_db.cpp
src/xline.cpp

index c2e83a63406807667ea8e6fb3c4d8776ace5cd2a..9788b3d335e598b5b97ccd4a05be0f01b9ab3479 100644 (file)
@@ -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;
index 8ac21f98841f61aebbb802148f492f94b07165fb..e2915e0247382a9a46e0997154964ae7bfd08b19 100644 (file)
@@ -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);
         }
index a926913753673dff7071090773cae9baac6b9525..44ccffbaccee5d8fbf217bda7c37ebcb05aeefcd 100644 (file)
@@ -98,9 +98,10 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& 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;
                        }
 
index 71b22807013a4b3f44001a01437e0cc540125ab7..e5542d16e19f82762ce8f7c1640970b5b741e885 100644 (file)
@@ -55,18 +55,19 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& 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 */
index b8192d3879f073bd2175f1783c19d2adb56710c8..cedb8a20e3874b540a9d688e182284c0f6702e4f 100644 (file)
@@ -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);
index 11bd32c8a03cdf484c975a0701a855829f50087f..a815cf35f602c8266b83ad91b26ebfb0e2af4cec 100644 (file)
@@ -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;
                }
 
index 824d6229a9258df687e2685b260fe0fb082c64c9..26c6f0ab8cdfc660b59ac4aed0e165cc223d3fd0 100644 (file)
@@ -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);
        }
index f4532ecd1b5befc0a3b0bb198779aa4090a1ef76..8a0ca2aa3b8634b86235ca1a1964093fbc175412 100644 (file)
@@ -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);
        }
index 858abe3a6445d45d5a2bf49f6cfd9526d159e3e5..fe7ef684511b919433bb6c1ca5673dc80ccc66d0 100644 (file)
@@ -50,7 +50,7 @@ bool TreeSocket::AddLine(const std::string &prefix, parameterlist &params)
        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)
        {
index 2ecbd8a88709f261bdec25cab12a75976d56011a..cb9d53b320a80720d7fdc56a35efc41d22832823 100644 (file)
@@ -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);
 
index eda627e3fad721481d5537bfce3668de40c31611..93e698dd4dfdaa8c55cd00ab4a1973dbc8a7ba19 100644 (file)
@@ -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);
                        }
                }
index 276fef038cab386c6695a06b738eb8ce689d5e11..eae168d6bdb08121042b5701dd60bf7cc613d5ba 100644 (file)
@@ -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;
                }
 
index d3a75a64cb301cea6ebbe95019405b897ecec07f..bde54a110a22c951c4d762d2d004f4e84a8c0918 100644 (file)
@@ -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))
index 0424e7a09ff7482f73c2b2ab0a8f3fe8cb25a5c9..33219b612014ffa726857e8bcdb1cd2e5d9d31b6 100644 (file)
@@ -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()