diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-06-05 17:39:36 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-06-05 17:39:36 +0000 |
commit | c2993f666f8146e75b4039b2b7bffe3455a3ac61 (patch) | |
tree | 9672e7a956f241696a337acf9973309c4c2b1e16 /src | |
parent | d2717df5ef65c00bb43e1b775c7846af1625848a (diff) |
Sexeger!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7241 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd_eline.cpp | 9 | ||||
-rw-r--r-- | src/cmd_gline.cpp | 9 | ||||
-rw-r--r-- | src/cmd_kline.cpp | 9 | ||||
-rw-r--r-- | src/cmd_qline.cpp | 10 | ||||
-rw-r--r-- | src/cmd_zline.cpp | 9 | ||||
-rw-r--r-- | src/command_parse.cpp | 4 | ||||
-rw-r--r-- | src/modules/extra/m_filter_pcre.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_dccallow.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_dnsbl.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_filter.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_timedbans.cpp | 9 |
11 files changed, 35 insertions, 32 deletions
diff --git a/src/cmd_eline.cpp b/src/cmd_eline.cpp index c021f66ba..be78e3b35 100644 --- a/src/cmd_eline.cpp +++ b/src/cmd_eline.cpp @@ -38,17 +38,18 @@ CmdResult cmd_eline::Handle (const char** parameters, int pcnt, userrec *user) return CMD_FAILURE; } - if (ServerInstance->XLines->add_eline(ServerInstance->Duration(parameters[1]),user->nick,parameters[2],parameters[0])) + long duration = ServerInstance->Duration(parameters[1]); + if (ServerInstance->XLines->add_eline(duration,user->nick,parameters[2],parameters[0])) { - FOREACH_MOD(I_OnAddELine,OnAddELine(ServerInstance->Duration(parameters[1]), user, parameters[2], parameters[0])); + FOREACH_MOD(I_OnAddELine,OnAddELine(duration, user, parameters[2], parameters[0])); - if (!ServerInstance->Duration(parameters[1])) + if (!duration) { ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent E-line for %s.",user->nick,parameters[0]); } else { - time_t c_requires_crap = ServerInstance->Duration(parameters[1]) + ServerInstance->Time(); + time_t c_requires_crap = duration + ServerInstance->Time(); ServerInstance->SNO->WriteToSnoMask('x',"%s added timed E-line for %s, expires on %s",user->nick,parameters[0], ServerInstance->TimeString(c_requires_crap).c_str()); } diff --git a/src/cmd_gline.cpp b/src/cmd_gline.cpp index 608f93650..afec3889c 100644 --- a/src/cmd_gline.cpp +++ b/src/cmd_gline.cpp @@ -43,20 +43,21 @@ CmdResult cmd_gline::Handle (const char** parameters, int pcnt, userrec *user) return CMD_FAILURE; } - if (ServerInstance->XLines->add_gline(ServerInstance->Duration(parameters[1]),user->nick,parameters[2],parameters[0])) + long duration = ServerInstance->Duration(parameters[1]); + if (ServerInstance->XLines->add_gline(duration,user->nick,parameters[2],parameters[0])) { int to_apply = APPLY_GLINES; - FOREACH_MOD(I_OnAddGLine,OnAddGLine(ServerInstance->Duration(parameters[1]), user, parameters[2], parameters[0])); + FOREACH_MOD(I_OnAddGLine,OnAddGLine(duration, user, parameters[2], parameters[0])); - if (!ServerInstance->Duration(parameters[1])) + if (!duration) { ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent G-line for %s.",user->nick,parameters[0]); to_apply |= APPLY_PERM_ONLY; } else { - time_t c_requires_crap = ServerInstance->Duration(parameters[1]) + ServerInstance->Time(); + time_t c_requires_crap = duration + ServerInstance->Time(); ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires on %s",user->nick,parameters[0], ServerInstance->TimeString(c_requires_crap).c_str()); } diff --git a/src/cmd_kline.cpp b/src/cmd_kline.cpp index a72624342..eab027b70 100644 --- a/src/cmd_kline.cpp +++ b/src/cmd_kline.cpp @@ -43,20 +43,21 @@ CmdResult cmd_kline::Handle (const char** parameters, int pcnt, userrec *user) return CMD_FAILURE; } - if (ServerInstance->XLines->add_kline(ServerInstance->Duration(parameters[1]),user->nick,parameters[2],parameters[0])) + long duration = ServerInstance->Duration(parameters[1]); + if (ServerInstance->XLines->add_kline(duration,user->nick,parameters[2],parameters[0])) { int to_apply = APPLY_KLINES; - FOREACH_MOD(I_OnAddKLine,OnAddKLine(ServerInstance->Duration(parameters[1]), user, parameters[2], parameters[0])); + FOREACH_MOD(I_OnAddKLine,OnAddKLine(duration, user, parameters[2], parameters[0])); - if (!ServerInstance->Duration(parameters[1])) + if (!duration) { ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent K-line for %s.",user->nick,parameters[0]); to_apply |= APPLY_PERM_ONLY; } else { - time_t c_requires_crap = ServerInstance->Duration(parameters[1]) + ServerInstance->Time(); + time_t c_requires_crap = duration + ServerInstance->Time(); ServerInstance->SNO->WriteToSnoMask('x',"%s added timed K-line for %s, expires on %s",user->nick,parameters[0], ServerInstance->TimeString(c_requires_crap).c_str()); } diff --git a/src/cmd_qline.cpp b/src/cmd_qline.cpp index aa8933580..383f27756 100644 --- a/src/cmd_qline.cpp +++ b/src/cmd_qline.cpp @@ -38,19 +38,19 @@ CmdResult cmd_qline::Handle (const char** parameters, int pcnt, userrec *user) return CMD_FAILURE; } - if (ServerInstance->XLines->add_qline(ServerInstance->Duration(parameters[1]),user->nick,parameters[2],parameters[0])) + long duration = ServerInstance->Duration(parameters[1]); + if (ServerInstance->XLines->add_qline(duration,user->nick,parameters[2],parameters[0])) { int to_apply = APPLY_QLINES; - - FOREACH_MOD(I_OnAddQLine,OnAddQLine(ServerInstance->Duration(parameters[1]), user, parameters[2], parameters[0])); - if (!ServerInstance->Duration(parameters[1])) + FOREACH_MOD(I_OnAddQLine,OnAddQLine(duration, user, parameters[2], parameters[0])); + if (!duration) { to_apply |= APPLY_PERM_ONLY; ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Q-line for %s.",user->nick,parameters[0]); } else { - time_t c_requires_crap = ServerInstance->Duration(parameters[1]) + ServerInstance->Time(); + time_t c_requires_crap = duration + ServerInstance->Time(); ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s",user->nick,parameters[0], ServerInstance->TimeString(c_requires_crap).c_str()); } diff --git a/src/cmd_zline.cpp b/src/cmd_zline.cpp index 1f8076a77..443647208 100644 --- a/src/cmd_zline.cpp +++ b/src/cmd_zline.cpp @@ -38,19 +38,20 @@ CmdResult cmd_zline::Handle (const char** parameters, int pcnt, userrec *user) if (ServerInstance->IPMatchesEveryone(parameters[0],user)) return CMD_FAILURE; - if (ServerInstance->XLines->add_zline(ServerInstance->Duration(parameters[1]),user->nick,parameters[2],parameters[0])) + long duration = ServerInstance->Duration(parameters[1]); + if (ServerInstance->XLines->add_zline(duration,user->nick,parameters[2],parameters[0])) { int to_apply = APPLY_ZLINES; - FOREACH_MOD(I_OnAddZLine,OnAddZLine(ServerInstance->Duration(parameters[1]), user, parameters[2], parameters[0])); - if (!ServerInstance->Duration(parameters[1])) + FOREACH_MOD(I_OnAddZLine,OnAddZLine(duration, user, parameters[2], parameters[0])); + if (!duration) { to_apply |= APPLY_PERM_ONLY; ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Z-line for %s.",user->nick,parameters[0]); } else { - time_t c_requires_crap = ServerInstance->Duration(parameters[1]) + ServerInstance->Time(); + time_t c_requires_crap = duration + ServerInstance->Time(); ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s",user->nick,parameters[0], ServerInstance->TimeString(c_requires_crap).c_str()); } diff --git a/src/command_parse.cpp b/src/command_parse.cpp index c7f89e03b..d03cb9296 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -65,7 +65,7 @@ std::string InspIRCd::TimeString(time_t curtime) /** Refactored by Brain, Jun 2007. Much faster with some clever O(1) array * lookups and pointer maths. */ -long InspIRCd::Duration(const char* str) +long InspIRCd::Duration(const std::string &str) { unsigned char multiplier = 0; long total = 0; @@ -73,7 +73,7 @@ long InspIRCd::Duration(const char* str) long subtotal = 0; /* Iterate each item in the string, looking for number or multiplier */ - for (const char* i = str + strlen(str) - 1; i >= str; --i) + for (std::string::const_reverse_iterator i = str.rbegin(); i != str.rend(); ++i) { /* Found a number, queue it onto the current number */ if ((*i >= '0') && (*i <= '9')) diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp index c2cc1f40f..e25fd06bb 100644 --- a/src/modules/extra/m_filter_pcre.cpp +++ b/src/modules/extra/m_filter_pcre.cpp @@ -139,7 +139,7 @@ class ModuleFilterPCRE : public FilterBase std::string reason = MyConf.ReadValue("keyword", "reason", index); std::string action = MyConf.ReadValue("keyword", "action", index); std::string flags = MyConf.ReadValue("keyword", "flags", index); - long gline_time = ServerInstance->Duration(MyConf.ReadValue("keyword", "duration", index).c_str()); + long gline_time = ServerInstance->Duration(MyConf.ReadValue("keyword", "duration", index)); if (action.empty()) action = "none"; if (flags.empty()) diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index e875302b8..817057b87 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -161,7 +161,7 @@ class cmd_dccallow : public command_t long length; if (pcnt < 2) { - length = ServerInstance->Duration(default_length.c_str()); + length = ServerInstance->Duration(default_length); } else if (!atoi(parameters[1])) { diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 70cc40765..5d32a0adb 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -223,7 +223,7 @@ class ModuleDNSBL : public Module e->reason = MyConf->ReadValue("dnsbl", "reason", i); e->domain = MyConf->ReadValue("dnsbl", "domain", i); e->banaction = str2banaction(MyConf->ReadValue("dnsbl", "action", i)); - e->duration = ServerInstance->Duration(MyConf->ReadValue("dnsbl", "duration", i).c_str()); + e->duration = ServerInstance->Duration(MyConf->ReadValue("dnsbl", "duration", i)); e->bitmask = MyConf->ReadInteger("dnsbl", "bitmask", i, false); /* yeah, logic here is a little messy */ diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 8feb5be41..926b6b03e 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -106,7 +106,7 @@ class ModuleFilter : public FilterBase std::string reason = MyConf->ReadValue("keyword","reason",index); std::string do_action = MyConf->ReadValue("keyword","action",index); std::string flags = MyConf->ReadValue("keyword","flags",index); - long gline_time = ServerInstance->Duration(MyConf->ReadValue("keyword","duration",index).c_str()); + long gline_time = ServerInstance->Duration(MyConf->ReadValue("keyword","duration",index)); if (do_action.empty()) do_action = "none"; if (flags.empty()) diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 473785149..2f57a966c 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -67,14 +67,13 @@ class cmd_tban : public command_t } TimedBan T; std::string channelname = parameters[0]; - unsigned long expire = ServerInstance->Duration(parameters[1]) + time(NULL); - if (ServerInstance->Duration(parameters[1]) < 1) + long duration = ServerInstance->Duration(parameters[1]); + unsigned long expire = duration + time(NULL); + if (duration < 1) { user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid ban time"); return CMD_FAILURE; } - char duration[MAXBUF]; - snprintf(duration,MAXBUF,"%lu",ServerInstance->Duration(parameters[1])); std::string mask = parameters[2]; const char *setban[32]; setban[0] = parameters[0]; @@ -94,7 +93,7 @@ class cmd_tban : public command_t T.mask = mask; T.expire = expire; TimedBanList.push_back(T); - channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s added a timed ban on %s lasting for %s seconds.", channel->name, user->nick, mask.c_str(), duration); + channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s added a timed ban on %s lasting for %ld seconds.", channel->name, user->nick, mask.c_str(), duration); return CMD_SUCCESS; } return CMD_FAILURE; |