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;
* @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;
}
*/
virtual ~XLine()
{
- free(reason);
- free(source);
}
/** Change creation time of an xline. Updates expiry
/** 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.
*/
* @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);
}
*/
~KLine()
{
- free(identmask);
- free(hostmask);
}
virtual bool Matches(User *u);
/** Ident mask (ident part only)
*/
- char* identmask;
+ std::string identmask;
/** Host mask (host part only)
*/
- char* hostmask;
+ std::string hostmask;
std::string matchtext;
};
* @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);
}
*/
~GLine()
{
- free(identmask);
- free(hostmask);
}
virtual bool Matches(User *u);
/** Ident mask (ident part only)
*/
- char* identmask;
+ std::string identmask;
/** Host mask (host part only)
*/
- char* hostmask;
+ std::string hostmask;
std::string matchtext;
};
* @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);
/** Ident mask (ident part only)
*/
- char* identmask;
+ std::string identmask;
/** Host mask (host part only)
*/
- char* hostmask;
+ std::string hostmask;
std::string matchtext;
};
* @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);
/** IP mask (no ident part)
*/
- char* ipaddr;
+ std::string ipaddr;
};
/** QLine class
* @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);
/** Nickname mask
*/
- char* nick;
+ std::string nick;
};
/** Contains an ident and host split into two strings
* @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; }
/** 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);
}
};
/** 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);
}
};
/** 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);
}
};
/** 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);
}
/** 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);
}
{
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;
}
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);
}
}
-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 */
/* 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);
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()
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()
/** 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);
}
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;
}
* @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;
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()
/** 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);
}
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;
}
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()
/** 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);
}
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)
{
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);
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);
}
}
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()
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()
/** 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);
}
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;
}
{
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..");
while (tokens.GetToken(tmp) && (items < MAXPARAMETERS))
{
- command_p[items] = tmp.c_str();
+ command_p[items] = tmp;
items++;
}
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))
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);
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)
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)
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()
const char* ZLine::Displayable()
{
- return ipaddr;
+ return ipaddr.c_str();
}
const char* QLine::Displayable()
{
- return nick;
+ return nick.c_str();
}
bool KLine::IsBurstable()