summaryrefslogtreecommitdiff
path: root/src/xline.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-09-19 13:44:09 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-09-19 13:44:09 +0000
commit89dc9ab19899e8bde4761da2e3f86194cf34fc21 (patch)
treec7b89f6b06c22164620cc0841feee35f4a747a11 /src/xline.cpp
parent136b8e0f8c75f61e063f9c4f0acdf0c139d0f892 (diff)
Make xline more memory-efficient and faster/neater. Eliminate a mass of fixed-size buffer and strlcpy
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5300 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/xline.cpp')
-rw-r--r--src/xline.cpp77
1 files changed, 11 insertions, 66 deletions
diff --git a/src/xline.cpp b/src/xline.cpp
index a0ac98df2..eb00eaee0 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -121,14 +121,7 @@ bool XLineManager::add_gline(long duration, const char* source,const char* reaso
bool ret = del_gline(hostmask);
- GLine item;
- item.duration = duration;
- strlcpy(item.identmask,ih.first.c_str(),19);
- strlcpy(item.hostmask,ih.second.c_str(),199);
- strlcpy(item.reason,reason,MAXBUF);
- strlcpy(item.source,source,255);
- item.n_matches = 0;
- item.set_time = ServerInstance->Time();
+ GLine item(ServerInstance->Time(), duration, source, reason, ih.first.c_str(), ih.second.c_str());
if (duration)
{
@@ -151,14 +144,8 @@ bool XLineManager::add_eline(long duration, const char* source, const char* reas
bool ret = del_eline(hostmask);
- ELine item;
- item.duration = duration;
- strlcpy(item.identmask,ih.first.c_str(),19);
- strlcpy(item.hostmask,ih.second.c_str(),199);
- strlcpy(item.reason,reason,MAXBUF);
- strlcpy(item.source,source,255);
- item.n_matches = 0;
- item.set_time = ServerInstance->Time();
+ ELine item(ServerInstance->Time(), duration, source, reason, ih.first.c_str(), ih.second.c_str());
+
if (duration)
{
elines.push_back(item);
@@ -176,14 +163,8 @@ bool XLineManager::add_eline(long duration, const char* source, const char* reas
bool XLineManager::add_qline(long duration, const char* source, const char* reason, const char* nickname)
{
bool ret = del_qline(nickname);
- QLine item;
- item.duration = duration;
- strlcpy(item.nick,nickname,63);
- strlcpy(item.reason,reason,MAXBUF);
- strlcpy(item.source,source,255);
- item.n_matches = 0;
- item.is_global = false;
- item.set_time = ServerInstance->Time();
+ QLine item(ServerInstance->Time(), duration, source, reason, nickname);
+
if (duration)
{
qlines.push_back(item);
@@ -201,20 +182,16 @@ bool XLineManager::add_qline(long duration, const char* source, const char* reas
bool XLineManager::add_zline(long duration, const char* source, const char* reason, const char* ipaddr)
{
bool ret = del_zline(ipaddr);
- ZLine item;
- item.duration = duration;
+
if (strchr(ipaddr,'@'))
{
while (*ipaddr != '@')
ipaddr++;
ipaddr++;
}
- strlcpy(item.ipaddr,ipaddr,39);
- strlcpy(item.reason,reason,MAXBUF);
- strlcpy(item.source,source,255);
- item.n_matches = 0;
- item.is_global = false;
- item.set_time = ServerInstance->Time();
+
+ ZLine item(ServerInstance->Time(), duration, source, reason, ipaddr);
+
if (duration)
{
zlines.push_back(item);
@@ -235,14 +212,8 @@ bool XLineManager::add_kline(long duration, const char* source, const char* reas
bool ret = del_kline(hostmask);
- KLine item;
- item.duration = duration;
- strlcpy(item.identmask,ih.first.c_str(),19);
- strlcpy(item.hostmask,ih.second.c_str(),200);
- strlcpy(item.reason,reason,MAXBUF);
- strlcpy(item.source,source,255);
- item.n_matches = 0;
- item.set_time = ServerInstance->Time();
+ KLine item(ServerInstance->Time(), duration, source, reason, ih.first.c_str(), ih.second.c_str());
+
if (duration)
{
klines.push_back(item);
@@ -326,32 +297,6 @@ bool XLineManager::del_qline(const char* nickname)
return false;
}
-bool XLineManager::qline_make_global(const char* nickname)
-{
- for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
- {
- if (!strcasecmp(nickname,i->nick))
- {
- i->is_global = true;
- return true;
- }
- }
- return false;
-}
-
-bool XLineManager::zline_make_global(const char* ipaddr)
-{
- for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
- {
- if (!strcasecmp(ipaddr,i->ipaddr))
- {
- i->is_global = true;
- return true;
- }
- }
- return false;
-}
-
// deletes a z:line, returns true if the line existed and was removed
bool XLineManager::del_zline(const char* ipaddr)