summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/helperfuncs.cpp24
-rw-r--r--src/mode.cpp32
-rw-r--r--src/modules/m_banexception.cpp4
-rw-r--r--src/modules/m_blockcaps.cpp5
-rw-r--r--src/modules/m_blockcolor.cpp4
-rw-r--r--src/modules/m_censor.cpp4
-rw-r--r--src/modules/m_chanfilter.cpp4
-rw-r--r--src/modules/m_chanprotect.cpp2
-rw-r--r--src/modules/m_inviteexception.cpp4
-rw-r--r--src/modules/m_joinflood.cpp2
-rw-r--r--src/modules/m_kicknorejoin.cpp4
-rw-r--r--src/modules/m_knock.cpp2
-rw-r--r--src/modules/m_messageflood.cpp4
-rw-r--r--src/modules/m_noctcp.cpp4
-rw-r--r--src/modules/m_noinvite.cpp4
-rw-r--r--src/modules/m_nokicks.cpp4
-rw-r--r--src/modules/m_nonicks.cpp2
-rw-r--r--src/modules/m_nonotice.cpp4
-rw-r--r--src/modules/m_operchans.cpp4
-rw-r--r--src/modules/m_redirect.cpp2
-rw-r--r--src/modules/m_services.cpp4
-rw-r--r--src/modules/m_services_account.cpp4
-rw-r--r--src/modules/m_sslmodes.cpp4
-rw-r--r--src/modules/m_stripcolor.cpp4
24 files changed, 85 insertions, 50 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 689b1c409..d048b75df 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -507,30 +507,6 @@ bool AllModulesReportReady(userrec* user)
return true;
}
-int InsertMode(std::string &output, const char* mode, unsigned short section)
-{
- unsigned short currsection = 1;
- unsigned int pos = output.find("CHANMODES=", 0) + 10; // +10 for the length of "CHANMODES="
-
- if(section > 4 || section == 0)
- {
- log(DEBUG, "InsertMode: CHANMODES doesn't have a section %dh :/", section);
- return 0;
- }
-
- for(; pos < output.size(); pos++)
- {
- if(section == currsection)
- break;
-
- if(output[pos] == ',')
- currsection++;
- }
-
- output.insert(pos, mode);
- return 1;
-}
-
bool IsValidChannelName(const char *chname)
{
char *c;
diff --git a/src/mode.cpp b/src/mode.cpp
index 915dcd809..b0043b828 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -3,13 +3,13 @@
* +------------------------------------+
*
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
- * <brain@chatspike.net>
- * <Craig@chatspike.net>
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
*
* Written by Craig Edwards, Craig McLure, and others.
* This program is free but copyrighted software; see
- * the file COPYING for details.
+ * the file COPYING for details.
*
* ---------------------------------------------------
*/
@@ -699,3 +699,27 @@ ModeParser::ModeParser()
this->AddMode(new ModeUserServerNoticeMask, 'n');
}
+bool ModeParser::InsertMode(std::string &output, const char* mode, unsigned short section)
+{
+ unsigned short currsection = 1;
+ unsigned int pos = output.find("CHANMODES=", 0) + 10; // +10 for the length of "CHANMODES="
+
+ if(section > 4 || section == 0)
+ {
+ log(DEBUG, "InsertMode: CHANMODES doesn't have a section %dh :/", section);
+ return false;
+ }
+
+ for(; pos < output.size(); pos++)
+ {
+ if(section == currsection)
+ break;
+
+ if(output[pos] == ',')
+ currsection++;
+ }
+
+ output.insert(pos, mode);
+ return true;
+}
+
diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp
index bd549860f..588c42b5e 100644
--- a/src/modules/m_banexception.cpp
+++ b/src/modules/m_banexception.cpp
@@ -18,6 +18,8 @@
// The +e channel mode takes a nick!ident@host, glob patterns allowed,
// and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
+extern InspIRCd* ServerInstance;
+
class BanException : public ListModeBase
{
public:
@@ -48,7 +50,7 @@ public:
virtual void On005Numeric(std::string &output)
{
output.append(" EXCEPTS=e");
- InsertMode(output, "e", 1);
+ ServerInstance->ModeGrok->InsertMode(output, "e", 1);
}
virtual int OnCheckBan(userrec* user, chanrec* chan)
diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp
index 0fea32288..8cc3d8646 100644
--- a/src/modules/m_blockcaps.cpp
+++ b/src/modules/m_blockcaps.cpp
@@ -20,9 +20,12 @@
#include "modules.h"
#include "helperfuncs.h"
#include "inspircd.h"
+#include "mode.h"
/* $ModDesc: Provides support for channel mode +P to block all-CAPS channel messages and notices */
+extern InspIRCd* ServerInstance;
+
class BlockCaps : public ModeHandler
{
public:
@@ -71,7 +74,7 @@ public:
virtual void On005Numeric(std::string &output)
{
- InsertMode(output, "P", 4);
+ ServerInstance->ModeGrok->InsertMode(output, "P", 4);
}
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp
index 2b9006583..75d86bba0 100644
--- a/src/modules/m_blockcolor.cpp
+++ b/src/modules/m_blockcolor.cpp
@@ -26,6 +26,8 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style channel mode +c */
+extern InspIRCd* ServerInstance;
+
class BlockColor : public ModeHandler
{
public:
@@ -74,7 +76,7 @@ class ModuleBlockColour : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"c",4);
+ ServerInstance->ModeGrok->InsertMode(output,"c",4);
}
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp
index 5d18f9de8..deeb68685 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -28,6 +28,8 @@ typedef std::map<irc::string,irc::string> censor_t;
/* $ModDesc: Provides user and channel +G mode */
+extern InspIRCd* ServerInstance;
+
class CensorException : public ModuleException
{
public:
@@ -137,7 +139,7 @@ class ModuleCensor : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"G",4);
+ ServerInstance->ModeGrok->InsertMode(output,"G",4);
}
virtual ~ModuleCensor()
diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp
index a4f4d6068..22442de98 100644
--- a/src/modules/m_chanfilter.cpp
+++ b/src/modules/m_chanfilter.cpp
@@ -29,6 +29,8 @@ using namespace std;
/* $ModDesc: Provides channel-specific censor lists (like mode +G but varies from channel to channel) */
+extern InspIRCd* ServerInstance;
+
class ChanFilter : public ListModeBase
{
public:
@@ -84,7 +86,7 @@ class ModuleChanFilter : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"g",1);
+ ServerInstance->ModeGrok->InsertMode(output,"g",1);
}
virtual void OnChannelDelete(chanrec* chan)
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp
index 21c3ee681..024887792 100644
--- a/src/modules/m_chanprotect.cpp
+++ b/src/modules/m_chanprotect.cpp
@@ -275,7 +275,7 @@ class ModuleChanProtect : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"qa",1);
+ ServerInstance->ModeGrok->InsertMode(output,"qa",1);
}
virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason)
diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp
index dabdc2829..5bd8d17e6 100644
--- a/src/modules/m_inviteexception.cpp
+++ b/src/modules/m_inviteexception.cpp
@@ -19,6 +19,8 @@
* ignoring if +i is set on the channel
*/
+class InspIRCd* ServerInstance;
+
class InviteException : public ListModeBase
{
public:
@@ -47,7 +49,7 @@ public:
virtual void On005Numeric(std::string &output)
{
output.append(" INVEX=I");
- InsertMode(output, "I", 1);
+ ServerInstance->ModeGrok->InsertMode(output, "I", 1);
}
virtual int OnCheckInvite(userrec* user, chanrec* chan)
diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp
index c93286861..60794c804 100644
--- a/src/modules/m_joinflood.cpp
+++ b/src/modules/m_joinflood.cpp
@@ -250,7 +250,7 @@ class ModuleJoinFlood : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output, "j", 3);
+ ServerInstance->ModeGrok->InsertMode(output, "j", 3);
}
virtual ~ModuleJoinFlood()
diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp
index c61f6484f..268b8d5f7 100644
--- a/src/modules/m_kicknorejoin.cpp
+++ b/src/modules/m_kicknorejoin.cpp
@@ -10,6 +10,8 @@
/* $ModDesc: Provides channel mode +J (delay rejoin after kick) */
+extern InspIRCd* ServerInstance;
+
inline int strtoint(const std::string &str)
{
std::istringstream ss(str);
@@ -166,7 +168,7 @@ public:
virtual void On005Numeric(std::string &output)
{
- InsertMode(output, "J", 3);
+ ServerInstance->ModeGrok->InsertMode(output, "J", 3);
}
virtual ~ModuleKickNoRejoin()
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index 9e505b14d..ce956b9e0 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -126,7 +126,7 @@ class ModuleKnock : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"K",4);
+ ServerInstance->ModeGrok->InsertMode(output,"K",4);
}
virtual ~ModuleKnock()
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index 53c9500db..7dfe9b943 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -26,6 +26,8 @@ using namespace std;
/* $ModDesc: Provides channel mode +f (message flood protection) */
+extern InspIRCd* ServerInstance;
+
class floodsettings : public classbase
{
public:
@@ -268,7 +270,7 @@ class ModuleMsgFlood : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output, "f", 3);
+ ServerInstance->ModeGrok->InsertMode(output, "f", 3);
}
virtual ~ModuleMsgFlood()
diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp
index d75ded180..dd35f88a8 100644
--- a/src/modules/m_noctcp.cpp
+++ b/src/modules/m_noctcp.cpp
@@ -25,6 +25,8 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style channel mode +c */
+extern InspIRCd* ServerInstance;
+
class NoCTCP : public ModeHandler
{
public:
@@ -75,7 +77,7 @@ class ModuleNoCTCP : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"C",4);
+ ServerInstance->ModeGrok->InsertMode(output,"C",4);
}
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
diff --git a/src/modules/m_noinvite.cpp b/src/modules/m_noinvite.cpp
index 2cf3954fe..1d14f1c9b 100644
--- a/src/modules/m_noinvite.cpp
+++ b/src/modules/m_noinvite.cpp
@@ -25,6 +25,8 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style channel mode +V */
+extern InspIRCd* ServerInstance;
+
class NoInvite : public ModeHandler
{
public:
@@ -74,7 +76,7 @@ class ModuleNoInvite : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"V",4);
+ ServerInstance->ModeGrok->InsertMode(output,"V",4);
}
diff --git a/src/modules/m_nokicks.cpp b/src/modules/m_nokicks.cpp
index c1cc9670f..c1151472d 100644
--- a/src/modules/m_nokicks.cpp
+++ b/src/modules/m_nokicks.cpp
@@ -25,6 +25,8 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style channel mode +Q */
+extern InspIRCd* ServerInstance;
+
class NoKicks : public ModeHandler
{
public:
@@ -75,7 +77,7 @@ class ModuleNoKicks : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"Q",4);
+ ServerInstance->ModeGrok->InsertMode(output,"Q",4);
}
virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type)
diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp
index 9d1ddb0ff..7b134b71e 100644
--- a/src/modules/m_nonicks.cpp
+++ b/src/modules/m_nonicks.cpp
@@ -89,7 +89,7 @@ class ModuleNoNickChange : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"N",4);
+ ServerInstance->ModeGrok->InsertMode(output,"N",4);
}
virtual int OnUserPreNick(userrec* user, const std::string &newnick)
diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp
index 673915ee8..7a2229ccd 100644
--- a/src/modules/m_nonotice.cpp
+++ b/src/modules/m_nonotice.cpp
@@ -25,6 +25,8 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style channel mode +T */
+extern InspIRCd* ServerInstance;
+
class NoNotice : public ModeHandler
{
public:
@@ -96,7 +98,7 @@ class ModuleNoNotice : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"T",4);
+ ServerInstance->ModeGrok->InsertMode(output,"T",4);
}
virtual ~ModuleNoNotice()
diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp
index 8d066b211..1aace393c 100644
--- a/src/modules/m_operchans.cpp
+++ b/src/modules/m_operchans.cpp
@@ -25,6 +25,8 @@ using namespace std;
/* $ModDesc: Provides support for oper-only chans via the +O channel mode */
+extern InspIRCd* ServerInstance;
+
class OperChans : public ModeHandler
{
public:
@@ -75,7 +77,7 @@ class ModuleOperChans : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"O",4);
+ ServerInstance->ModeGrok->InsertMode(output,"O",4);
}
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp
index c143cab52..643d972d1 100644
--- a/src/modules/m_redirect.cpp
+++ b/src/modules/m_redirect.cpp
@@ -126,7 +126,7 @@ class ModuleRedirect : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output, "L", 3);
+ ServerInstance->ModeGrok->InsertMode(output, "L", 3);
}
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
diff --git a/src/modules/m_services.cpp b/src/modules/m_services.cpp
index 2a7656f2f..33748450d 100644
--- a/src/modules/m_services.cpp
+++ b/src/modules/m_services.cpp
@@ -29,6 +29,8 @@ static bool kludgeme = false;
/* $ModDesc: Povides support for services +r user/chan modes and more */
+extern InspIRCd* ServerInstance;
+
class Channel_r : public ModeHandler
{
Server* Srv;
@@ -188,7 +190,7 @@ class ModuleServices : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output, "rRM", 4);
+ ServerInstance->ModeGrok->InsertMode(output, "rRM", 4);
}
/* <- :stitch.chatspike.net 307 w00t w00t :is a registered nick */
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index c545e26b6..d712a0ec7 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -27,6 +27,8 @@ using namespace std;
/* $ModDesc: Povides support for ircu-style services accounts, including chmode +R, etc. */
+extern InspIRCd* ServerInstance;
+
class AChannel_R : public ModeHandler
{
public:
@@ -131,7 +133,7 @@ class ModuleServicesAccount : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output, "RM", 4);
+ ServerInstance->ModeGrok->InsertMode(output, "RM", 4);
}
/* <- :twisted.oscnet.org 330 w00t2 w00t2 w00t :is logged in as */
diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp
index d2b26cbe0..c844e4e01 100644
--- a/src/modules/m_sslmodes.cpp
+++ b/src/modules/m_sslmodes.cpp
@@ -8,6 +8,8 @@
static char* dummy;
+extern InspIRCd* ServerInstance;
+
class SSLMode : public ModeHandler
{
Server* Srv;
@@ -75,7 +77,7 @@ class ModuleSSLModes : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output, "z", 4);
+ ServerInstance->ModeGrok->InsertMode(output, "z", 4);
}
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp
index 98c5945a7..05ffd201c 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -26,6 +26,8 @@ using namespace std;
/* $ModDesc: Provides channel +S mode (strip ansi colour) */
+extern InspIRCd* ServerInstance;
+
class ChannelStripColor : public ModeHandler
{
public:
@@ -118,7 +120,7 @@ class ModuleStripColor : public Module
virtual void On005Numeric(std::string &output)
{
- InsertMode(output,"S",4);
+ ServerInstance->ModeGrok->InsertMode(output,"S",4);
}
virtual ~ModuleStripColor()