X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodes%2Fcmode_b.cpp;h=e45f191f78d330a1ce280b9ec93f6827dc6611c3;hb=e6601069038c35c546fd3f3dce95024b0d13f1b4;hp=119660ff54aa25b713ed87c3c8db00cb8c5c4c63;hpb=6d03943426dcce76ba66567a9b18425a5ebb4c0c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp index 119660ff5..e45f191f7 100644 --- a/src/modes/cmode_b.cpp +++ b/src/modes/cmode_b.cpp @@ -1,16 +1,23 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2006 Craig Edwards * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "inspircd.h" #include #include @@ -25,7 +32,7 @@ #include "hashcomp.h" #include "modes/cmode_b.h" -ModeChannelBan::ModeChannelBan() : ModeHandler(NULL, 'b', PARAM_ALWAYS, MODETYPE_CHANNEL) +ModeChannelBan::ModeChannelBan() : ModeHandler(NULL, "ban", 'b', PARAM_ALWAYS, MODETYPE_CHANNEL) { list = true; } @@ -36,11 +43,11 @@ ModeAction ModeChannelBan::OnModeChange(User* source, User*, Channel* channel, s /* Call the correct method depending on wether we're adding or removing the mode */ if (adding) { - parameter = this->AddBan(source, parameter, channel, status); + this->AddBan(source, parameter, channel, status); } else { - parameter = this->DelBan(source, parameter, channel, status); + this->DelBan(source, parameter, channel, status); } /* If the method above 'ate' the parameter by reducing it to an empty string, then * it won't matter wether we return ALLOW or DENY here, as an empty string overrides @@ -98,21 +105,21 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan if ((!user) || (!chan)) { ServerInstance->Logs->Log("MODE",DEFAULT,"*** BUG *** AddBan was given an invalid parameter"); - dest = ""; + dest.clear(); return dest; } /* Attempt to tidy the mask */ ModeParser::CleanMask(dest); /* If the mask was invalid, we exit */ - if (dest == "") + if (dest.empty() || dest.length() > 250) return dest; long maxbans = chan->GetMaxBans(); - if (!IS_LOCAL(user) && ((unsigned)chan->bans.size() > (unsigned)maxbans)) + if (IS_LOCAL(user) && ((unsigned)chan->bans.size() >= (unsigned)maxbans)) { user->WriteServ("478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %ld)",user->nick.c_str(), chan->name.c_str(), chan->name.c_str(), maxbans); - dest = ""; + dest.clear(); return dest; } @@ -120,7 +127,7 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan FIRST_MOD_RESULT(OnAddBan, MOD_RESULT, (user,chan,dest)); if (MOD_RESULT == MOD_RES_DENY) { - dest = ""; + dest.clear(); return dest; } @@ -129,7 +136,7 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan if (i->data == dest) { /* dont allow a user to set the same ban twice */ - dest = ""; + dest.clear(); return dest; } } @@ -141,30 +148,15 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan return dest; } -ModePair ModeChannelBan::ModeSet(User*, User*, Channel* channel, const std::string ¶meter) -{ - for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++) - { - if (!strcasecmp(i->data.c_str(), parameter.c_str())) - { - return std::make_pair(true, i->data); - } - } - return std::make_pair(false, parameter); -} - std::string& ModeChannelBan::DelBan(User *user, std::string& dest, Channel *chan, int) { if ((!user) || (!chan)) { ServerInstance->Logs->Log("MODE",DEFAULT,"*** BUG *** TakeBan was given an invalid parameter"); - dest = ""; + dest.clear(); return dest; } - /* 'Clean' the mask, e.g. nick -> nick!*@* */ - ModeParser::CleanMask(dest); - for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++) { if (!strcasecmp(i->data.c_str(), dest.c_str())) @@ -173,14 +165,15 @@ std::string& ModeChannelBan::DelBan(User *user, std::string& dest, Channel *chan FIRST_MOD_RESULT(OnDelBan, MOD_RESULT, (user, chan, dest)); if (MOD_RESULT == MOD_RES_DENY) { - dest = ""; + dest.clear(); return dest; } + dest = i->data; chan->bans.erase(i); return dest; } } - dest = ""; + dest.clear(); return dest; }