summaryrefslogtreecommitdiff
path: root/src/modes
diff options
context:
space:
mode:
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2007-07-16 17:14:45 +0000
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2007-07-16 17:14:45 +0000
commitbab14f0dd2345c9d7dcbc47c918563709e1ac094 (patch)
tree753a23cfc9fc08c6697e80b3e686f074aa911d85 /src/modes
parent3abff3a37550cc1d88dd4d1fd7ed526e89309a53 (diff)
'svn propset -R svn:eol-style CR *' Set to UNIX-style always. Binaries are auto skipped by svn.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7454 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modes')
-rw-r--r--src/modes/Makefile66
-rw-r--r--src/modes/cmode_b.cpp186
-rw-r--r--src/modes/cmode_h.cpp163
-rw-r--r--src/modes/cmode_i.cpp36
-rw-r--r--src/modes/cmode_k.cpp104
-rw-r--r--src/modes/cmode_l.cpp98
-rw-r--r--src/modes/cmode_m.cpp37
-rw-r--r--src/modes/cmode_n.cpp37
-rw-r--r--src/modes/cmode_o.cpp154
-rw-r--r--src/modes/cmode_p.cpp36
-rw-r--r--src/modes/cmode_s.cpp36
-rw-r--r--src/modes/cmode_t.cpp37
-rw-r--r--src/modes/cmode_v.cpp153
-rw-r--r--src/modes/umode_i.cpp46
-rw-r--r--src/modes/umode_n.cpp59
-rw-r--r--src/modes/umode_o.cpp50
-rw-r--r--src/modes/umode_s.cpp46
-rw-r--r--src/modes/umode_w.cpp47
18 files changed, 18 insertions, 1373 deletions
diff --git a/src/modes/Makefile b/src/modes/Makefile
index 8839168b7..1b7743649 100644
--- a/src/modes/Makefile
+++ b/src/modes/Makefile
@@ -1,65 +1 @@
-CC = i am cornholio
-CXXFLAGS = -I../../include ${FLAGS}
-
-all: umode_w.o umode_s.o umode_o.o umode_n.o umode_i.o cmode_v.o cmode_t.o cmode_s.o cmode_p.o cmode_o.o cmode_n.o cmode_m.o cmode_l.o cmode_k.o cmode_i.o cmode_h.o cmode_b.o modeclasses.a
-
-umode_w.o: umode_w.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_w.cpp
-
-umode_s.o: umode_s.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_s.cpp
-
-umode_o.o: umode_o.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_o.cpp
-
-umode_n.o: umode_n.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_n.cpp
-
-umode_i.o: umode_i.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_i.cpp
-
-cmode_v.o: cmode_v.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_v.cpp
-
-cmode_t.o: cmode_t.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_t.cpp
-
-cmode_s.o: cmode_s.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_s.cpp
-
-cmode_p.o: cmode_p.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_p.cpp
-
-cmode_o.o: cmode_o.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_o.cpp
-
-cmode_n.o: cmode_n.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_n.cpp
-
-cmode_m.o: cmode_m.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_m.cpp
-
-cmode_l.o: cmode_l.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_l.cpp
-
-cmode_k.o: cmode_k.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_k.cpp
-
-cmode_i.o: cmode_i.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_i.cpp
-
-cmode_h.o: cmode_h.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_h.cpp
-
-cmode_b.o: cmode_b.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
- $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_b.cpp
-
-modeclasses.a: umode_w.o umode_s.o umode_o.o umode_n.o umode_i.o cmode_v.o cmode_t.o cmode_s.o cmode_p.o cmode_o.o cmode_n.o cmode_m.o cmode_l.o cmode_k.o cmode_i.o cmode_h.o cmode_b.o
- @-rm -rf modeclasses.a
- ar r modeclasses.a *.o
- ranlib modeclasses.a
-
-clean:
- @-rm *.o
- @-rm modeclasses.a
-
+CC = i am cornholio CXXFLAGS = -I../../include ${FLAGS} all: umode_w.o umode_s.o umode_o.o umode_n.o umode_i.o cmode_v.o cmode_t.o cmode_s.o cmode_p.o cmode_o.o cmode_n.o cmode_m.o cmode_l.o cmode_k.o cmode_i.o cmode_h.o cmode_b.o modeclasses.a umode_w.o: umode_w.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_w.cpp umode_s.o: umode_s.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_s.cpp umode_o.o: umode_o.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_o.cpp umode_n.o: umode_n.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_n.cpp umode_i.o: umode_i.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c umode_i.cpp cmode_v.o: cmode_v.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_v.cpp cmode_t.o: cmode_t.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_t.cpp cmode_s.o: cmode_s.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_s.cpp cmode_p.o: cmode_p.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_p.cpp cmode_o.o: cmode_o.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_o.cpp cmode_n.o: cmode_n.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_n.cpp cmode_m.o: cmode_m.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_m.cpp cmode_l.o: cmode_l.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_l.cpp cmode_k.o: cmode_k.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_k.cpp cmode_i.o: cmode_i.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_i.cpp cmode_h.o: cmode_h.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_h.cpp cmode_b.o: cmode_b.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h $(CC) -pipe -I../../include $(FLAGS) -export-dynamic -c cmode_b.cpp modeclasses.a: umode_w.o umode_s.o umode_o.o umode_n.o umode_i.o cmode_v.o cmode_t.o cmode_s.o cmode_p.o cmode_o.o cmode_n.o cmode_m.o cmode_l.o cmode_k.o cmode_i.o cmode_h.o cmode_b.o @-rm -rf modeclasses.a ar r modeclasses.a *.o ranlib modeclasses.a clean: @-rm *.o @-rm modeclasses.a \ No newline at end of file
diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp
index e306f31f6..dbc2e925d 100644
--- a/src/modes/cmode_b.cpp
+++ b/src/modes/cmode_b.cpp
@@ -1,185 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include <string>
-#include <vector>
-#include "inspircd_config.h"
-#include "configreader.h"
-#include "hash_map.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modules.h"
-#include "inspstring.h"
-#include "hashcomp.h"
-#include "modes/cmode_b.h"
-
-ModeChannelBan::ModeChannelBan(InspIRCd* Instance) : ModeHandler(Instance, 'b', 1, 1, true, MODETYPE_CHANNEL, false)
-{
-}
-
-ModeAction ModeChannelBan::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- int status = channel->GetStatus(source);
- /* Call the correct method depending on wether we're adding or removing the mode */
- if (adding)
- {
- parameter = this->AddBan(source, parameter, channel, status);
- }
- else
- {
- parameter = 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
- * the return value and is always MODEACTION_DENY if the mode is supposed to have
- * a parameter.
- */
- return MODEACTION_ALLOW;
-}
-
-void ModeChannelBan::RemoveMode(chanrec* channel)
-{
- BanList copy;
- char moderemove[MAXBUF];
- userrec* n = new userrec(ServerInstance);
- n->SetFd(FD_MAGIC_NUMBER);
-
- for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
- {
- copy.push_back(*i);
- }
- for (BanList::iterator i = copy.begin(); i != copy.end(); i++)
- {
- sprintf(moderemove,"-%c",this->GetModeChar());
- const char* parameters[] = { channel->name, moderemove, i->data };
- ServerInstance->SendMode(parameters, 3, n);
- }
-
- delete n;
-}
-
-void ModeChannelBan::RemoveMode(userrec* user)
-{
-}
-
-void ModeChannelBan::DisplayList(userrec* user, chanrec* channel)
-{
- /* Display the channel banlist */
- for (BanList::reverse_iterator i = channel->bans.rbegin(); i != channel->bans.rend(); ++i)
- {
- user->WriteServ("367 %s %s %s %s %d",user->nick, channel->name, i->data, i->set_by, i->set_time);
- }
- user->WriteServ("368 %s %s :End of channel ban list",user->nick, channel->name);
- return;
-}
-
-std::string& ModeChannelBan::AddBan(userrec *user,std::string &dest,chanrec *chan,int status)
-{
- if ((!user) || (!chan))
- {
- ServerInstance->Log(DEFAULT,"*** BUG *** AddBan was given an invalid parameter");
- dest = "";
- return dest;
- }
-
- /* Attempt to tidy the mask */
- ModeParser::CleanMask(dest);
- /* If the mask was invalid, we exit */
- if (dest == "")
- return dest;
-
- long maxbans = chan->GetMaxBans();
- if ((unsigned)chan->bans.size() > (unsigned)maxbans)
- {
- user->WriteServ("478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %d)",user->nick, chan->name,chan->name,maxbans);
- dest = "";
- return dest;
- }
-
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnAddBan,OnAddBan(user,chan,dest));
- if (MOD_RESULT)
- {
- dest = "";
- return dest;
- }
-
- for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++)
- {
- if (!strcasecmp(i->data,dest.c_str()))
- {
- /* dont allow a user to set the same ban twice */
- dest = "";
- return dest;
- }
- }
-
- b.set_time = ServerInstance->Time();
- strlcpy(b.data,dest.c_str(),MAXBUF);
- if (*user->nick)
- {
- strlcpy(b.set_by,user->nick,NICKMAX-1);
- }
- else
- {
- strlcpy(b.set_by,ServerInstance->Config->ServerName,NICKMAX-1);
- }
- chan->bans.push_back(b);
- return dest;
-}
-
-ModePair ModeChannelBan::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
-{
- for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
- {
- if (!strcasecmp(i->data,parameter.c_str()))
- {
- return std::make_pair(true, i->data);
- }
- }
- return std::make_pair(false, parameter);
-}
-
-std::string& ModeChannelBan::DelBan(userrec *user,std::string& dest,chanrec *chan,int status)
-{
- if ((!user) || (!chan))
- {
- ServerInstance->Log(DEFAULT,"*** BUG *** TakeBan was given an invalid parameter");
- dest = "";
- 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,dest.c_str()))
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnDelBan,OnDelBan(user,chan,dest));
- if (MOD_RESULT)
- {
- dest = "";
- return dest;
- }
- chan->bans.erase(i);
- return dest;
- }
- }
- dest = "";
- return dest;
-}
-
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include <string> #include <vector> #include "inspircd_config.h" #include "configreader.h" #include "hash_map.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modules.h" #include "inspstring.h" #include "hashcomp.h" #include "modes/cmode_b.h" ModeChannelBan::ModeChannelBan(InspIRCd* Instance) : ModeHandler(Instance, 'b', 1, 1, true, MODETYPE_CHANNEL, false) { } ModeAction ModeChannelBan::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { int status = channel->GetStatus(source); /* Call the correct method depending on wether we're adding or removing the mode */ if (adding) { parameter = this->AddBan(source, parameter, channel, status); } else { parameter = 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 * the return value and is always MODEACTION_DENY if the mode is supposed to have * a parameter. */ return MODEACTION_ALLOW; } void ModeChannelBan::RemoveMode(chanrec* channel) { BanList copy; char moderemove[MAXBUF]; userrec* n = new userrec(ServerInstance); n->SetFd(FD_MAGIC_NUMBER); for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++) { copy.push_back(*i); } for (BanList::iterator i = copy.begin(); i != copy.end(); i++) { sprintf(moderemove,"-%c",this->GetModeChar()); const char* parameters[] = { channel->name, moderemove, i->data }; ServerInstance->SendMode(parameters, 3, n); } delete n; } void ModeChannelBan::RemoveMode(userrec* user) { } void ModeChannelBan::DisplayList(userrec* user, chanrec* channel) { /* Display the channel banlist */ for (BanList::reverse_iterator i = channel->bans.rbegin(); i != channel->bans.rend(); ++i) { user->WriteServ("367 %s %s %s %s %d",user->nick, channel->name, i->data, i->set_by, i->set_time); } user->WriteServ("368 %s %s :End of channel ban list",user->nick, channel->name); return; } std::string& ModeChannelBan::AddBan(userrec *user,std::string &dest,chanrec *chan,int status) { if ((!user) || (!chan)) { ServerInstance->Log(DEFAULT,"*** BUG *** AddBan was given an invalid parameter"); dest = ""; return dest; } /* Attempt to tidy the mask */ ModeParser::CleanMask(dest); /* If the mask was invalid, we exit */ if (dest == "") return dest; long maxbans = chan->GetMaxBans(); if ((unsigned)chan->bans.size() > (unsigned)maxbans) { user->WriteServ("478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %d)",user->nick, chan->name,chan->name,maxbans); dest = ""; return dest; } int MOD_RESULT = 0; FOREACH_RESULT(I_OnAddBan,OnAddBan(user,chan,dest)); if (MOD_RESULT) { dest = ""; return dest; } for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++) { if (!strcasecmp(i->data,dest.c_str())) { /* dont allow a user to set the same ban twice */ dest = ""; return dest; } } b.set_time = ServerInstance->Time(); strlcpy(b.data,dest.c_str(),MAXBUF); if (*user->nick) { strlcpy(b.set_by,user->nick,NICKMAX-1); } else { strlcpy(b.set_by,ServerInstance->Config->ServerName,NICKMAX-1); } chan->bans.push_back(b); return dest; } ModePair ModeChannelBan::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter) { for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++) { if (!strcasecmp(i->data,parameter.c_str())) { return std::make_pair(true, i->data); } } return std::make_pair(false, parameter); } std::string& ModeChannelBan::DelBan(userrec *user,std::string& dest,chanrec *chan,int status) { if ((!user) || (!chan)) { ServerInstance->Log(DEFAULT,"*** BUG *** TakeBan was given an invalid parameter"); dest = ""; 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,dest.c_str())) { int MOD_RESULT = 0; FOREACH_RESULT(I_OnDelBan,OnDelBan(user,chan,dest)); if (MOD_RESULT) { dest = ""; return dest; } chan->bans.erase(i); return dest; } } dest = ""; return dest; } \ No newline at end of file
diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp
index ecee93388..f2ffff665 100644
--- a/src/modes/cmode_h.cpp
+++ b/src/modes/cmode_h.cpp
@@ -1,162 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "configreader.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modules.h"
-#include "modes/cmode_h.h"
-
-ModeChannelHalfOp::ModeChannelHalfOp(InspIRCd* Instance) : ModeHandler(Instance, 'h', 1, 1, true, MODETYPE_CHANNEL, false, '%')
-{
-}
-
-unsigned int ModeChannelHalfOp::GetPrefixRank()
-{
- return HALFOP_VALUE;
-}
-
-ModePair ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
-{
- userrec* x = ServerInstance->FindNick(parameter);
- if (x)
- {
- if (channel->GetStatusFlags(x) & UCMODE_HOP)
- {
- return std::make_pair(true, x->nick);
- }
- else
- {
- return std::make_pair(false, parameter);
- }
- }
- return std::make_pair(false, parameter);
-}
-
-void ModeChannelHalfOp::RemoveMode(chanrec* channel)
-{
- CUList* list = channel->GetHalfoppedUsers();
- CUList copy;
- char moderemove[MAXBUF];
- userrec* n = new userrec(ServerInstance);
- n->SetFd(FD_MAGIC_NUMBER);
-
- for (CUList::iterator i = list->begin(); i != list->end(); i++)
- {
- userrec* n = i->first;
- copy.insert(std::make_pair(n,n->nick));
- }
- for (CUList::iterator i = copy.begin(); i != copy.end(); i++)
- {
- sprintf(moderemove,"-%c",this->GetModeChar());
- const char* parameters[] = { channel->name, moderemove, i->first->nick };
- ServerInstance->SendMode(parameters, 3, n);
- }
- delete n;
-}
-
-void ModeChannelHalfOp::RemoveMode(userrec* user)
-{
-}
-
-ModeAction ModeChannelHalfOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- /* If halfops are not enabled in the conf, we don't execute
- * anything in this class at all.
- */
- if (!ServerInstance->Config->AllowHalfop)
- {
- parameter = "";
- return MODEACTION_DENY;
- }
-
- int status = channel->GetStatus(source);
-
- /* Call the correct method depending on wether we're adding or removing the mode */
- if (adding)
- {
- parameter = this->AddHalfOp(source, parameter.c_str(), channel, status);
- }
- else
- {
- parameter = this->DelHalfOp(source, parameter.c_str(), 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
- * the return value and is always MODEACTION_DENY if the mode is supposed to have
- * a parameter.
- */
- if (parameter.length())
- return MODEACTION_ALLOW;
- else
- return MODEACTION_DENY;
-}
-
-std::string ModeChannelHalfOp::AddHalfOp(userrec *user,const char* dest,chanrec *chan,int status)
-{
- userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
-
- if (d)
- {
- if (IS_LOCAL(user))
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_HALFOP));
-
- if (MOD_RESULT == ACR_DENY)
- return "";
- if (MOD_RESULT == ACR_DEFAULT)
- {
- if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)))
- {
- user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name);
- return "";
- }
- }
- }
-
- return ServerInstance->Modes->Grant(d,chan,UCMODE_HOP);
- }
- return "";
-}
-
-std::string ModeChannelHalfOp::DelHalfOp(userrec *user,const char *dest,chanrec *chan,int status)
-{
- userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
-
- if (d)
- {
- if (IS_LOCAL(user))
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEHALFOP));
-
- if (MOD_RESULT == ACR_DENY)
- return "";
- if (MOD_RESULT == ACR_DEFAULT)
- {
- if ((user != d) && ((status < STATUS_OP) && (!ServerInstance->ULine(user->server))))
- {
- user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name);
- return "";
- }
- }
- }
-
- return ServerInstance->Modes->Revoke(d,chan,UCMODE_HOP);
- }
- return "";
-}
-
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "configreader.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modules.h" #include "modes/cmode_h.h" ModeChannelHalfOp::ModeChannelHalfOp(InspIRCd* Instance) : ModeHandler(Instance, 'h', 1, 1, true, MODETYPE_CHANNEL, false, '%') { } unsigned int ModeChannelHalfOp::GetPrefixRank() { return HALFOP_VALUE; } ModePair ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter) { userrec* x = ServerInstance->FindNick(parameter); if (x) { if (channel->GetStatusFlags(x) & UCMODE_HOP) { return std::make_pair(true, x->nick); } else { return std::make_pair(false, parameter); } } return std::make_pair(false, parameter); } void ModeChannelHalfOp::RemoveMode(chanrec* channel) { CUList* list = channel->GetHalfoppedUsers(); CUList copy; char moderemove[MAXBUF]; userrec* n = new userrec(ServerInstance); n->SetFd(FD_MAGIC_NUMBER); for (CUList::iterator i = list->begin(); i != list->end(); i++) { userrec* n = i->first; copy.insert(std::make_pair(n,n->nick)); } for (CUList::iterator i = copy.begin(); i != copy.end(); i++) { sprintf(moderemove,"-%c",this->GetModeChar()); const char* parameters[] = { channel->name, moderemove, i->first->nick }; ServerInstance->SendMode(parameters, 3, n); } delete n; } void ModeChannelHalfOp::RemoveMode(userrec* user) { } ModeAction ModeChannelHalfOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { /* If halfops are not enabled in the conf, we don't execute * anything in this class at all. */ if (!ServerInstance->Config->AllowHalfop) { parameter = ""; return MODEACTION_DENY; } int status = channel->GetStatus(source); /* Call the correct method depending on wether we're adding or removing the mode */ if (adding) { parameter = this->AddHalfOp(source, parameter.c_str(), channel, status); } else { parameter = this->DelHalfOp(source, parameter.c_str(), 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 * the return value and is always MODEACTION_DENY if the mode is supposed to have * a parameter. */ if (parameter.length()) return MODEACTION_ALLOW; else return MODEACTION_DENY; } std::string ModeChannelHalfOp::AddHalfOp(userrec *user,const char* dest,chanrec *chan,int status) { userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { if (IS_LOCAL(user)) { int MOD_RESULT = 0; FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_HALFOP)); if (MOD_RESULT == ACR_DENY) return ""; if (MOD_RESULT == ACR_DEFAULT) { if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server))) { user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name); return ""; } } } return ServerInstance->Modes->Grant(d,chan,UCMODE_HOP); } return ""; } std::string ModeChannelHalfOp::DelHalfOp(userrec *user,const char *dest,chanrec *chan,int status) { userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { if (IS_LOCAL(user)) { int MOD_RESULT = 0; FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEHALFOP)); if (MOD_RESULT == ACR_DENY) return ""; if (MOD_RESULT == ACR_DEFAULT) { if ((user != d) && ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)))) { user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name); return ""; } } } return ServerInstance->Modes->Revoke(d,chan,UCMODE_HOP); } return ""; } \ No newline at end of file
diff --git a/src/modes/cmode_i.cpp b/src/modes/cmode_i.cpp
index 12bdb18b8..1dd6dc857 100644
--- a/src/modes/cmode_i.cpp
+++ b/src/modes/cmode_i.cpp
@@ -1,35 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/cmode_i.h"
-
-ModeChannelInviteOnly::ModeChannelInviteOnly(InspIRCd* Instance) : ModeHandler(Instance, 'i', 0, 0, false, MODETYPE_CHANNEL, false)
-{
-}
-
-ModeAction ModeChannelInviteOnly::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- if (channel->modes[CM_INVITEONLY] != adding)
- {
- channel->modes[CM_INVITEONLY] = adding;
- return MODEACTION_ALLOW;
- }
- else
- {
- return MODEACTION_DENY;
- }
-}
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/cmode_i.h" ModeChannelInviteOnly::ModeChannelInviteOnly(InspIRCd* Instance) : ModeHandler(Instance, 'i', 0, 0, false, MODETYPE_CHANNEL, false) { } ModeAction ModeChannelInviteOnly::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { if (channel->modes[CM_INVITEONLY] != adding) { channel->modes[CM_INVITEONLY] = adding; return MODEACTION_ALLOW; } else { return MODEACTION_DENY; } } \ No newline at end of file
diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp
index eb59714f7..e06c35e83 100644
--- a/src/modes/cmode_k.cpp
+++ b/src/modes/cmode_k.cpp
@@ -1,103 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/cmode_k.h"
-
-ModeChannelKey::ModeChannelKey(InspIRCd* Instance) : ModeHandler(Instance, 'k', 1, 1, false, MODETYPE_CHANNEL, false)
-{
-}
-
-ModePair ModeChannelKey::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
-{
- if (channel->modes[CM_KEY])
- {
- return std::make_pair(true, channel->key);
- }
- else
- {
- return std::make_pair(false, parameter);
- }
-}
-
-void ModeChannelKey::RemoveMode(chanrec* channel)
-{
- /** +k needs a parameter when being removed,
- * so we have a special-case RemoveMode here for it
- */
- char moderemove[MAXBUF];
- const char* parameters[] = { channel->name, moderemove, channel->key };
-
- if (channel->IsModeSet(this->GetModeChar()))
- {
- userrec* n = new userrec(ServerInstance);
-
- sprintf(moderemove,"-%c",this->GetModeChar());
- n->SetFd(FD_MAGIC_NUMBER);
-
- ServerInstance->SendMode(parameters, 3, n);
-
- delete n;
- }
-}
-
-void ModeChannelKey::RemoveMode(userrec* user)
-{
-}
-
-bool ModeChannelKey::CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel)
-{
- /* When TS is equal, the alphabetically later channel key wins */
- return (their_param < our_param);
-}
-
-ModeAction ModeChannelKey::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- if ((channel->modes[CM_KEY] != adding) || (!IS_LOCAL(source)))
- {
- if (((channel->modes[CM_KEY]) && (strcasecmp(parameter.c_str(),channel->key))) && (IS_LOCAL(source)))
- {
- /* Key is currently set and the correct key wasnt given */
- return MODEACTION_DENY;
- }
- else if ((!channel->modes[CM_KEY]) || ((adding) && (!IS_LOCAL(source))))
- {
- /* Key isnt currently set */
- if ((parameter.length()) && (parameter.rfind(' ') == std::string::npos))
- {
- strlcpy(channel->key,parameter.c_str(),32);
- channel->modes[CM_KEY] = adding;
- parameter = channel->key;
- return MODEACTION_ALLOW;
- }
- else
- return MODEACTION_DENY;
- }
- else if (((channel->modes[CM_KEY]) && (!strcasecmp(parameter.c_str(),channel->key))) || ((!adding) && (!IS_LOCAL(source))))
- {
- /* Key is currently set, and correct key was given */
- *channel->key = 0;
- channel->modes[CM_KEY] = adding;
- return MODEACTION_ALLOW;
- }
- return MODEACTION_DENY;
- }
- else
- {
- return MODEACTION_DENY;
- }
-}
-
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/cmode_k.h" ModeChannelKey::ModeChannelKey(InspIRCd* Instance) : ModeHandler(Instance, 'k', 1, 1, false, MODETYPE_CHANNEL, false) { } ModePair ModeChannelKey::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter) { if (channel->modes[CM_KEY]) { return std::make_pair(true, channel->key); } else { return std::make_pair(false, parameter); } } void ModeChannelKey::RemoveMode(chanrec* channel) { /** +k needs a parameter when being removed, * so we have a special-case RemoveMode here for it */ char moderemove[MAXBUF]; const char* parameters[] = { channel->name, moderemove, channel->key }; if (channel->IsModeSet(this->GetModeChar())) { userrec* n = new userrec(ServerInstance); sprintf(moderemove,"-%c",this->GetModeChar()); n->SetFd(FD_MAGIC_NUMBER); ServerInstance->SendMode(parameters, 3, n); delete n; } } void ModeChannelKey::RemoveMode(userrec* user) { } bool ModeChannelKey::CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel) { /* When TS is equal, the alphabetically later channel key wins */ return (their_param < our_param); } ModeAction ModeChannelKey::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { if ((channel->modes[CM_KEY] != adding) || (!IS_LOCAL(source))) { if (((channel->modes[CM_KEY]) && (strcasecmp(parameter.c_str(),channel->key))) && (IS_LOCAL(source))) { /* Key is currently set and the correct key wasnt given */ return MODEACTION_DENY; } else if ((!channel->modes[CM_KEY]) || ((adding) && (!IS_LOCAL(source)))) { /* Key isnt currently set */ if ((parameter.length()) && (parameter.rfind(' ') == std::string::npos)) { strlcpy(channel->key,parameter.c_str(),32); channel->modes[CM_KEY] = adding; parameter = channel->key; return MODEACTION_ALLOW; } else return MODEACTION_DENY; } else if (((channel->modes[CM_KEY]) && (!strcasecmp(parameter.c_str(),channel->key))) || ((!adding) && (!IS_LOCAL(source)))) { /* Key is currently set, and correct key was given */ *channel->key = 0; channel->modes[CM_KEY] = adding; return MODEACTION_ALLOW; } return MODEACTION_DENY; } else { return MODEACTION_DENY; } } \ No newline at end of file
diff --git a/src/modes/cmode_l.cpp b/src/modes/cmode_l.cpp
index 1a57a440d..5e1a8c26c 100644
--- a/src/modes/cmode_l.cpp
+++ b/src/modes/cmode_l.cpp
@@ -1,97 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/cmode_l.h"
-
-ModeChannelLimit::ModeChannelLimit(InspIRCd* Instance) : ModeHandler(Instance, 'l', 1, 0, false, MODETYPE_CHANNEL, false)
-{
-}
-
-ModePair ModeChannelLimit::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
-{
- if (channel->limit)
- {
- return std::make_pair(true, ConvToStr(channel->limit));
- }
- else
- {
- return std::make_pair(false, parameter);
- }
-}
-
-bool ModeChannelLimit::CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel)
-{
- /* When TS is equal, the higher channel limit wins */
- return (atoi(their_param.c_str()) < atoi(our_param.c_str()));
-}
-
-ModeAction ModeChannelLimit::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- if (adding)
- {
- /* Setting a new limit, sanity check */
- long limit = atoi(parameter.c_str());
-
- /* Wrap low values at 32768 */
- if (limit < 0)
- limit = 0x7FFF;
-
- /* If the new limit is the same as the old limit,
- * and the old limit isnt 0, disallow */
- if ((limit == channel->limit) && (channel->limit > 0))
- {
- parameter = "";
- return MODEACTION_DENY;
- }
-
- /* They must have specified an invalid number.
- * Dont allow +l 0.
- */
- if (!limit)
- {
- parameter = "";
- return MODEACTION_DENY;
- }
-
- parameter = ConvToStr(limit);
-
- /* Set new limit */
- channel->limit = limit;
- channel->modes[CM_LIMIT] = 1;
-
- return MODEACTION_ALLOW;
- }
- else
- {
- /* Check if theres a limit here to remove.
- * If there isnt, dont allow the -l
- */
- if (!channel->limit)
- {
- parameter = "";
- return MODEACTION_DENY;
- }
-
- /* Removing old limit, no checks here */
- channel->limit = 0;
- channel->modes[CM_LIMIT] = 0;
-
- return MODEACTION_ALLOW;
- }
-
- return MODEACTION_DENY;
-}
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/cmode_l.h" ModeChannelLimit::ModeChannelLimit(InspIRCd* Instance) : ModeHandler(Instance, 'l', 1, 0, false, MODETYPE_CHANNEL, false) { } ModePair ModeChannelLimit::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter) { if (channel->limit) { return std::make_pair(true, ConvToStr(channel->limit)); } else { return std::make_pair(false, parameter); } } bool ModeChannelLimit::CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel) { /* When TS is equal, the higher channel limit wins */ return (atoi(their_param.c_str()) < atoi(our_param.c_str())); } ModeAction ModeChannelLimit::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { if (adding) { /* Setting a new limit, sanity check */ long limit = atoi(parameter.c_str()); /* Wrap low values at 32768 */ if (limit < 0) limit = 0x7FFF; /* If the new limit is the same as the old limit, * and the old limit isnt 0, disallow */ if ((limit == channel->limit) && (channel->limit > 0)) { parameter = ""; return MODEACTION_DENY; } /* They must have specified an invalid number. * Dont allow +l 0. */ if (!limit) { parameter = ""; return MODEACTION_DENY; } parameter = ConvToStr(limit); /* Set new limit */ channel->limit = limit; channel->modes[CM_LIMIT] = 1; return MODEACTION_ALLOW; } else { /* Check if theres a limit here to remove. * If there isnt, dont allow the -l */ if (!channel->limit) { parameter = ""; return MODEACTION_DENY; } /* Removing old limit, no checks here */ channel->limit = 0; channel->modes[CM_LIMIT] = 0; return MODEACTION_ALLOW; } return MODEACTION_DENY; } \ No newline at end of file
diff --git a/src/modes/cmode_m.cpp b/src/modes/cmode_m.cpp
index 520248fda..da882333b 100644
--- a/src/modes/cmode_m.cpp
+++ b/src/modes/cmode_m.cpp
@@ -1,36 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/cmode_m.h"
-
-ModeChannelModerated::ModeChannelModerated(InspIRCd* Instance) : ModeHandler(Instance, 'm', 0, 0, false, MODETYPE_CHANNEL, false)
-{
-}
-
-ModeAction ModeChannelModerated::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- if (channel->modes[CM_MODERATED] != adding)
- {
- channel->modes[CM_MODERATED] = adding;
- return MODEACTION_ALLOW;
- }
- else
- {
- return MODEACTION_DENY;
- }
-}
-
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/cmode_m.h" ModeChannelModerated::ModeChannelModerated(InspIRCd* Instance) : ModeHandler(Instance, 'm', 0, 0, false, MODETYPE_CHANNEL, false) { } ModeAction ModeChannelModerated::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { if (channel->modes[CM_MODERATED] != adding) { channel->modes[CM_MODERATED] = adding; return MODEACTION_ALLOW; } else { return MODEACTION_DENY; } } \ No newline at end of file
diff --git a/src/modes/cmode_n.cpp b/src/modes/cmode_n.cpp
index ddc2e1bbd..3ae7d538c 100644
--- a/src/modes/cmode_n.cpp
+++ b/src/modes/cmode_n.cpp
@@ -1,36 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/cmode_n.h"
-
-ModeChannelNoExternal::ModeChannelNoExternal(InspIRCd* Instance) : ModeHandler(Instance, 'n', 0, 0, false, MODETYPE_CHANNEL, false)
-{
-}
-
-ModeAction ModeChannelNoExternal::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- if (channel->modes[CM_NOEXTERNAL] != adding)
- {
- channel->modes[CM_NOEXTERNAL] = adding;
- return MODEACTION_ALLOW;
- }
- else
- {
- return MODEACTION_DENY;
- }
-}
-
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/cmode_n.h" ModeChannelNoExternal::ModeChannelNoExternal(InspIRCd* Instance) : ModeHandler(Instance, 'n', 0, 0, false, MODETYPE_CHANNEL, false) { } ModeAction ModeChannelNoExternal::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { if (channel->modes[CM_NOEXTERNAL] != adding) { channel->modes[CM_NOEXTERNAL] = adding; return MODEACTION_ALLOW; } else { return MODEACTION_DENY; } } \ No newline at end of file
diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp
index 47d191ff8..9ae18109e 100644
--- a/src/modes/cmode_o.cpp
+++ b/src/modes/cmode_o.cpp
@@ -1,153 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "configreader.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modules.h"
-#include "modes/cmode_o.h"
-
-ModeChannelOp::ModeChannelOp(InspIRCd* Instance) : ModeHandler(Instance, 'o', 1, 1, true, MODETYPE_CHANNEL, false, '@')
-{
-}
-
-unsigned int ModeChannelOp::GetPrefixRank()
-{
- return OP_VALUE;
-}
-
-ModePair ModeChannelOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
-{
- userrec* x = ServerInstance->FindNick(parameter);
- if (x)
- {
- if (channel->GetStatusFlags(x) & UCMODE_OP)
- {
- return std::make_pair(true, x->nick);
- }
- else
- {
- return std::make_pair(false, parameter);
- }
- }
- return std::make_pair(false, parameter);
-}
-
-
-void ModeChannelOp::RemoveMode(chanrec* channel)
-{
- CUList* list = channel->GetOppedUsers();
- CUList copy;
- char moderemove[MAXBUF];
- userrec* n = new userrec(ServerInstance);
- n->SetFd(FD_MAGIC_NUMBER);
-
- for (CUList::iterator i = list->begin(); i != list->end(); i++)
- {
- userrec* n = i->first;
- copy.insert(std::make_pair(n,n->nick));
- }
- for (CUList::iterator i = copy.begin(); i != copy.end(); i++)
- {
- sprintf(moderemove,"-%c",this->GetModeChar());
- const char* parameters[] = { channel->name, moderemove, i->first->nick };
- ServerInstance->SendMode(parameters, 3, n);
- }
- delete n;
-}
-
-void ModeChannelOp::RemoveMode(userrec* user)
-{
-}
-
-ModeAction ModeChannelOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- int status = channel->GetStatus(source);
-
- /* Call the correct method depending on wether we're adding or removing the mode */
- if (adding)
- {
- parameter = this->AddOp(source, parameter.c_str(), channel, status);
- }
- else
- {
- parameter = this->DelOp(source, parameter.c_str(), 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
- * the return value and is always MODEACTION_DENY if the mode is supposed to have
- * a parameter.
- */
- if (parameter.length())
- return MODEACTION_ALLOW;
- else
- return MODEACTION_DENY;
-}
-
-std::string ModeChannelOp::AddOp(userrec *user,const char* dest,chanrec *chan,int status)
-{
- userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
-
- if (d)
- {
- if (IS_LOCAL(user))
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_OP));
-
- if (MOD_RESULT == ACR_DENY)
- return "";
- if (MOD_RESULT == ACR_DEFAULT)
- {
- if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)))
- {
- user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name);
- return "";
- }
- }
- }
-
- return ServerInstance->Modes->Grant(d,chan,UCMODE_OP);
- }
- return "";
-}
-
-std::string ModeChannelOp::DelOp(userrec *user,const char *dest,chanrec *chan,int status)
-{
- userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
-
- if (d)
- {
- if (IS_LOCAL(user))
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEOP));
-
- if (MOD_RESULT == ACR_DENY)
- return "";
- if (MOD_RESULT == ACR_DEFAULT)
- {
- if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)) && (IS_LOCAL(user)))
- {
- user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name);
- return "";
- }
- }
- }
-
- return ServerInstance->Modes->Revoke(d,chan,UCMODE_OP);
- }
- return "";
-}
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "configreader.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modules.h" #include "modes/cmode_o.h" ModeChannelOp::ModeChannelOp(InspIRCd* Instance) : ModeHandler(Instance, 'o', 1, 1, true, MODETYPE_CHANNEL, false, '@') { } unsigned int ModeChannelOp::GetPrefixRank() { return OP_VALUE; } ModePair ModeChannelOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter) { userrec* x = ServerInstance->FindNick(parameter); if (x) { if (channel->GetStatusFlags(x) & UCMODE_OP) { return std::make_pair(true, x->nick); } else { return std::make_pair(false, parameter); } } return std::make_pair(false, parameter); } void ModeChannelOp::RemoveMode(chanrec* channel) { CUList* list = channel->GetOppedUsers(); CUList copy; char moderemove[MAXBUF]; userrec* n = new userrec(ServerInstance); n->SetFd(FD_MAGIC_NUMBER); for (CUList::iterator i = list->begin(); i != list->end(); i++) { userrec* n = i->first; copy.insert(std::make_pair(n,n->nick)); } for (CUList::iterator i = copy.begin(); i != copy.end(); i++) { sprintf(moderemove,"-%c",this->GetModeChar()); const char* parameters[] = { channel->name, moderemove, i->first->nick }; ServerInstance->SendMode(parameters, 3, n); } delete n; } void ModeChannelOp::RemoveMode(userrec* user) { } ModeAction ModeChannelOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { int status = channel->GetStatus(source); /* Call the correct method depending on wether we're adding or removing the mode */ if (adding) { parameter = this->AddOp(source, parameter.c_str(), channel, status); } else { parameter = this->DelOp(source, parameter.c_str(), 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 * the return value and is always MODEACTION_DENY if the mode is supposed to have * a parameter. */ if (parameter.length()) return MODEACTION_ALLOW; else return MODEACTION_DENY; } std::string ModeChannelOp::AddOp(userrec *user,const char* dest,chanrec *chan,int status) { userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { if (IS_LOCAL(user)) { int MOD_RESULT = 0; FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_OP)); if (MOD_RESULT == ACR_DENY) return ""; if (MOD_RESULT == ACR_DEFAULT) { if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server))) { user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name); return ""; } } } return ServerInstance->Modes->Grant(d,chan,UCMODE_OP); } return ""; } std::string ModeChannelOp::DelOp(userrec *user,const char *dest,chanrec *chan,int status) { userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { if (IS_LOCAL(user)) { int MOD_RESULT = 0; FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEOP)); if (MOD_RESULT == ACR_DENY) return ""; if (MOD_RESULT == ACR_DEFAULT) { if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)) && (IS_LOCAL(user))) { user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name); return ""; } } } return ServerInstance->Modes->Revoke(d,chan,UCMODE_OP); } return ""; } \ No newline at end of file
diff --git a/src/modes/cmode_p.cpp b/src/modes/cmode_p.cpp
index 15c33222e..c762b7827 100644
--- a/src/modes/cmode_p.cpp
+++ b/src/modes/cmode_p.cpp
@@ -1,35 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/cmode_p.h"
-
-ModeChannelPrivate::ModeChannelPrivate(InspIRCd* Instance) : ModeHandler(Instance, 'p', 0, 0, false, MODETYPE_CHANNEL, false)
-{
-}
-
-ModeAction ModeChannelPrivate::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- if (channel->modes[CM_PRIVATE] != adding)
- {
- channel->modes[CM_PRIVATE] = adding;
- return MODEACTION_ALLOW;
- }
- else
- {
- return MODEACTION_DENY;
- }
-}
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/cmode_p.h" ModeChannelPrivate::ModeChannelPrivate(InspIRCd* Instance) : ModeHandler(Instance, 'p', 0, 0, false, MODETYPE_CHANNEL, false) { } ModeAction ModeChannelPrivate::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { if (channel->modes[CM_PRIVATE] != adding) { channel->modes[CM_PRIVATE] = adding; return MODEACTION_ALLOW; } else { return MODEACTION_DENY; } } \ No newline at end of file
diff --git a/src/modes/cmode_s.cpp b/src/modes/cmode_s.cpp
index 135291592..069591e6b 100644
--- a/src/modes/cmode_s.cpp
+++ b/src/modes/cmode_s.cpp
@@ -1,35 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/cmode_s.h"
-
-ModeChannelSecret::ModeChannelSecret(InspIRCd* Instance) : ModeHandler(Instance, 's', 0, 0, false, MODETYPE_CHANNEL, false)
-{
-}
-
-ModeAction ModeChannelSecret::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- if (channel->modes[CM_SECRET] != adding)
- {
- channel->modes[CM_SECRET] = adding;
- return MODEACTION_ALLOW;
- }
- else
- {
- return MODEACTION_DENY;
- }
-}
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/cmode_s.h" ModeChannelSecret::ModeChannelSecret(InspIRCd* Instance) : ModeHandler(Instance, 's', 0, 0, false, MODETYPE_CHANNEL, false) { } ModeAction ModeChannelSecret::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { if (channel->modes[CM_SECRET] != adding) { channel->modes[CM_SECRET] = adding; return MODEACTION_ALLOW; } else { return MODEACTION_DENY; } } \ No newline at end of file
diff --git a/src/modes/cmode_t.cpp b/src/modes/cmode_t.cpp
index 2a6c06b42..def48a781 100644
--- a/src/modes/cmode_t.cpp
+++ b/src/modes/cmode_t.cpp
@@ -1,36 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/cmode_t.h"
-
-ModeChannelTopicOps::ModeChannelTopicOps(InspIRCd* Instance) : ModeHandler(Instance, 't', 0, 0, false, MODETYPE_CHANNEL, false)
-{
-}
-
-ModeAction ModeChannelTopicOps::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- if (channel->modes[CM_TOPICLOCK] != adding)
- {
- channel->modes[CM_TOPICLOCK] = adding;
- return MODEACTION_ALLOW;
- }
- else
- {
- return MODEACTION_DENY;
- }
-}
-
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/cmode_t.h" ModeChannelTopicOps::ModeChannelTopicOps(InspIRCd* Instance) : ModeHandler(Instance, 't', 0, 0, false, MODETYPE_CHANNEL, false) { } ModeAction ModeChannelTopicOps::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { if (channel->modes[CM_TOPICLOCK] != adding) { channel->modes[CM_TOPICLOCK] = adding; return MODEACTION_ALLOW; } else { return MODEACTION_DENY; } } \ No newline at end of file
diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp
index 1e244c606..c055cca7f 100644
--- a/src/modes/cmode_v.cpp
+++ b/src/modes/cmode_v.cpp
@@ -1,152 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "configreader.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modules.h"
-#include "modes/cmode_v.h"
-
-ModeChannelVoice::ModeChannelVoice(InspIRCd* Instance) : ModeHandler(Instance, 'v', 1, 1, true, MODETYPE_CHANNEL, false, '+')
-{
-}
-
-unsigned int ModeChannelVoice::GetPrefixRank()
-{
- return VOICE_VALUE;
-}
-
-ModePair ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
-{
- userrec* x = ServerInstance->FindNick(parameter);
- if (x)
- {
- if (channel->GetStatusFlags(x) & UCMODE_VOICE)
- {
- return std::make_pair(true, x->nick);
- }
- else
- {
- return std::make_pair(false, parameter);
- }
- }
- return std::make_pair(false, parameter);
-}
-
-void ModeChannelVoice::RemoveMode(chanrec* channel)
-{
- CUList* list = channel->GetVoicedUsers();
- CUList copy;
- char moderemove[MAXBUF];
- userrec* n = new userrec(ServerInstance);
- n->SetFd(FD_MAGIC_NUMBER);
-
- for (CUList::iterator i = list->begin(); i != list->end(); i++)
- {
- userrec* n = i->first;
- copy.insert(std::make_pair(n,n->nick));
- }
- for (CUList::iterator i = copy.begin(); i != copy.end(); i++)
- {
- sprintf(moderemove,"-%c",this->GetModeChar());
- const char* parameters[] = { channel->name, moderemove, i->first->nick };
- ServerInstance->SendMode(parameters, 3, n);
- }
- delete n;
-}
-
-void ModeChannelVoice::RemoveMode(userrec* user)
-{
-}
-
-ModeAction ModeChannelVoice::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- int status = channel->GetStatus(source);
-
- /* Call the correct method depending on wether we're adding or removing the mode */
- if (adding)
- {
- parameter = this->AddVoice(source, parameter.c_str(), channel, status);
- }
- else
- {
- parameter = this->DelVoice(source, parameter.c_str(), 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
- * the return value and is always MODEACTION_DENY if the mode is supposed to have
- * a parameter.
- */
- if (parameter.length())
- return MODEACTION_ALLOW;
- else
- return MODEACTION_DENY;
-}
-
-std::string ModeChannelVoice::AddVoice(userrec *user,const char* dest,chanrec *chan,int status)
-{
- userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
-
- if (d)
- {
- if (IS_LOCAL(user))
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_VOICE));
-
- if (MOD_RESULT == ACR_DENY)
- return "";
- if (MOD_RESULT == ACR_DEFAULT)
- {
- if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server)))
- {
- user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick, chan->name);
- return "";
- }
- }
- }
-
- return ServerInstance->Modes->Grant(d,chan,UCMODE_VOICE);
- }
- return "";
-}
-
-std::string ModeChannelVoice::DelVoice(userrec *user,const char *dest,chanrec *chan,int status)
-{
- userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
-
- if (d)
- {
- if (IS_LOCAL(user))
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEVOICE));
-
- if (MOD_RESULT == ACR_DENY)
- return "";
- if (MOD_RESULT == ACR_DEFAULT)
- {
- if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server)))
- {
- user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick, chan->name);
- return "";
- }
- }
- }
-
- return ServerInstance->Modes->Revoke(d,chan,UCMODE_VOICE);
- }
- return "";
-}
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "configreader.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modules.h" #include "modes/cmode_v.h" ModeChannelVoice::ModeChannelVoice(InspIRCd* Instance) : ModeHandler(Instance, 'v', 1, 1, true, MODETYPE_CHANNEL, false, '+') { } unsigned int ModeChannelVoice::GetPrefixRank() { return VOICE_VALUE; } ModePair ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter) { userrec* x = ServerInstance->FindNick(parameter); if (x) { if (channel->GetStatusFlags(x) & UCMODE_VOICE) { return std::make_pair(true, x->nick); } else { return std::make_pair(false, parameter); } } return std::make_pair(false, parameter); } void ModeChannelVoice::RemoveMode(chanrec* channel) { CUList* list = channel->GetVoicedUsers(); CUList copy; char moderemove[MAXBUF]; userrec* n = new userrec(ServerInstance); n->SetFd(FD_MAGIC_NUMBER); for (CUList::iterator i = list->begin(); i != list->end(); i++) { userrec* n = i->first; copy.insert(std::make_pair(n,n->nick)); } for (CUList::iterator i = copy.begin(); i != copy.end(); i++) { sprintf(moderemove,"-%c",this->GetModeChar()); const char* parameters[] = { channel->name, moderemove, i->first->nick }; ServerInstance->SendMode(parameters, 3, n); } delete n; } void ModeChannelVoice::RemoveMode(userrec* user) { } ModeAction ModeChannelVoice::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { int status = channel->GetStatus(source); /* Call the correct method depending on wether we're adding or removing the mode */ if (adding) { parameter = this->AddVoice(source, parameter.c_str(), channel, status); } else { parameter = this->DelVoice(source, parameter.c_str(), 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 * the return value and is always MODEACTION_DENY if the mode is supposed to have * a parameter. */ if (parameter.length()) return MODEACTION_ALLOW; else return MODEACTION_DENY; } std::string ModeChannelVoice::AddVoice(userrec *user,const char* dest,chanrec *chan,int status) { userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { if (IS_LOCAL(user)) { int MOD_RESULT = 0; FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_VOICE)); if (MOD_RESULT == ACR_DENY) return ""; if (MOD_RESULT == ACR_DEFAULT) { if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server))) { user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick, chan->name); return ""; } } } return ServerInstance->Modes->Grant(d,chan,UCMODE_VOICE); } return ""; } std::string ModeChannelVoice::DelVoice(userrec *user,const char *dest,chanrec *chan,int status) { userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { if (IS_LOCAL(user)) { int MOD_RESULT = 0; FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEVOICE)); if (MOD_RESULT == ACR_DENY) return ""; if (MOD_RESULT == ACR_DEFAULT) { if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server))) { user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick, chan->name); return ""; } } } return ServerInstance->Modes->Revoke(d,chan,UCMODE_VOICE); } return ""; } \ No newline at end of file
diff --git a/src/modes/umode_i.cpp b/src/modes/umode_i.cpp
index 5a9327375..6bd769a9a 100644
--- a/src/modes/umode_i.cpp
+++ b/src/modes/umode_i.cpp
@@ -1,45 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/umode_i.h"
-
-ModeUserInvisible::ModeUserInvisible(InspIRCd* Instance) : ModeHandler(Instance, 'i', 0, 0, false, MODETYPE_USER, false)
-{
-}
-
-ModeAction ModeUserInvisible::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- /* Only opers can change other users modes */
- if ((source != dest) && (!*source->oper))
- return MODEACTION_DENY;
-
- /* Set the bitfields */
- if (dest->modes[UM_INVISIBLE] != adding)
- {
- dest->modes[UM_INVISIBLE] = adding;
- this->count += (adding ? 1: -1);
- return MODEACTION_ALLOW;
- }
-
- /* Allow the change */
- return MODEACTION_DENY;
-}
-
-unsigned int ModeUserInvisible::GetCount()
-{
- return count;
-}
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/umode_i.h" ModeUserInvisible::ModeUserInvisible(InspIRCd* Instance) : ModeHandler(Instance, 'i', 0, 0, false, MODETYPE_USER, false) { } ModeAction ModeUserInvisible::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { /* Only opers can change other users modes */ if ((source != dest) && (!*source->oper)) return MODEACTION_DENY; /* Set the bitfields */ if (dest->modes[UM_INVISIBLE] != adding) { dest->modes[UM_INVISIBLE] = adding; this->count += (adding ? 1: -1); return MODEACTION_ALLOW; } /* Allow the change */ return MODEACTION_DENY; } unsigned int ModeUserInvisible::GetCount() { return count; } \ No newline at end of file
diff --git a/src/modes/umode_n.cpp b/src/modes/umode_n.cpp
index c9c9e312e..c5d2599d8 100644
--- a/src/modes/umode_n.cpp
+++ b/src/modes/umode_n.cpp
@@ -1,58 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/umode_n.h"
-
-ModeUserServerNoticeMask::ModeUserServerNoticeMask(InspIRCd* Instance) : ModeHandler(Instance, 'n', 1, 0, false, MODETYPE_USER, true)
-{
-}
-
-ModeAction ModeUserServerNoticeMask::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- /* Only opers can change other users modes */
- if ((source != dest) && (!*source->oper))
- return MODEACTION_DENY;
-
- /* Set the bitfields */
- if (adding)
- {
- /* Fix for bug #310 reported by Smartys */
- if (!dest->modes[UM_SNOMASK])
- memset(dest->snomasks, 0, sizeof(dest->snomasks));
-
- parameter = dest->ProcessNoticeMasks(parameter.c_str());
- dest->modes[UM_SNOMASK] = true;
- if (!dest->modes[UM_SERVERNOTICE])
- {
- const char* newmodes[] = { dest->nick, "+s" };
- ServerInstance->Modes->Process(newmodes, 2, source, true);
- }
- return MODEACTION_ALLOW;
- }
- else
- {
- if (dest->modes[UM_SNOMASK] != false)
- {
- dest->modes[UM_SNOMASK] = false;
- return MODEACTION_ALLOW;
- }
- }
-
- /* Allow the change */
- return MODEACTION_DENY;
-}
-
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/umode_n.h" ModeUserServerNoticeMask::ModeUserServerNoticeMask(InspIRCd* Instance) : ModeHandler(Instance, 'n', 1, 0, false, MODETYPE_USER, true) { } ModeAction ModeUserServerNoticeMask::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { /* Only opers can change other users modes */ if ((source != dest) && (!*source->oper)) return MODEACTION_DENY; /* Set the bitfields */ if (adding) { /* Fix for bug #310 reported by Smartys */ if (!dest->modes[UM_SNOMASK]) memset(dest->snomasks, 0, sizeof(dest->snomasks)); parameter = dest->ProcessNoticeMasks(parameter.c_str()); dest->modes[UM_SNOMASK] = true; if (!dest->modes[UM_SERVERNOTICE]) { const char* newmodes[] = { dest->nick, "+s" }; ServerInstance->Modes->Process(newmodes, 2, source, true); } return MODEACTION_ALLOW; } else { if (dest->modes[UM_SNOMASK] != false) { dest->modes[UM_SNOMASK] = false; return MODEACTION_ALLOW; } } /* Allow the change */ return MODEACTION_DENY; } \ No newline at end of file
diff --git a/src/modes/umode_o.cpp b/src/modes/umode_o.cpp
index 30ed089f6..1b47fe8b2 100644
--- a/src/modes/umode_o.cpp
+++ b/src/modes/umode_o.cpp
@@ -1,49 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/umode_o.h"
-
-ModeUserOperator::ModeUserOperator(InspIRCd* Instance) : ModeHandler(Instance, 'o', 0, 0, false, MODETYPE_USER, true)
-{
-}
-
-ModeAction ModeUserOperator::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- /* Only opers can execute this class at all */
- if (!*source->oper)
- return MODEACTION_DENY;
-
- /* Not even opers can GIVE the +o mode, only take it away */
- if (adding)
- return MODEACTION_DENY;
-
- /* Set the bitfields.
- * Note that oper status is only given in cmd_oper.cpp
- * NOT here. It is impossible to directly set +o without
- * verifying as an oper and getting an opertype assigned
- * to your userrec!
- */
- ServerInstance->SNO->WriteToSnoMask('o', "User %s de-opered (by %s)", dest->nick, source->nick);
- dest->UnOper();
-
- return MODEACTION_ALLOW;
-}
-
-unsigned int ModeUserOperator::GetCount()
-{
- return ServerInstance->all_opers.size();
-}
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/umode_o.h" ModeUserOperator::ModeUserOperator(InspIRCd* Instance) : ModeHandler(Instance, 'o', 0, 0, false, MODETYPE_USER, true) { } ModeAction ModeUserOperator::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { /* Only opers can execute this class at all */ if (!*source->oper) return MODEACTION_DENY; /* Not even opers can GIVE the +o mode, only take it away */ if (adding) return MODEACTION_DENY; /* Set the bitfields. * Note that oper status is only given in cmd_oper.cpp * NOT here. It is impossible to directly set +o without * verifying as an oper and getting an opertype assigned * to your userrec! */ ServerInstance->SNO->WriteToSnoMask('o', "User %s de-opered (by %s)", dest->nick, source->nick); dest->UnOper(); return MODEACTION_ALLOW; } unsigned int ModeUserOperator::GetCount() { return ServerInstance->all_opers.size(); } \ No newline at end of file
diff --git a/src/modes/umode_s.cpp b/src/modes/umode_s.cpp
index 4b3179001..f0441b85f 100644
--- a/src/modes/umode_s.cpp
+++ b/src/modes/umode_s.cpp
@@ -1,45 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/umode_s.h"
-
-ModeUserServerNotice::ModeUserServerNotice(InspIRCd* Instance) : ModeHandler(Instance, 's', 0, 0, false, MODETYPE_USER, false)
-{
-}
-
-ModeAction ModeUserServerNotice::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- /* Only opers can change other users modes */
- if ((source != dest) && (!*source->oper))
- return MODEACTION_DENY;
-
- /* Set the bitfields */
- if (dest->modes[UM_SERVERNOTICE] != adding)
- {
- dest->modes[UM_SERVERNOTICE] = adding;
- this->count += (adding ? 1: -1);
- return MODEACTION_ALLOW;
- }
-
- /* Allow the change */
- return MODEACTION_DENY;
-}
-
-unsigned int ModeUserServerNotice::GetCount()
-{
- return count;
-}
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/umode_s.h" ModeUserServerNotice::ModeUserServerNotice(InspIRCd* Instance) : ModeHandler(Instance, 's', 0, 0, false, MODETYPE_USER, false) { } ModeAction ModeUserServerNotice::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { /* Only opers can change other users modes */ if ((source != dest) && (!*source->oper)) return MODEACTION_DENY; /* Set the bitfields */ if (dest->modes[UM_SERVERNOTICE] != adding) { dest->modes[UM_SERVERNOTICE] = adding; this->count += (adding ? 1: -1); return MODEACTION_ALLOW; } /* Allow the change */ return MODEACTION_DENY; } unsigned int ModeUserServerNotice::GetCount() { return count; } \ No newline at end of file
diff --git a/src/modes/umode_w.cpp b/src/modes/umode_w.cpp
index 383c91f6e..21c007655 100644
--- a/src/modes/umode_w.cpp
+++ b/src/modes/umode_w.cpp
@@ -1,46 +1 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "mode.h"
-#include "channels.h"
-#include "users.h"
-#include "modes/umode_w.h"
-
-ModeUserWallops::ModeUserWallops(InspIRCd* Instance) : ModeHandler(Instance, 'w', 0, 0, false, MODETYPE_USER, false)
-{
-}
-
-ModeAction ModeUserWallops::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
-{
- /* Only opers can change other users modes */
- if ((source != dest) && (!*source->oper))
- return MODEACTION_DENY;
-
- /* Set the bitfields */
- if (dest->modes[UM_WALLOPS] != adding)
- {
- dest->modes[UM_WALLOPS] = adding;
- this->count += (adding ? 1: -1);
- return MODEACTION_ALLOW;
- }
-
- /* Allow the change */
- return MODEACTION_DENY;
-}
-
-unsigned int ModeUserWallops::GetCount()
-{
- return count;
-}
-
+/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" #include "modes/umode_w.h" ModeUserWallops::ModeUserWallops(InspIRCd* Instance) : ModeHandler(Instance, 'w', 0, 0, false, MODETYPE_USER, false) { } ModeAction ModeUserWallops::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) { /* Only opers can change other users modes */ if ((source != dest) && (!*source->oper)) return MODEACTION_DENY; /* Set the bitfields */ if (dest->modes[UM_WALLOPS] != adding) { dest->modes[UM_WALLOPS] = adding; this->count += (adding ? 1: -1); return MODEACTION_ALLOW; } /* Allow the change */ return MODEACTION_DENY; } unsigned int ModeUserWallops::GetCount() { return count; } \ No newline at end of file