summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@drink-coca-cola.info>2010-05-14 20:35:38 -0400
committerAdam <Adam@anope.org>2010-06-18 21:01:53 -0400
commitf049124905bd9f53439293e873003cb027a17b91 (patch)
tree352ed9251fd47055dd770aa2d5eabb20247e4b43
parent81a45520a773732c9f46785f27aa1956150775d7 (diff)
Rewrote the hashing system to use std::tr1::unordered_map
-rw-r--r--docs/WIN32.txt16
-rw-r--r--include/Makefile2
-rw-r--r--include/account.h15
-rw-r--r--include/bots.h24
-rw-r--r--include/channels.h4
-rw-r--r--include/commands.h62
-rw-r--r--include/extern.h50
-rw-r--r--include/hashcomp.h58
-rw-r--r--include/messages.h22
-rw-r--r--include/modules.h196
-rw-r--r--include/regchannel.h4
-rw-r--r--include/services.h25
-rw-r--r--include/users.h11
-rw-r--r--src/Makefile2
-rw-r--r--src/actions.c26
-rw-r--r--src/bots.cpp67
-rw-r--r--src/botserv.c90
-rw-r--r--src/channels.c151
-rw-r--r--src/chanserv.c282
-rw-r--r--src/command.cpp10
-rw-r--r--src/commands.c113
-rw-r--r--src/config.c8
-rw-r--r--src/core/bs_act.c2
-rw-r--r--src/core/bs_assign.c2
-rw-r--r--src/core/bs_badwords.c2
-rw-r--r--src/core/bs_bot.c2
-rw-r--r--src/core/bs_botlist.c44
-rw-r--r--src/core/bs_help.c4
-rw-r--r--src/core/bs_info.c27
-rw-r--r--src/core/bs_kick.c2
-rw-r--r--src/core/bs_say.c2
-rw-r--r--src/core/bs_set.c2
-rw-r--r--src/core/bs_unassign.c2
-rw-r--r--src/core/cs_access.c4
-rw-r--r--src/core/cs_akick.c49
-rw-r--r--src/core/cs_ban.c4
-rw-r--r--src/core/cs_clear.c2
-rw-r--r--src/core/cs_drop.c4
-rw-r--r--src/core/cs_forbid.c6
-rw-r--r--src/core/cs_getkey.c2
-rw-r--r--src/core/cs_help.c4
-rw-r--r--src/core/cs_info.c2
-rw-r--r--src/core/cs_invite.c2
-rw-r--r--src/core/cs_kick.c4
-rw-r--r--src/core/cs_list.c88
-rw-r--r--src/core/cs_modes.c32
-rw-r--r--src/core/cs_register.c4
-rw-r--r--src/core/cs_set.c8
-rw-r--r--src/core/cs_status.c2
-rw-r--r--src/core/cs_suspend.c8
-rw-r--r--src/core/cs_topic.c10
-rw-r--r--src/core/cs_unban.c2
-rw-r--r--src/core/cs_xop.c14
-rw-r--r--src/core/db_plain.cpp444
-rw-r--r--src/core/hs_del.c2
-rw-r--r--src/core/hs_delall.c2
-rw-r--r--src/core/hs_group.c2
-rw-r--r--src/core/hs_help.c4
-rw-r--r--src/core/hs_list.c69
-rw-r--r--src/core/hs_off.c2
-rw-r--r--src/core/hs_on.c2
-rw-r--r--src/core/hs_set.c2
-rw-r--r--src/core/hs_setall.c2
-rw-r--r--src/core/ms_cancel.c2
-rw-r--r--src/core/ms_check.c2
-rw-r--r--src/core/ms_del.c2
-rw-r--r--src/core/ms_help.c4
-rw-r--r--src/core/ms_info.c2
-rw-r--r--src/core/ms_list.c2
-rw-r--r--src/core/ms_read.c2
-rw-r--r--src/core/ms_rsend.c2
-rw-r--r--src/core/ms_send.c2
-rw-r--r--src/core/ms_sendall.c20
-rw-r--r--src/core/ms_set.c2
-rw-r--r--src/core/ms_staff.c17
-rw-r--r--src/core/ns_access.c2
-rw-r--r--src/core/ns_alist.c36
-rw-r--r--src/core/ns_drop.c6
-rw-r--r--src/core/ns_forbid.c4
-rw-r--r--src/core/ns_getemail.c23
-rw-r--r--src/core/ns_getpass.c6
-rw-r--r--src/core/ns_ghost.c2
-rw-r--r--src/core/ns_group.c8
-rw-r--r--src/core/ns_help.c4
-rw-r--r--src/core/ns_identify.c4
-rw-r--r--src/core/ns_info.c2
-rw-r--r--src/core/ns_list.c95
-rw-r--r--src/core/ns_logout.c2
-rw-r--r--src/core/ns_recover.c2
-rw-r--r--src/core/ns_register.c6
-rw-r--r--src/core/ns_release.c2
-rw-r--r--src/core/ns_resetpass.c2
-rw-r--r--src/core/ns_saset.c4
-rw-r--r--src/core/ns_sendpass.c2
-rw-r--r--src/core/ns_set.c2
-rw-r--r--src/core/ns_status.c2
-rw-r--r--src/core/ns_suspend.c8
-rw-r--r--src/core/ns_update.c2
-rw-r--r--src/core/os_akill.c4
-rw-r--r--src/core/os_chankill.c4
-rw-r--r--src/core/os_chanlist.c31
-rw-r--r--src/core/os_clearmodes.c4
-rw-r--r--src/core/os_defcon.c24
-rw-r--r--src/core/os_global.c4
-rw-r--r--src/core/os_help.c4
-rw-r--r--src/core/os_ignore.c2
-rw-r--r--src/core/os_jupe.c4
-rw-r--r--src/core/os_kick.c6
-rw-r--r--src/core/os_mode.c6
-rw-r--r--src/core/os_modinfo.c49
-rw-r--r--src/core/os_modlist.c109
-rw-r--r--src/core/os_modload.c12
-rw-r--r--src/core/os_modunload.c12
-rw-r--r--src/core/os_news.c6
-rw-r--r--src/core/os_noop.c12
-rw-r--r--src/core/os_oline.c8
-rw-r--r--src/core/os_quit.c2
-rw-r--r--src/core/os_reload.c2
-rw-r--r--src/core/os_restart.c2
-rw-r--r--src/core/os_session.c19
-rw-r--r--src/core/os_set.c10
-rw-r--r--src/core/os_sgline.c4
-rw-r--r--src/core/os_shutdown.c2
-rw-r--r--src/core/os_sqline.c4
-rw-r--r--src/core/os_staff.c6
-rw-r--r--src/core/os_stats.c2
-rw-r--r--src/core/os_svsnick.c4
-rw-r--r--src/core/os_szline.c4
-rw-r--r--src/core/os_umode.c6
-rw-r--r--src/core/os_update.c2
-rw-r--r--src/core/os_userlist.c32
-rw-r--r--src/core/ss_main.c19
-rw-r--r--src/hashcomp.cpp43
-rw-r--r--src/hostserv.c33
-rw-r--r--src/init.c90
-rw-r--r--src/log.c2
-rw-r--r--src/main.c19
-rw-r--r--src/memoserv.c4
-rw-r--r--src/messages.c22
-rw-r--r--src/misc.c21
-rw-r--r--src/module.cpp151
-rw-r--r--src/modulemanager.cpp35
-rw-r--r--src/modules.c496
-rw-r--r--src/modules/cs_appendtopic.c2
-rw-r--r--src/modules/cs_enforce.c2
-rw-r--r--src/modules/cs_tban.c2
-rw-r--r--src/modules/hs_request.c10
-rw-r--r--src/modules/mysql/db_mysql.h7
-rw-r--r--src/modules/mysql/db_mysql_execute.cpp25
-rw-r--r--src/modules/mysql/db_mysql_read.cpp8
-rw-r--r--src/modules/mysql/db_mysql_write.cpp174
-rw-r--r--src/modules/ns_maxemail.c13
-rw-r--r--src/modules/os_info.c27
-rw-r--r--src/nickalias.cpp24
-rw-r--r--src/nickcore.cpp13
-rw-r--r--src/nickserv.c343
-rw-r--r--src/operserv.c60
-rw-r--r--src/process.c29
-rw-r--r--src/protocol/bahamut.c62
-rw-r--r--src/protocol/inspircd11.c79
-rw-r--r--src/protocol/inspircd12.cpp103
-rw-r--r--src/protocol/ratbox.c60
-rw-r--r--src/protocol/unreal32.c139
-rw-r--r--src/regchannel.cpp14
-rw-r--r--src/servers.cpp10
-rw-r--r--src/sessions.c78
-rw-r--r--src/users.c210
167 files changed, 2136 insertions, 3091 deletions
diff --git a/docs/WIN32.txt b/docs/WIN32.txt
index c9035dfd0..102c36702 100644
--- a/docs/WIN32.txt
+++ b/docs/WIN32.txt
@@ -25,28 +25,20 @@ Anope for Windows
(NOTE: When installing, tell CMake to add itself to the PATH.)
- If you have Visual C++ 6, 7 (.NET 2002/2003), 8 (2005), or 9 (2008) skip ahead to step 2, else you
+ If you have Visual C++ 10 (2010) skip ahead to step 2, else you
need to download the following free components from Microsoft. Once
downloaded, install these packages.
- * Microsoft Visual C++ 2008 Express Edition:
+ * Microsoft Visual C++ 2010 Express Edition:
http://www.microsoft.com/express/vc/
or
- * Microsoft Visual C++ 2005 Express Edition:
- http://www.microsoft.com/downloads/details.aspx?FamilyId=7B0B0339-613A-46E6-AB4D-080D4D4A8C4E&displaylang=en
-
then download and install:
* Microsoft Windows 2008 SDK:
http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&displaylang=en
- or (if you prefer a smaller download)
-
- * Microsoft Windows 2003 Platform SDK: (Requires WGA validation)
- http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en
-
(NOTE: Although they say for Windows Server 2003 or 2008, they do infact work on all supported
versions of Windows. When installing the 2003 SDK, you should select the Custom option, and only select
to have the Microsoft Windows Core SDK installed. When installing the 2008 SDK, you should select the
@@ -54,10 +46,6 @@ Anope for Windows
the Visual C++ Compilers as well as the Mobile Tools. Doing this will decrease the install time as well
as the space used by the SDK.)
- If you chose to download the 2003 SDK, it will not work out-of-the-box on either Visual C++ 2005 Express or
- Visual C++ 2008 Express. The 2008 SDK will work out-of-the-box with Visual C++ 2008 Express but not with
- Visual C++ 2005 Express.
-
2) Unpack the Anope tarball with your favorite uncompression program
(WinZip or WinRAR, etc).
diff --git a/include/Makefile b/include/Makefile
index 3d8067aa6..69e2473f6 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -1,7 +1,7 @@
all: services.h extern.h pseudo.h version.h
-version.h: Makefile version.sh services.h pseudo.h messages.h $(SRCS)
+version.h: Makefile version.sh services.h pseudo.h $(SRCS)
sh version.sh ../version.log $@
services.h: sysconf.h config.h extern.h
diff --git a/include/account.h b/include/account.h
index 5449bd93a..1a567c317 100644
--- a/include/account.h
+++ b/include/account.h
@@ -1,3 +1,14 @@
+class NickAlias;
+class NickCore;
+class NickRequest;
+
+typedef unordered_map_namespace::unordered_map<ci::string, NickAlias *, hash_compare_ci_string> nickalias_map;
+typedef unordered_map_namespace::unordered_map<ci::string, NickCore *, hash_compare_ci_string> nickcore_map;
+typedef unordered_map_namespace::unordered_map<ci::string, NickRequest *, hash_compare_ci_string> nickrequest_map;
+
+extern CoreExport nickalias_map NickAliasList;
+extern CoreExport nickcore_map NickCoreList;
+extern CoreExport nickrequest_map NickRequestList;
/* NickServ nickname structures. */
@@ -76,7 +87,6 @@ class CoreExport NickRequest : public Extensible
~NickRequest();
- NickRequest *next, *prev;
char *nick;
std::string passcode;
std::string password;
@@ -100,7 +110,6 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag>
*/
~NickAlias();
- NickAlias *next, *prev;
char *nick; /* Nickname */
char *last_quit; /* Last quit message */
char *last_realname; /* Last realname */
@@ -135,8 +144,6 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag>
*/
~NickCore();
- NickCore *next, *prev;
-
std::list<User *> Users;
char *display; /* How the nick is displayed */
diff --git a/include/bots.h b/include/bots.h
index 3b4987bb7..b73b39879 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -8,6 +8,12 @@
*
*/
+#include "commands.h"
+
+class BotInfo;
+typedef unordered_map_namespace::unordered_map<ci::string, BotInfo *, hash_compare_ci_string> botinfo_map;
+extern CoreExport botinfo_map BotList;
+
/** Flags settable on a bot
*/
enum BotFlag
@@ -16,29 +22,13 @@ enum BotFlag
/* This bot can only be assigned by IRCops */
BI_PRIVATE,
- /* The following flags are used to determin what bot really is what.
- * Since you *could* have ChanServ really named BotServ or something stupid,
- * this keeps track of them and allows them to be renamed in the config
- * at any time, even if they already exist in the database
- */
- BI_CHANSERV,
- BI_BOTSERV,
- BI_HOSTSERV,
- BI_OPERSERV,
- BI_MEMOSERV,
- BI_NICKSERV,
- BI_GLOBAL,
BI_END
};
-struct CommandHash;
-
class CoreExport BotInfo : public Extensible, public Flags<BotFlag>
{
public:
- BotInfo *next, *prev;
-
std::string uid; /* required for UID supporting servers, as opposed to the shitty struct Uid. */
std::string nick; /* Nickname of the bot */
std::string user; /* Its user name */
@@ -48,7 +38,7 @@ class CoreExport BotInfo : public Extensible, public Flags<BotFlag>
int16 chancount; /* Number of channels that use the bot. */
/* Dynamic data */
time_t lastmsg; /* Last time we said something */
- CommandHash **cmdTable;
+ CommandMap Commands;
/** Create a new bot.
* @param nick The nickname to assign to the bot.
diff --git a/include/channels.h b/include/channels.h
index 51b830c03..4285a9f21 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -8,6 +8,9 @@
*
*/
+typedef unordered_map_namespace::unordered_map<ci::string, Channel *, hash_compare_ci_string> channel_map;
+extern CoreExport channel_map ChannelList;
+
struct UserData
{
UserData()
@@ -72,7 +75,6 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
*/
~Channel();
- Channel *next, *prev;
std::string name; /* Channel name */
ChannelInfo *ci; /* Corresponding ChannelInfo */
time_t creation_time; /* When channel was created */
diff --git a/include/commands.h b/include/commands.h
index 5d43f556b..5d381084e 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -14,25 +14,13 @@
#ifndef COMMAND_H_
#define COMMAND_H_
-#define MAX_CMD_HASH 1024
-#define CMD_HASH(x) (((x)[0]&31)<<5 | ((x)[1]&31)) /* Will gen a hash from a string :) */
-
-#define HOSTSERV HS_cmdTable /* using HOSTSERV etc. looks nicer than HS_cmdTable for modules */
-#define BOTSERV BS_cmdTable
-#define MEMOSERV MS_cmdTable
-#define NICKSERV NS_cmdTable
-#define CHANSERV CS_cmdTable
-#define OPERSERV OS_cmdTable
-
-#ifndef _WIN32
-#define MDE
-#else
-#ifndef MODULE_COMPILE
-#define MDE __declspec(dllexport)
-#else
-#define MDE __declspec(dllimport)
-#endif
-#endif
+#include "services.h"
+
+class Module;
+class BotInfo;
+class Command;
+
+typedef std::map<ci::string, Command *> CommandMap;
/** The return value from commands.
* */
@@ -42,24 +30,9 @@ enum CommandReturn
MOD_STOP
};
-class Command;
-
-extern MDE Command *lookup_cmd(Command *list, char *name);
-extern MDE void mod_help_cmd(char *service, User *u, CommandHash *cmdTable[], const char *cmd);
-extern MDE void mod_run_cmd(const std::string &service, User *u, CommandHash *cmdTable[], const char *cmd);
-
-struct CommandHash {
- char *name; /* Name of the command */
- Command *c; /* Actual command */
- CommandHash *next; /* Next command */
-};
-
-extern MDE CommandHash *HOSTSERV[MAX_CMD_HASH];
-extern MDE CommandHash *BOTSERV[MAX_CMD_HASH];
-extern MDE CommandHash *MEMOSERV[MAX_CMD_HASH];
-extern MDE CommandHash *NICKSERV[MAX_CMD_HASH];
-extern MDE CommandHash *CHANSERV[MAX_CMD_HASH];
-extern MDE CommandHash *OPERSERV[MAX_CMD_HASH];
+extern CoreExport Command *FindCommand(BotInfo *bi, const ci::string &cmd);
+extern CoreExport void mod_help_cmd(BotInfo *bi, User *u, const ci::string &cmd);
+extern CoreExport void mod_run_cmd(BotInfo *bi, User *u, const ci::string &cmd);
enum CommandFlag
{
@@ -76,11 +49,20 @@ enum CommandFlag
class CoreExport Command : public Flags<CommandFlag>
{
public:
+ /* Maximum paramaters accepted by this command */
size_t MaxParams;
+ /* Minimum parameters required to use this command */
size_t MinParams;
+ /* Command name */
ci::string name;
+ /* Permission needed to use this comand */
std::string permission;
+ /* Module which owns us */
+ Module *module;
+ /* Service this command is on */
+ BotInfo *service;
+
/** Create a new command.
* @param sname The command name
* @param min_params The minimum number of parameters the parser will require to execute this command
@@ -114,12 +96,6 @@ class CoreExport Command : public Flags<CommandFlag>
* @param reststr The permission required to successfully execute this command
*/
void SetPermission(const std::string &reststr);
-
- /* Module related stuff */
- int core; /* Can this command be deleted? */
- char *mod_name; /* Name of the module who owns us, NULL for core's */
- char *service; /* Service we provide this command for */
- Command *next;
};
#endif
diff --git a/include/extern.h b/include/extern.h
index 67364c0f5..a10585e69 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -46,14 +46,14 @@ E BotInfo *OperServ;
/**** botserv.c ****/
-E BotInfo *botlists[256];
-E int nbots;
E void get_botserv_stats(long *nrec, long *memuse);
E void bs_init();
E void botserv(User *u, char *buf);
E void botmsgs(User *u, BotInfo *bi, char *buf);
E void botchanmsgs(User *u, ChannelInfo *ci, char *buf);
+E BotInfo *findbot(const char *nick);
E BotInfo *findbot(const std::string &nick);
+E BotInfo *findbot(const ci::string &nick);
/** Finds a pseudoclient, given a UID. Useful for TS6 protocol modules.
* @param uid The UID to search for
@@ -61,7 +61,6 @@ E BotInfo *findbot(const std::string &nick);
*/
E void bot_join(ChannelInfo *ci);
E char *normalizeBuffer(const char *);
-E void insert_bot(BotInfo * bi);
E void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, const char *reason);
E void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, const char *reason);
@@ -69,12 +68,11 @@ E void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, char *
/**** channels.c ****/
-E Channel *chanlist[1024];
-
E void get_channel_stats(long *nrec, long *memuse);
+
E Channel *findchan(const char *chan);
-E Channel *firstchan();
-E Channel *nextchan();
+E Channel *findchan(const std::string &chan);
+E Channel *findchan(const ci::string &chan);
E void ChanSetInternalModes(Channel *c, int ac, const char **av);
@@ -112,12 +110,10 @@ E long get_memuse(EList *list);
/**** chanserv.c ****/
-E ChannelInfo *chanlists[256];
E LevelInfo levelinfo[];
E void get_chanserv_stats(long *nrec, long *memuse);
-E void alpha_insert_chan(ChannelInfo * ci);
E void reset_levels(ChannelInfo * ci);
E void cs_init();
E void chanserv(User * u, char *buf);
@@ -136,7 +132,9 @@ E void record_topic(const char *chan);
E void restore_topic(const char *chan);
E int check_topiclock(Channel * c, time_t topic_time);
+E ChannelInfo *cs_findchan(const char *chan);
E ChannelInfo *cs_findchan(const std::string &chan);
+E ChannelInfo *cs_findchan(const ci::string &chan);
E int check_access(User * user, ChannelInfo * ci, int what);
E bool IsFounder(User *user, ChannelInfo *ci);
E bool IsRealFounder(User *user, ChannelInfo *ci);
@@ -359,18 +357,11 @@ E std::map<ChannelModeName, std::string> DefMLockParams;
E std::list<ChannelModeStatus *> BotModes;
E void SetDefaultMLock();
-/**** modules.c ****/
-E void modules_unload_all(bool unload_proto); /* Read warnings near function source */
-
/**** nickserv.c ****/
-E NickAlias *nalists[1024];
-E NickCore *nclists[1024];
-E NickRequest *nrlists[1024];
E NickRequest *findrequestnick(const char *nick);
-E void insert_requestnick(NickRequest * nr);
-E void alpha_insert_alias(NickAlias * na);
-E void insert_core(NickCore * nc);
+E NickRequest *findrequestnick(const std::string &nick);
+E NickRequest *findrequestnick(const ci::string &nick);
E void get_aliases_stats(long *nrec, long *memuse);
E void get_core_stats(long *nrec, long *memuse);
E void change_core_display(NickCore * nc);
@@ -384,7 +375,10 @@ E void expire_nicks();
E void expire_requests();
E NickAlias *findnick(const char *nick);
E NickAlias *findnick(const std::string &nick);
-E NickCore *findcore(const char *nick);
+E NickAlias *findnick(const ci::string &nick);
+E NickCore *findcore(const char *nick);
+E NickCore *findcore(const std::string &nick);
+E NickCore *findcore(const ci::string &nick);
E bool is_on_access(User *u, NickCore *nc);
/**** operserv.c ****/
@@ -462,9 +456,6 @@ E void notice_help(const char *source, User *dest, int message, ...); // MARK_DE
E Exception *exceptions;
E int16 nexceptions;
-E Session *sessionlist[1024];
-E int32 nsessions;
-
E void get_session_stats(long *nrec, long *memuse);
E void get_exception_stats(long *nrec, long *memuse);
@@ -473,7 +464,7 @@ E void del_session(const char *host);
E void expire_exceptions();
-E Session *findsession(const char *host);
+E Session *findsession(const std::string &host);
E Exception *find_host_exception(const char *host);
E Exception *find_hostip_exception(const char *host, const char *hostip);
@@ -501,20 +492,19 @@ E int32 TotalWritten;
/**** users.c ****/
-E User *userlist[1024];
-
E int32 opcnt;
E uint32 maxusercnt, usercnt;
E time_t maxusertime;
E void get_user_stats(long *nusers, long *memuse);
-E User *finduser(const std::string &nick);
-E User *firstuser();
-E User *nextuser();
+E User *finduser(const char *nick);
+E User *finduser(const std::string &nick);
+E User *finduser(const ci::string &nick);
+E User *find_byuid(const char *uid);
+E User *find_byuid(const ci::string &uid);
E User *find_byuid(const std::string &uid);
-E User *first_uid();
-E User *next_uid();
+
E Server *findserver_uid(Server * s, const char *name);
E char *TS6SID;
diff --git a/include/hashcomp.h b/include/hashcomp.h
index becebb48e..a0d456b40 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -15,6 +15,23 @@
#include <string>
+#ifndef _WIN32
+ #ifdef HASHMAP_DEPRECATED /* If gcc ver > 4.3 */
+ /* GCC4.3+ has deprecated hash_map and uses tr1. But of course, uses a different include to MSVC. */
+ #include <tr1/unordered_map>
+ #define unordered_map_namespace std::tr1
+ #else
+ #include <ext/hash_map>
+ /* Oddball linux namespace for hash_map */
+ #define unordered_map_namespace __gnu_cxx
+ #define unordered_map hash_map
+ #endif
+#else
+ /* MSVC 2010+ has tr1. Though MSVC and GCC use different includes! */
+ #include <unordered_map>
+ #define unordered_map_namespace std::tr1
+#endif
+
/*******************************************************
* This file contains classes and templates that deal
* with the comparison and hashing of 'irc strings'.
@@ -30,9 +47,6 @@
* aware of irc::string.
*******************************************************/
-#ifndef LOWERMAP
-#define LOWERMAP
-
/** A mapping of uppercase to lowercase, including scandinavian
* 'oddities' as specified by RFC1459, e.g. { -> [, and | -> \
*/
@@ -72,8 +86,6 @@ unsigned const char ascii_case_insensitive_map[256] = {
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 /* 240-255 */
};
-#endif
-
/** The irc namespace contains a number of helper classes.
*/
namespace irc
@@ -470,4 +482,40 @@ class spacesepstream : public sepstream
spacesepstream(const char *source) : sepstream(source, ' ') { }
};
+/** Class used to hash a std::string, given as the third argument to the unordered_map template
+ */
+class CoreExport hash_compare_std_string
+{
+ public:
+ /** Return a hash value for a string
+ * @param s The string
+ * @return The hash value
+ */
+ size_t operator()(const std::string &s) const;
+};
+
+/** Class used to hash a ci::string, given as the third argument to the unordered_map template
+ */
+class CoreExport hash_compare_ci_string
+{
+ public:
+ /** Return a hash value for a string using case insensitivity
+ * @param s The string
+ * @return The hash value
+ */
+ size_t operator()(const ci::string &s) const;
+};
+
+/** Class used to hash a irc::string, given as the third argument to the unordered_map template
+ */
+class CoreExport hash_compare_irc_string
+{
+ public:
+ /** Return a hash value for a string using RFC1459 case sensitivity rules
+ * @param s The stirng
+ * @return The hash value
+ */
+ size_t operator()(const irc::string &s) const;
+};
+
#endif
diff --git a/include/messages.h b/include/messages.h
deleted file mode 100644
index a5505471e..000000000
--- a/include/messages.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Declarations of IRC message structures, variables, and functions.
- *
- * (C) 2003-2010 Anope Team
- * Contact us at team@anope.org
- *
- * Please read COPYING and README for furhter details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- *
- *
- */
-
-/*************************************************************************/
-#include "modules.h"
-
-extern Message messages[];
-extern void moduleAddMsgs();
-extern Message *find_message(const char *name);
-
-
-/*************************************************************************/
diff --git a/include/modules.h b/include/modules.h
index f3bc20bfb..d76b8f70b 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -104,52 +104,6 @@ do { \
} \
} while(0);
-
-
-/** Priority types which can be returned from Module::Prioritize()
- */
-enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER };
-
-
-
-/*************************************************************************/
-
-#define IRCD IRCD_cmdTable
-#define MODULE_HASH Module_table
-#define EVENT EVENT_cmdTable
-#define EVENTHOOKS HOOK_cmdTable
-
-/**********************************************************************
- * Module Returns
- **********************************************************************/
-#define MOD_ERR_OK 0
-#define MOD_ERR_MEMORY 1
-#define MOD_ERR_PARAMS 2
-#define MOD_ERR_EXISTS 3
-#define MOD_ERR_NOEXIST 4
-#define MOD_ERR_NOUSER 5
-#define MOD_ERR_NOLOAD 6
-#define MOD_ERR_NOUNLOAD 7
-#define MOD_ERR_SYNTAX 8
-#define MOD_ERR_NODELETE 9
-#define MOD_ERR_UNKNOWN 10
-#define MOD_ERR_FILE_IO 11
-#define MOD_ERR_NOSERVICE 12
-#define MOD_ERR_NO_MOD_NAME 13
-
-/*************************************************************************/
-/* Macros to export the Module API functions/variables */
-#ifndef _WIN32
-#define MDE
-#else
-#ifndef MODULE_COMPILE
-#define MDE __declspec(dllexport)
-#else
-#define MDE __declspec(dllimport)
-#endif
-#endif
-/*************************************************************************/
-
#if !defined(_WIN32)
#include <dlfcn.h>
/* Define these for systems without them */
@@ -169,26 +123,42 @@ enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFOR
const char *ano_moderr();
#endif
-typedef enum { CORE,PROTOCOL,THIRD,SUPPORTED,QATESTED,ENCRYPTION,DATABASE } MODType;
-typedef enum { MOD_OP_LOAD, MOD_OP_UNLOAD } ModuleOperation;
-
-/*************************************************************************/
-/* Structure for information about a *Serv command. */
+extern CoreExport Module *FindModule(const std::string &name);
+int protocol_module_init();
+extern CoreExport Message *createMessage(const char *name, int (*func)(const char *source, int ac, const char **av));
+std::vector<Message *> FindMessage(const std::string &name);
+extern CoreExport bool moduleMinVersion(int major,int minor,int patch,int build);
-typedef struct ModuleLang_ ModuleLang;
-typedef struct ModuleHash_ ModuleHash;
-typedef struct Message_ Message;
-typedef struct MessageHash_ MessageHash;
+enum ModuleReturn
+{
+ MOD_ERR_OK,
+ MOD_ERR_MEMORY,
+ MOD_ERR_PARAMS,
+ MOD_ERR_EXISTS,
+ MOD_ERR_NOEXIST,
+ MOD_ERR_NOUSER,
+ MOD_ERR_NOLOAD,
+ MOD_ERR_NOUNLOAD,
+ MOD_ERR_SYNTAX,
+ MOD_ERR_NODELETE,
+ MOD_ERR_UNKNOWN,
+ MOD_ERR_FILE_IO,
+ MOD_ERR_NOSERVICE,
+ MOD_ERR_NO_MOD_NAME
+};
-/*************************************************************************/
+/** Priority types which can be returned from Module::Prioritize()
+ */
+enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER };
+enum MODType { CORE, PROTOCOL, THIRD, SUPPORTED, QATESTED, ENCRYPTION, DATABASE };
-extern MDE MessageHash *IRCD[MAX_CMD_HASH];
-extern MDE ModuleHash *MODULE_HASH[MAX_CMD_HASH];
+struct Message;
+extern CoreExport std::multimap<std::string, Message *> MessageMap;
+class Module;
+extern CoreExport std::deque<Module *> Modules;
-struct ModuleLang_ {
- int argc;
- char **argv;
-};
+/*************************************************************************/
+/* Structure for information about a *Serv command. */
class Version
{
@@ -247,15 +217,31 @@ class CoreExport Module
*/
std::list<CallBack *> CallBacks;
+ /** Handle for this module, obtained from dlopen()
+ */
ano_module_t handle;
+
+ /** Time this module was created
+ */
time_t created;
+
+ /** Version of this module
+ */
std::string version;
+
+ /** Author of the module
+ */
std::string author;
+ /** What type this module is
+ */
MODType type;
- MessageHash *msgList[MAX_CMD_HASH];
- ModuleLang lang[NUM_LANGS];
+ struct ModuleLang
+ {
+ int argc;
+ char **argv;
+ } lang[NUM_LANGS];
/** Creates and initialises a new module.
* @param loadernick The nickname of the user loading the module.
@@ -299,7 +285,7 @@ class CoreExport Module
* compiled against
* @return The version
*/
- virtual Version GetVersion() { return Version(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD); }
+ Version GetVersion() { return Version(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD); }
/**
* Allow a module to add a set of language strings to anope
@@ -334,20 +320,19 @@ class CoreExport Module
/**
* Add a module provided command to the given service.
- * e.g. AddCommand(NICKSERV,c,MOD_HEAD);
- * @param cmdTable the services to add the command to
- * @param c the command to add
+ * @param bi The service to add the command to
+ * @param c The command to add
* @return MOD_ERR_OK on successfully adding the command
*/
- int AddCommand(CommandHash *cmdTable[], Command * c);
+ int AddCommand(BotInfo *bi, Command *c);
/**
* Delete a command from the service given.
- * @param cmdTable the cmdTable for the services to remove the command from
- * @param name the name of the command to delete from the service
+ * @param bi The service to remove the command from
+ * @param c Thec command to delete
* @return returns MOD_ERR_OK on success
*/
- int DelCommand(CommandHash * cmdTable[], const char *name);
+ int DelCommand(BotInfo *bi, Command *c);
/** Called on NickServ HELP
* @param u The user requesting help
@@ -434,13 +419,13 @@ class CoreExport Module
virtual void OnUserNickChange(User *u, const std::string &oldnick) { }
/** Called immediatly when a user tries to run a command
- * @param service The service
+ * @param bi The bot the command is being run from
* @param u The user
* @param cmd The command
* @param c The command class (if it exists)
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
*/
- virtual EventReturn OnPreCommandRun(const std::string &service, User *u, const char *cmd, Command *c) { return EVENT_CONTINUE; }
+ virtual EventReturn OnPreCommandRun(BotInfo *bi, User *u, const ci::string &cmd, Command *c) { return EVENT_CONTINUE; }
/** Called before a command is due to be executed.
* @param u The user executing the command
@@ -449,7 +434,7 @@ class CoreExport Module
* @param params The parameters the user is sending
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
*/
- virtual EventReturn OnPreCommand(User *u, const std::string &service, const ci::string &command, const std::vector<ci::string> &params) { return EVENT_CONTINUE; }
+ virtual EventReturn OnPreCommand(User *u, BotInfo *service, const ci::string &command, const std::vector<ci::string> &params) { return EVENT_CONTINUE; }
/** Called after a command has been executed.
* @param u The user executing the command
@@ -457,7 +442,7 @@ class CoreExport Module
* @param command The command the user executed
* @param params The parameters the user sent
*/
- virtual void OnPostCommand(User *u, const std::string &service, const ci::string &command, const std::vector<ci::string> &params) { }
+ virtual void OnPostCommand(User *u, BotInfo *service, const ci::string &command, const std::vector<ci::string> &params) { }
/** Called after the core has finished loading the databases, but before
* we connect to the server
@@ -714,9 +699,9 @@ class CoreExport Module
virtual EventReturn OnPreNickExpire(NickAlias *na) { return EVENT_CONTINUE; }
/** Called when a nick drops
- * @param nick The nick
+ * @param na The nick
*/
- virtual void OnNickExpire(const char *nick) { }
+ virtual void OnNickExpire(NickAlias *na) { }
/** Called when defcon level changes
* @param level The level
@@ -1238,7 +1223,13 @@ class CoreExport ModuleManager
*/
static void ClearCallBacks(Module *m);
-private:
+ /** Unloading all modules, NEVER call this when Anope isn't shutting down.
+ * Ever.
+ * @param unload_proto true to unload the protocol module
+ */
+ static void UnloadAll(bool unload_proto);
+
+ private:
/** Call the module_delete function to safely delete the module
* @param m the module to delete
*/
@@ -1267,51 +1258,10 @@ class CallBack : public Timer
}
};
-struct ModuleHash_ {
- char *name;
- Module *m;
- ModuleHash *next;
-};
-
-struct Message_ {
- char *name;
+struct Message
+{
+ std::string name;
int (*func)(const char *source, int ac, const char **av);
- int core;
- Message *next;
};
-struct MessageHash_ {
- char *name;
- Message *m;
- MessageHash *next;
-};
-
-/*************************************************************************/
-/* Module Managment Functions */
-MDE Module *findModule(const char *name); /* Find a module */
-
-int protocol_module_init(); /* Load the IRCD Protocol Module up*/
-
-/*************************************************************************/
-/*************************************************************************/
-/* Command Managment Functions */
-MDE Command *findCommand(CommandHash *cmdTable[], const char *name); /* Find a command */
-
-/*************************************************************************/
-
-/* Message Managment Functions */
-MDE Message *createMessage(const char *name,int (*func)(const char *source, int ac, const char **av));
-Message *findMessage(MessageHash *msgTable[], const char *name); /* Find a Message */
-MDE int addMessage(MessageHash *msgTable[], Message *m, int pos); /* Add a Message to a Message table */
-MDE int addCoreMessage(MessageHash *msgTable[], Message *m); /* Add a Message to a Message table */
-int delMessage(MessageHash *msgTable[], Message *m); /* Del a Message from a msg table */
-int destroyMessage(Message *m); /* destroy a Message*/
-
-/*************************************************************************/
-
-MDE bool moduleMinVersion(int major,int minor,int patch,int build); /* Checks if the current version of anope is before or after a given verison */
-
-/************************************************************************/
-
#endif
-/* EOF */
diff --git a/include/regchannel.h b/include/regchannel.h
index bd5a50ced..4a571182b 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -8,6 +8,9 @@
*
*/
+typedef unordered_map_namespace::unordered_map<ci::string, ChannelInfo *, hash_compare_ci_string> registered_channel_map;
+extern CoreExport registered_channel_map RegisteredChannelList;
+
/** Flags used for the ChannelInfo class
*/
enum ChannelInfoFlag
@@ -78,7 +81,6 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag>
*/
~ChannelInfo();
- ChannelInfo *next, *prev;
std::string name; /* Channel name */
NickCore *founder;
NickCore *successor; /* Who gets the channel if the founder
diff --git a/include/services.h b/include/services.h
index 4a8eb8d77..c05b44eac 100644
--- a/include/services.h
+++ b/include/services.h
@@ -198,6 +198,7 @@ extern int strncasecmp(const char *, const char *, size_t);
#endif
/* Miscellaneous definitions. */
+#include "hashcomp.h"
#include "defs.h"
#include "slist.h"
@@ -352,12 +353,12 @@ class ChannelInfo;
class Channel;
class Server;
struct EList;
+struct Session;
typedef struct bandata_ BanData;
typedef struct mailinfo_ MailInfo;
typedef struct akill_ Akill;
typedef struct exception_ Exception;
-typedef struct session_ Session;
#include "extensible.h"
#include "threadengine.h"
@@ -827,8 +828,11 @@ struct exception_ {
/*************************************************************************/
-struct session_ {
- Session *prev, *next;
+typedef unordered_map_namespace::unordered_map<std::string, Session *, hash_compare_std_string> session_map;
+extern CoreExport session_map SessionList;
+
+struct Session
+{
char *host;
int count; /* Number of clients with this host */
int hits; /* Number of subsequent kills for a host */
@@ -1054,6 +1058,7 @@ class CoreExport Alog
}
};
+class Message; // XXX
class CoreExport Anope
{
@@ -1065,6 +1070,20 @@ class CoreExport Anope
*/
static bool Match(const std::string &str, const std::string &mask, bool case_sensitive = false);
inline static bool Match(const ci::string &str, const ci::string &mask) { return Match(str.c_str(), mask.c_str(), false); }
+
+ /** Add a message to Anope
+ * @param name The message name as sent by the IRCd
+ * @param func A callback function that will be called when this message is received
+ * @return The new message object
+ */
+ static Message *AddMessage(const std::string &name, int (*func)(const char *source, int ac, const char **av));
+
+ /** Deletes a message from Anope
+ * XXX Im not sure what will happen if this function is called indirectly from message function pointed to by this message.. must check
+ * @param m The message
+ * @return true if the message was found and deleted, else false
+ */
+ static bool DelMessage(Message *m);
};
/*************************************************************************/
diff --git a/include/users.h b/include/users.h
index b11c17875..3937e2ebe 100644
--- a/include/users.h
+++ b/include/users.h
@@ -8,6 +8,15 @@
*
*/
+/* Hash maps used for users. Note UserListByUID will not be used on non-TS6 IRCds, and should never
+ * be assumed to have users
+ */
+typedef unordered_map_namespace::unordered_map<ci::string, User *, hash_compare_ci_string> user_map;
+typedef unordered_map_namespace::unordered_map<std::string, User *, hash_compare_std_string> user_uid_map;
+
+extern CoreExport user_map UserListByNick;
+extern CoreExport user_uid_map UserListByUID;
+
struct ChannelContainer
{
Channel *chan;
@@ -32,8 +41,6 @@ class CoreExport User : public Extensible
NickCore *nc; /* NickCore account the user is currently loggged in as */
public: // XXX: exposing a tiny bit too much
- User *next, *prev;
-
std::string nick; /* User's current nick */
char *host; /* User's real hostname */
diff --git a/src/Makefile b/src/Makefile
index c82f9f5b4..1756e6702 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -6,7 +6,7 @@ OBJS = actions.o base64.o bots.o botserv.o channels.o chanserv.o command.o comm
INCLUDES = ../include/commands.h ../include/defs.h ../include/language.h \
../include/pseudo.h ../include/sysconf.h ../include/config.h \
- ../include/messages.h ../include/services.h \
+ ../include/services.h \
../include/timers.h ../include/extern.h \
../include/modules.h ../include/slist.h ../include/hashcomp.h \
../include/threadengine.h ../include/mail.h
diff --git a/src/actions.c b/src/actions.c
index 471e1273f..e3f199e80 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -77,32 +77,26 @@ void kill_user(const std::string &source, const std::string &user, const std::st
*/
void sqline(const std::string &mask, const std::string &reason)
{
- int i;
- Channel *c, *next;
-
if (ircd->chansqline)
{
if (mask[0] == '#')
{
ircdproto->SendSQLine(mask, reason);
- for (i = 0; i < 1024; ++i)
+ for (channel_map::const_iterator cit = ChannelList.begin(); cit != ChannelList.end(); ++cit)
{
- for (c = chanlist[i]; c; c = next)
+ Channel *c = cit->second;
+
+ if (!Anope::Match(c->name, mask, false))
+ continue;
+ for (CUserList::iterator it = c->users.begin(); it != c->users.end();)
{
- next = c->next;
+ UserContainer *uc = *it;
+ ++it;
- if (!Anope::Match(c->name, mask, false))
+ if (is_oper(uc->user))
continue;
- for (CUserList::iterator it = c->users.begin(); it != c->users.end();)
- {
- UserContainer *uc = *it;
- ++it;
-
- if (is_oper(uc->user))
- continue;
- c->Kick(NULL, uc->user, "%s", reason.c_str());
- }
+ c->Kick(NULL, uc->user, "%s", reason.c_str());
}
}
}
diff --git a/src/bots.cpp b/src/bots.cpp
index 6f544a64a..a8cc86654 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -12,6 +12,8 @@
#include "modules.h"
#include "commands.h"
+botinfo_map BotList;
+
BotInfo *BotServ = NULL;
BotInfo *ChanServ = NULL;
BotInfo *Global = NULL;
@@ -28,54 +30,39 @@ BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::
this->real = nreal;
this->lastmsg = this->created = time(NULL);
this->uid = ts6_uid_retrieve();
- this->cmdTable = NULL;
- ++nbots;
this->chancount = 0;
ci::string ci_nick(nnick.c_str());
if (Config.s_ChanServ && ci_nick == Config.s_ChanServ)
{
ChanServ = this;
- this->cmdTable = CHANSERV;
- this->SetFlag(BI_CHANSERV);
}
else if (Config.s_BotServ && ci_nick == Config.s_BotServ)
{
BotServ = this;
- this->cmdTable = BOTSERV;
- this->SetFlag(BI_BOTSERV);
}
else if (Config.s_HostServ && ci_nick == Config.s_HostServ)
{
HostServ = this;
- this->cmdTable = HOSTSERV;
- this->SetFlag(BI_HOSTSERV);
}
else if (Config.s_OperServ && ci_nick == Config.s_OperServ)
{
OperServ = this;
- this->cmdTable = OPERSERV;
- this->SetFlag(BI_OPERSERV);
}
else if (Config.s_MemoServ && ci_nick == Config.s_MemoServ)
{
MemoServ = this;
- this->cmdTable = MEMOSERV;
- this->SetFlag(BI_MEMOSERV);
}
else if (Config.s_NickServ && ci_nick == Config.s_NickServ)
{
NickServ = this;
- this->cmdTable = NICKSERV;
- this->SetFlag(BI_NICKSERV);
}
else if (Config.s_GlobalNoticer && ci_nick == Config.s_GlobalNoticer)
{
Global = this;
- this->SetFlag(BI_GLOBAL);
}
- insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL.
+ BotList[this->nick.c_str()] = this;
// If we're synchronised with the uplink already, call introduce_user() for this bot.
if (Me && Me->GetUplink()->IsSynced())
@@ -86,48 +73,38 @@ BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::
BotInfo::~BotInfo()
{
- int i;
- ChannelInfo *ci;
-
- for (i = 0; i < 256; ++i)
- for (ci = chanlists[i]; ci; ci = ci->next)
- if (ci->bi == this)
- ci->bi = NULL;
-
- if (this->next)
- this->next->prev = this->prev;
- if (this->prev)
- this->prev->next = this->next;
- else
- botlists[tolower(this->nick[0])] = this->next;
-
- --nbots;
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
+ {
+ ChannelInfo *ci = it->second;
+
+ if (ci->bi == this)
+ {
+ ci->bi = NULL;
+ }
+ }
+
+ BotList.erase(this->nick.c_str());
}
void BotInfo::ChangeNick(const char *newnick)
{
- if (this->next)
- this->next->prev = this->prev;
- if (this->prev)
- this->prev->next = this->next;
- else
- botlists[tolower(this->nick[0])] = this->next;
+ BotList.erase(this->nick.c_str());
this->nick = newnick;
- insert_bot(this);
+ BotList[this->nick.c_str()] = this;
}
void BotInfo::RejoinAll()
{
- int i;
- ChannelInfo *ci;
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
+ {
+ ChannelInfo *ci = it->second;
- for (i = 0; i < 256; ++i)
- for (ci = chanlists[i]; ci; ci = ci->next)
- if (ci->bi == this && ci->c && (ci->c->users.size() >= Config.BSMinUsers))
- bot_join(ci);
+ if (ci->bi == this && ci->c && ci->c->users.size() >= Config.BSMinUsers)
+ bot_join(ci);
+ }
}
void BotInfo::Assign(User *u, ChannelInfo *ci)
diff --git a/src/botserv.c b/src/botserv.c
index d0862c119..ea675ea60 100644
--- a/src/botserv.c
+++ b/src/botserv.c
@@ -18,11 +18,6 @@
/*************************************************************************/
-BotInfo *botlists[256]; /* Hash list of bots */
-int nbots = 0;
-
-/*************************************************************************/
-
static UserData *get_user_data(Channel * c, User * u);
static void check_ban(ChannelInfo * ci, User * u, int ttbtype);
@@ -44,18 +39,17 @@ void moduleAddBotServCmds() {
void get_botserv_stats(long *nrec, long *memuse)
{
long count = 0, mem = 0;
- int i;
- BotInfo *bi;
-
- for (i = 0; i < 256; i++) {
- for (bi = botlists[i]; bi; bi = bi->next) {
- count++;
- mem += sizeof(*bi);
- mem += bi->nick.size() + 1;
- mem += bi->user.size() + 1;
- mem += bi->host.size() + 1;
- mem += bi->real.size() + 1;
- }
+
+ for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it)
+ {
+ BotInfo *bi = it->second;
+
+ count++;
+ mem += sizeof(*bi);
+ mem += bi->nick.size() + 1;
+ mem += bi->user.size() + 1;
+ mem += bi->host.size() + 1;
+ mem += bi->real.size() + 1;
}
*nrec = count;
@@ -90,9 +84,9 @@ void botserv(User * u, char *buf)
if (!(s = strtok(NULL, ""))) {
*s = 0;
}
- ircdproto->SendCTCP(findbot(Config.s_BotServ), u->nick.c_str(), "PING %s", s);
+ ircdproto->SendCTCP(BotServ, u->nick.c_str(), "PING %s", s);
} else {
- mod_run_cmd(Config.s_BotServ, u, BOTSERV, cmd);
+ mod_run_cmd(BotServ, u, cmd);
}
}
@@ -106,7 +100,7 @@ void botmsgs(User * u, BotInfo * bi, char *buf)
char *cmd = strtok(buf, " ");
char *s;
- if (!cmd || !u)
+ if (!cmd || !u || !bi)
return;
if (!stricmp(cmd, "\1PING")) {
@@ -115,9 +109,9 @@ void botmsgs(User * u, BotInfo * bi, char *buf)
}
ircdproto->SendCTCP(bi, u->nick.c_str(), "PING %s", s);
}
- else if (cmd && bi->cmdTable)
+ else if (cmd && !bi->Commands.empty())
{
- mod_run_cmd(bi->nick, u, bi->cmdTable, cmd);
+ mod_run_cmd(bi, u, cmd);
}
}
@@ -134,7 +128,6 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
char *cmd;
UserData *ud;
bool was_action = false;
- Command *command;
std::string bbuf;
if (!u || !buf || !ci || !ci->c)
@@ -424,7 +417,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
if (check_access(u, ci, CA_FANTASIA))
{
- command = findCommand(CHANSERV, cmd);
+ Command *command = FindCommand(ChanServ, cmd);
/* Command exists and can not be called by fantasy */
if (command && !command->HasFlag(CFLAG_DISABLE_FANTASY))
@@ -459,53 +452,22 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
/*************************************************************************/
-/* Inserts a bot in the bot list. I can't be much explicit mh? */
-
-void insert_bot(BotInfo *bi)
+BotInfo *findbot(const char *nick)
{
- BotInfo *ptr, *prev;
-
- ci::string ci_bi_nick(bi->nick.c_str());
- for (prev = NULL, ptr = botlists[tolower(bi->nick[0])];
- ptr != NULL && ci_bi_nick > ptr->nick.c_str();
- prev = ptr, ptr = ptr->next);
- bi->prev = prev;
- bi->next = ptr;
- if (!prev)
- botlists[tolower(bi->nick[0])] = bi;
- else
- prev->next = bi;
- if (ptr)
- ptr->prev = bi;
+ return findbot(ci::string(nick));
}
-/*************************************************************************/
-/*************************************************************************/
-
BotInfo *findbot(const std::string &nick)
{
- BotInfo *bi;
-
- if (nick.empty())
- return NULL;
-
- ci::string ci_nick(nick.c_str());
-
- /*
- * XXX Less than efficient, but we need to do this for good TS6 support currently. This *will* improve. -- w00t
- */
- for (int i = 0; i < 256; i++)
- {
- for (bi = botlists[i]; bi; bi = bi->next)
- {
- if (ci_nick == bi->nick)
- return bi;
+ return findbot(ci::string(nick.c_str()));
+}
- if (ci_nick == bi->uid)
- return bi;
- }
- }
+BotInfo *findbot(const ci::string &nick)
+{
+ botinfo_map::const_iterator it = BotList.find(nick);
+ if (it != BotList.end())
+ return it->second;
return NULL;
}
diff --git a/src/channels.c b/src/channels.c
index a4cf3b167..6250d2342 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -15,11 +15,7 @@
#include "language.h"
#include "modules.h"
-Channel *chanlist[1024];
-
-#define HASH(chan) ((chan)[1] ? ((chan)[1]&31)<<5 | ((chan)[2]&31) : 0)
-
-/*************************************************************************/
+channel_map ChannelList;
/** Default constructor
* @param name The channel name
@@ -27,18 +23,12 @@ Channel *chanlist[1024];
*/
Channel::Channel(const std::string &name, time_t ts)
{
- Channel **list;
-
if (name.empty())
throw CoreException("A channel without a name ?");
this->name = name;
- list = &chanlist[HASH(this->name)];
- this->prev = NULL;
- this->next = *list;
- if (*list)
- (*list)->prev = this;
- *list = this;
+
+ ChannelList[this->name.c_str()] = this;
this->creation_time = ts;
this->topic = NULL;
@@ -102,12 +92,7 @@ Channel::~Channel()
}
}
- if (this->next)
- this->next->prev = this->prev;
- if (this->prev)
- this->prev->next = this->next;
- else
- chanlist[HASH(this->name)] = this->next;
+ ChannelList.erase(this->name.c_str());
}
void Channel::Sync()
@@ -1051,61 +1036,23 @@ char *chan_get_modes(Channel * chan, int complete, int plus)
/*************************************************************************/
-/* Return the Channel structure corresponding to the named channel, or NULL
- * if the channel was not found. chan is assumed to be non-NULL and valid
- * (i.e. pointing to a channel name of 2 or more characters). */
-
Channel *findchan(const char *chan)
{
- Channel *c;
-
- if (!chan || !*chan)
- {
- Alog(LOG_DEBUG) << "findchan() called with NULL values";
- return NULL;
- }
-
- c = chanlist[HASH(chan)];
- while (c)
- {
- if (stricmp(c->name.c_str(), chan) == 0)
- {
- Alog(LOG_DEBUG_3) << "findchan(" << chan << ") -> " << static_cast<void *>(c);
- return c;
- }
- c = c->next;
- }
- return NULL;
+ return findchan(ci::string(chan));
}
-/*************************************************************************/
-
-/* Iterate over all channels in the channel list. Return NULL at end of
- * list.
- */
-
-static Channel *current;
-static int next_index;
-
-Channel *firstchan()
+Channel *findchan(const std::string &chan)
{
- next_index = 0;
- while (next_index < 1024 && current == NULL)
- current = chanlist[next_index++];
- Alog(LOG_DEBUG_3) << "firstchan() returning " << (current ? current->name : "NULL (end of list)");
- return current;
+ return findchan(ci::string(chan.c_str()));
}
-Channel *nextchan()
+Channel *findchan(const ci::string &chan)
{
- if (current)
- current = current->next;
- if (!current && next_index < 1024) {
- while (next_index < 1024 && current == NULL)
- current = chanlist[next_index++];
- }
- Alog(LOG_DEBUG_3) << "nextchan() returning " << (current ? current->name : "NULL (end of list)");
- return current;
+ channel_map::const_iterator it = ChannelList.find(chan);
+
+ if (it != ChannelList.end())
+ return it->second;
+ return NULL;
}
/*************************************************************************/
@@ -1115,40 +1062,39 @@ Channel *nextchan()
void get_channel_stats(long *nrec, long *memuse)
{
long count = 0, mem = 0;
- Channel *chan;
BanData *bd;
- int i;
std::string buf;
- for (i = 0; i < 1024; i++) {
- for (chan = chanlist[i]; chan; chan = chan->next) {
- count++;
- mem += sizeof(*chan);
- if (chan->topic)
- mem += strlen(chan->topic) + 1;
- if (chan->GetParam(CMODE_KEY, buf))
- mem += buf.length() + 1;
- if (chan->GetParam(CMODE_FLOOD, buf))
- mem += buf.length() + 1;
- if (chan->GetParam(CMODE_REDIRECT, buf))
- mem += buf.length() + 1;
- mem += get_memuse(chan->bans);
- if (ModeManager::FindChannelModeByName(CMODE_EXCEPT))
- mem += get_memuse(chan->excepts);
- if (ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE))
- mem += get_memuse(chan->invites);
- for (CUserList::iterator it = chan->users.begin(); it != chan->users.end(); ++it)
- {
- mem += sizeof(*it);
- mem += sizeof((*it)->ud);
- if ((*it)->ud.lastline)
- mem += strlen((*it)->ud.lastline) + 1;
- }
- for (bd = chan->bd; bd; bd = bd->next) {
- if (bd->mask)
- mem += strlen(bd->mask) + 1;
- mem += sizeof(*bd);
- }
+ for (channel_map::const_iterator cit = ChannelList.begin(); cit != ChannelList.end(); ++cit)
+ {
+ Channel *chan = cit->second;
+
+ count++;
+ mem += sizeof(*chan);
+ if (chan->topic)
+ mem += strlen(chan->topic) + 1;
+ if (chan->GetParam(CMODE_KEY, buf))
+ mem += buf.length() + 1;
+ if (chan->GetParam(CMODE_FLOOD, buf))
+ mem += buf.length() + 1;
+ if (chan->GetParam(CMODE_REDIRECT, buf))
+ mem += buf.length() + 1;
+ mem += get_memuse(chan->bans);
+ if (ModeManager::FindChannelModeByName(CMODE_EXCEPT))
+ mem += get_memuse(chan->excepts);
+ if (ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE))
+ mem += get_memuse(chan->invites);
+ for (CUserList::iterator it = chan->users.begin(); it != chan->users.end(); ++it)
+ {
+ mem += sizeof(*it);
+ mem += sizeof((*it)->ud);
+ if ((*it)->ud.lastline)
+ mem += strlen((*it)->ud.lastline) + 1;
+ }
+ for (bd = chan->bd; bd; bd = bd->next) {
+ if (bd->mask)
+ mem += strlen(bd->mask) + 1;
+ mem += sizeof(*bd);
}
}
*nrec = count;
@@ -1542,10 +1488,10 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes)
*/
void MassChannelModes(BotInfo *bi, const std::string &modes)
{
- Channel *c;
-
- for (c = firstchan(); c; c = nextchan())
+ for (channel_map::const_iterator it = ChannelList.begin(); it != ChannelList.end(); ++it)
{
+ Channel *c = it->second;
+
if (c->bouncy_modes)
return;
c->SetModes(bi, false, modes.c_str());
@@ -1556,9 +1502,10 @@ void MassChannelModes(BotInfo *bi, const std::string &modes)
void restore_unsynced_topics()
{
- Channel *c;
+ for (channel_map::const_iterator it = ChannelList.begin(); it != ChannelList.end(); ++it)
+ {
+ Channel *c = it->second;
- for (c = firstchan(); c; c = nextchan()) {
if (!(c->topic_sync))
restore_topic(c->name.c_str());
}
diff --git a/src/chanserv.c b/src/chanserv.c
index 377a04323..872055df1 100644
--- a/src/chanserv.c
+++ b/src/chanserv.c
@@ -19,7 +19,7 @@
/*************************************************************************/
/* *INDENT-OFF* */
-ChannelInfo *chanlists[256];
+registered_channel_map RegisteredChannelList;
static int def_levels[][2] = {
{ CA_AUTOOP, 5 },
@@ -195,51 +195,51 @@ char *get_mlock_modes(ChannelInfo * ci, int complete)
void get_chanserv_stats(long *nrec, long *memuse)
{
long count = 0, mem = 0;
- unsigned i, j;
- ChannelInfo *ci;
std::string param;
- for (i = 0; i < 256; i++) {
- for (ci = chanlists[i]; ci; ci = ci->next) {
- count++;
- mem += sizeof(*ci);
- if (ci->desc)
- mem += strlen(ci->desc) + 1;
- if (ci->url)
- mem += strlen(ci->url) + 1;
- if (ci->email)
- mem += strlen(ci->email) + 1;
- mem += ci->GetAccessCount() * sizeof(ChanAccess);
- mem += ci->GetAkickCount() * sizeof(AutoKick);
-
- if (ci->GetParam(CMODE_KEY, param))
- mem += param.length() + 1;
-
- if (ci->GetParam(CMODE_FLOOD, param))
- mem += param.length() + 1;
-
- if (ci->GetParam(CMODE_REDIRECT, param))
- mem += param.length() + 1;
-
- if (ci->last_topic)
- mem += strlen(ci->last_topic) + 1;
- if (ci->entry_message)
- mem += strlen(ci->entry_message) + 1;
- if (ci->forbidby)
- mem += strlen(ci->forbidby) + 1;
- if (ci->forbidreason)
- mem += strlen(ci->forbidreason) + 1;
- if (ci->levels)
- mem += sizeof(*ci->levels) * CA_SIZE;
- mem += ci->memos.memos.size() * sizeof(Memo);
- for (j = 0; j < ci->memos.memos.size(); j++) {
- if (ci->memos.memos[j]->text)
- mem += strlen(ci->memos.memos[j]->text) + 1;
- }
- if (ci->ttb)
- mem += sizeof(*ci->ttb) * TTB_SIZE;
- mem += ci->GetBadWordCount() * sizeof(BadWord);
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
+ {
+ ChannelInfo *ci = it->second;
+
+ count++;
+ mem += sizeof(*ci);
+ if (ci->desc)
+ mem += strlen(ci->desc) + 1;
+ if (ci->url)
+ mem += strlen(ci->url) + 1;
+ if (ci->email)
+ mem += strlen(ci->email) + 1;
+ mem += ci->GetAccessCount() * sizeof(ChanAccess);
+ mem += ci->GetAkickCount() * sizeof(AutoKick);
+
+ if (ci->GetParam(CMODE_KEY, param))
+ mem += param.length() + 1;
+
+ if (ci->GetParam(CMODE_FLOOD, param))
+ mem += param.length() + 1;
+
+ if (ci->GetParam(CMODE_REDIRECT, param))
+ mem += param.length() + 1;
+
+ if (ci->last_topic)
+ mem += strlen(ci->last_topic) + 1;
+ if (ci->entry_message)
+ mem += strlen(ci->entry_message) + 1;
+ if (ci->forbidby)
+ mem += strlen(ci->forbidby) + 1;
+ if (ci->forbidreason)
+ mem += strlen(ci->forbidreason) + 1;
+ if (ci->levels)
+ mem += sizeof(*ci->levels) * CA_SIZE;
+ mem += ci->memos.memos.size() * sizeof(Memo);
+ for (unsigned j = 0; j < ci->memos.memos.size(); j++)
+ {
+ if (ci->memos.memos[j]->text)
+ mem += strlen(ci->memos.memos[j]->text) + 1;
}
+ if (ci->ttb)
+ mem += sizeof(*ci->ttb) * TTB_SIZE;
+ mem += ci->GetBadWordCount() * sizeof(BadWord);
}
*nrec = count;
*memuse = mem;
@@ -271,9 +271,9 @@ void chanserv(User * u, char *buf)
if (!(s = strtok(NULL, ""))) {
*s = 0;
}
- ircdproto->SendCTCP(findbot(Config.s_ChanServ), u->nick.c_str(), "PING %s", s);
+ ircdproto->SendCTCP(ChanServ, u->nick.c_str(), "PING %s", s);
} else {
- mod_run_cmd(Config.s_ChanServ, u, CHANSERV, cmd);
+ mod_run_cmd(ChanServ, u, cmd);
}
}
@@ -632,15 +632,15 @@ void restore_topic(const char *chan)
c->topic_setter = whosends(ci)->nick;
}
if (ircd->join2set) {
- if (whosends(ci) == findbot(Config.s_ChanServ)) {
- ircdproto->SendJoin(findbot(Config.s_ChanServ), chan, c->creation_time);
+ if (whosends(ci) == ChanServ) {
+ ircdproto->SendJoin(ChanServ, chan, c->creation_time);
c->SetMode(NULL, CMODE_OP, Config.s_ChanServ);
}
}
ircdproto->SendTopic(whosends(ci), c, c->topic_setter.c_str(), c->topic ? c->topic : "");
if (ircd->join2set) {
- if (whosends(ci) == findbot(Config.s_ChanServ)) {
- ircdproto->SendPart(findbot(Config.s_ChanServ), c, NULL);
+ if (whosends(ci) == ChanServ) {
+ ircdproto->SendPart(ChanServ, c, NULL);
}
}
}
@@ -692,8 +692,8 @@ int check_topiclock(Channel * c, time_t topic_time)
}
if (ircd->join2set) {
- if (whosends(ci) == findbot(Config.s_ChanServ)) {
- ircdproto->SendJoin(findbot(Config.s_ChanServ), c->name.c_str(), c->creation_time);
+ if (whosends(ci) == ChanServ) {
+ ircdproto->SendJoin(ChanServ, c->name.c_str(), c->creation_time);
c->SetMode(NULL, CMODE_OP, Config.s_ChanServ);
}
}
@@ -701,8 +701,8 @@ int check_topiclock(Channel * c, time_t topic_time)
ircdproto->SendTopic(whosends(ci), c, c->topic_setter.c_str(), c->topic ? c->topic : "");
if (ircd->join2set) {
- if (whosends(ci) == findbot(Config.s_ChanServ)) {
- ircdproto->SendPart(findbot(Config.s_ChanServ), c, NULL);
+ if (whosends(ci) == ChanServ) {
+ ircdproto->SendPart(ChanServ, c, NULL);
}
}
return 1;
@@ -714,118 +714,113 @@ int check_topiclock(Channel * c, time_t topic_time)
void expire_chans()
{
- ChannelInfo *ci, *next;
- int i;
- time_t now = time(NULL);
-
if (!Config.CSExpire)
return;
+
+ time_t now = time(NULL);
- for (i = 0; i < 256; i++) {
- for (ci = chanlists[i]; ci; ci = next) {
- next = ci->next;
- if (!ci->c && now - ci->last_used >= Config.CSExpire && !ci->HasFlag(CI_FORBIDDEN) && !ci->HasFlag(CI_NO_EXPIRE) && !ci->HasFlag(CI_SUSPENDED))
- {
- EventReturn MOD_RESULT;
- FOREACH_RESULT(I_OnPreChanExpire, OnPreChanExpire(ci));
- if (MOD_RESULT == EVENT_STOP)
- continue;
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end();)
+ {
+ ChannelInfo *ci = it->second;
+ ++it;
- char *chname = sstrdup(ci->name.c_str());
- Alog() << "Expiring channel " << ci->name << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << " )";
- delete ci;
- FOREACH_MOD(I_OnChanExpire, OnChanExpire(chname));
- delete [] chname;
- }
+ if (!ci->c && now - ci->last_used >= Config.CSExpire && !ci->HasFlag(CI_FORBIDDEN) && !ci->HasFlag(CI_NO_EXPIRE) && !ci->HasFlag(CI_SUSPENDED))
+ {
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(I_OnPreChanExpire, OnPreChanExpire(ci));
+ if (MOD_RESULT == EVENT_STOP)
+ continue;
+
+ char *chname = sstrdup(ci->name.c_str());
+ Alog() << "Expiring channel " << ci->name << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << " )";
+ delete ci;
+ FOREACH_MOD(I_OnChanExpire, OnChanExpire(chname));
+ delete [] chname;
}
}
}
/*************************************************************************/
-/* Remove a (deleted or expired) nickname from all channel lists. */
-
+// XXX this is slightly inefficient
void cs_remove_nick(const NickCore * nc)
{
- int i, j;
- ChannelInfo *ci, *next;
+ int j;
ChanAccess *ca;
AutoKick *akick;
- for (i = 0; i < 256; i++) {
- for (ci = chanlists[i]; ci; ci = next) {
- next = ci->next;
- if (ci->founder == nc) {
- if (ci->successor) {
- NickCore *nc2 = ci->successor;
- if (!nc2->IsServicesOper() && Config.CSMaxReg && nc2->channelcount >= Config.CSMaxReg) {
- Alog() << Config.s_ChanServ << ": Successor (" << nc2->display << " ) of " << ci->name << " owns too many channels, deleting channel",
- delete ci;
- continue;
- } else {
- Alog() << Config.s_ChanServ << ": Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to successor " << nc2->display;
- ci->founder = nc2;
- ci->successor = NULL;
- nc2->channelcount++;
- }
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
+ {
+ ChannelInfo *ci = it->second;
+
+ if (ci->founder == nc) {
+ if (ci->successor) {
+ NickCore *nc2 = ci->successor;
+ if (!nc2->IsServicesOper() && Config.CSMaxReg && nc2->channelcount >= Config.CSMaxReg) {
+ Alog() << Config.s_ChanServ << ": Successor (" << nc2->display << " ) of " << ci->name << " owns too many channels, deleting channel",
+ delete ci;
+ continue;
} else {
- Alog() << Config.s_ChanServ << ": Deleting channel " << ci->name << "owned by deleted nick " << nc->display;
+ Alog() << Config.s_ChanServ << ": Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to successor " << nc2->display;
+ ci->founder = nc2;
+ ci->successor = NULL;
+ nc2->channelcount++;
+ }
+ } else {
+ Alog() << Config.s_ChanServ << ": Deleting channel " << ci->name << "owned by deleted nick " << nc->display;
- if ((ModeManager::FindChannelModeByName(CMODE_REGISTERED)))
+ if ((ModeManager::FindChannelModeByName(CMODE_REGISTERED)))
+ {
+ /* Maybe move this to delchan() ? */
+ if (ci->c && ci->c->HasMode(CMODE_REGISTERED))
{
- /* Maybe move this to delchan() ? */
- if (ci->c && ci->c->HasMode(CMODE_REGISTERED))
- {
- ci->c->RemoveMode(NULL, CMODE_REGISTERED);
- }
+ ci->c->RemoveMode(NULL, CMODE_REGISTERED);
}
-
- delete ci;
- continue;
}
+
+ delete ci;
+ continue;
}
+ }
- if (ci->successor == nc)
- ci->successor = NULL;
+ if (ci->successor == nc)
+ ci->successor = NULL;
- for (j = ci->GetAccessCount(); j > 0; --j)
- {
- ca = ci->GetAccess(j - 1);
+ for (j = ci->GetAccessCount(); j > 0; --j)
+ {
+ ca = ci->GetAccess(j - 1);
- if (ca->in_use && ca->nc == nc)
- ci->EraseAccess(j - 1);
- }
+ if (ca->in_use && ca->nc == nc)
+ ci->EraseAccess(j - 1);
+ }
- for (j = ci->GetAkickCount(); j > 0; --j)
- {
- akick = ci->GetAkick(j - 1);
- if (akick->InUse && akick->HasFlag(AK_ISNICK) && akick->nc == nc)
- ci->EraseAkick(akick);
- }
+ for (j = ci->GetAkickCount(); j > 0; --j)
+ {
+ akick = ci->GetAkick(j - 1);
+ if (akick->InUse && akick->HasFlag(AK_ISNICK) && akick->nc == nc)
+ ci->EraseAkick(akick);
}
}
}
/*************************************************************************/
-/* Return the ChannelInfo structure for the given channel, or NULL if the
- * channel isn't registered. */
+ChannelInfo *cs_findchan(const char *chan)
+{
+ return cs_findchan(ci::string(chan));
+}
ChannelInfo *cs_findchan(const std::string &chan)
{
- ChannelInfo *ci;
+ return cs_findchan(ci::string(chan.c_str()));
+}
- if (chan.empty())
- {
- Alog(LOG_DEBUG) << "cs_findchan() called with NULL values";
- return NULL;
- }
+ChannelInfo *cs_findchan(const ci::string &chan)
+{
+ registered_channel_map::const_iterator it = RegisteredChannelList.find(chan);
- for (ci = chanlists[static_cast<unsigned char>(tolower(chan[1]))]; ci;
- ci = ci->next) {
- if (ci::string(ci->name.c_str()) == chan)
- return ci;
- }
+ if (it != RegisteredChannelList.end())
+ return it->second;
return NULL;
}
@@ -872,33 +867,6 @@ int check_access(User * user, ChannelInfo * ci, int what)
/*********************** ChanServ private routines ***********************/
/*************************************************************************/
-/* Insert a channel alphabetically into the database. */
-
-void alpha_insert_chan(ChannelInfo * ci)
-{
- ChannelInfo *ptr, *prev;
-
- if (!ci)
- {
- Alog(LOG_DEBUG) << "alpha_insert_chan() called with NULL values";
- return;
- }
-
- const char *chan = ci->name.c_str();
-
- for (prev = NULL, ptr = chanlists[static_cast<unsigned char>(tolower(chan[1]))];
- ptr != NULL && stricmp(ptr->name.c_str(), chan) < 0;
- prev = ptr, ptr = ptr->next);
- ci->prev = prev;
- ci->next = ptr;
- if (!prev)
- chanlists[static_cast<unsigned char>(tolower(chan[1]))] = ci;
- else
- prev->next = ci;
- if (ptr)
- ptr->prev = ci;
-}
-
/* Reset channel access level values to their default state. */
void reset_levels(ChannelInfo * ci)
@@ -1204,7 +1172,7 @@ void ChanServTimer::Tick(time_t)
if (!c->users.empty())
return;
- ircdproto->SendPart(findbot(Config.s_ChanServ), c, NULL);
+ ircdproto->SendPart(ChanServ, c, NULL);
/* Now delete the channel as it is empty */
if (!c->HasFlag(CH_PERSIST) && !c->ci->HasFlag(CI_PERSIST))
diff --git a/src/command.cpp b/src/command.cpp
index fc745fe46..b440c741f 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -12,20 +12,12 @@
Command::Command(const ci::string &sname, size_t min_params, size_t max_params, const std::string &spermission) : MaxParams(max_params), MinParams(min_params), name(sname), permission(spermission)
{
- this->core = 0;
- this->mod_name = NULL;
+ this->module = NULL;
this->service = NULL;
- this->next = NULL;
}
Command::~Command()
{
- if (this->mod_name) {
- delete [] this->mod_name;
- }
- if (this->service) {
- delete [] this->service;
- }
}
CommandReturn Command::Execute(User *u, const std::vector<ci::string> &) { return MOD_CONT; }
diff --git a/src/commands.c b/src/commands.c
index 40363a7d1..71c4c986a 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -16,75 +16,36 @@
#include "language.h"
#include "hashcomp.h"
-/*************************************************************************/
-
-/**
- * Search the command table gieven for a command.
- * @param cmdTable the name of the command table to search
- * @param name the name of the command to look for
- * @return returns a pointer to the found command struct, or NULL
- */
-Command *findCommand(CommandHash * cmdTable[], const char *name)
+Command *FindCommand(BotInfo *bi, const ci::string &name)
{
- int idx;
- CommandHash *current = NULL;
- if (!cmdTable || !name) {
+ if (!bi || bi->Commands.empty() || name.empty())
return NULL;
- }
+
+ std::map<ci::string, Command *>::iterator it = bi->Commands.find(name);
- idx = CMD_HASH(name);
+ if (it != bi->Commands.end())
+ return it->second;
- for (current = cmdTable[idx]; current; current = current->next) {
- if (stricmp(name, current->name) == 0) {
- return current->c;
- }
- }
return NULL;
}
-/**
- * Return the Command corresponding to the given name, or NULL if no such
- * command exists.
- * @param list Command struct
- * @param cmd Command to look up
- * @return Command Struct for the given cmd
- */
-Command *lookup_cmd(Command * list, char *cmd)
+void mod_run_cmd(BotInfo *bi, User *u, const ci::string &cmd)
{
- Command *c;
-
- for (c = list; ; c++) {
- if (stricmp(c->name.c_str(), cmd) == 0) {
- return c;
- }
- }
-}
-
-/*************************************************************************/
+ if (!bi || !u || cmd.empty())
+ return;
-/**
- * Run the routine for the given command, if it exists and the user has
- * privilege to do so; if not, print an appropriate error message.
- * @param services Services Client
- * @param u User Struct
- * @param Command Hash Table
- * @param cmd Command
- * @return void
- */
-void mod_run_cmd(const std::string &service, User * u, CommandHash * cmdTable[], const char *cmd)
-{
- Command *c = findCommand(cmdTable, cmd);
+ Command *c = FindCommand(bi, cmd);
int retVal = MOD_CONT;
ChannelInfo *ci;
- EventReturn MOD_RESULT;
- FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(service, u, cmd, c));
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(bi, u, cmd, c));
if (MOD_RESULT == EVENT_STOP)
return;
if (!c)
{
- notice_lang(service, u, UNKNOWN_COMMAND_HELP, cmd, service.c_str());
+ notice_lang(bi->nick, u, UNKNOWN_COMMAND_HELP, cmd.c_str(), bi->nick.c_str());
return;
}
@@ -93,8 +54,8 @@ void mod_run_cmd(const std::string &service, User * u, CommandHash * cmdTable[],
// Command requires registered users only
if (!u->IsIdentified())
{
- notice_lang(service, u, NICK_IDENTIFY_REQUIRED, Config.s_NickServ);
- Alog() << "Access denied for unregistered user " << u->nick << " with service " << service << " and command " << cmd;
+ notice_lang(bi->nick, u, NICK_IDENTIFY_REQUIRED, Config.s_NickServ);
+ Alog() << "Access denied for unregistered user " << u->nick << " with service " << bi->nick << " and command " << cmd;
return;
}
}
@@ -131,11 +92,11 @@ void mod_run_cmd(const std::string &service, User * u, CommandHash * cmdTable[],
return;
}
- FOREACH_RESULT(I_OnPreCommand, OnPreCommand(u, c->service, c->name.c_str(), params));
+ FOREACH_RESULT(I_OnPreCommand, OnPreCommand(u, c->service, c->name, params));
if (MOD_RESULT == EVENT_STOP)
return;
- if (params.size() > 0 && !c->HasFlag(CFLAG_STRIP_CHANNEL) && (cmdTable == CHANSERV || cmdTable == BOTSERV))
+ if (params.size() > 0 && !c->HasFlag(CFLAG_STRIP_CHANNEL) && (bi == ChanServ || bi == BotServ))
{
if (ircdproto->IsChannelValid(params[0].c_str()))
{
@@ -143,29 +104,29 @@ void mod_run_cmd(const std::string &service, User * u, CommandHash * cmdTable[],
{
if ((ci->HasFlag(CI_FORBIDDEN)) && (!c->HasFlag(CFLAG_ALLOW_FORBIDDEN)))
{
- notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name.c_str());
- Alog() << "Access denied for user " << u->nick << " with service " << service
+ notice_lang(bi->nick, u, CHAN_X_FORBIDDEN, ci->name.c_str());
+ Alog() << "Access denied for user " << u->nick << " with service " << bi->nick
<< " and command " << cmd << " because of FORBIDDEN channel " << ci->name;
return;
}
else if ((ci->HasFlag(CI_SUSPENDED)) && (!c->HasFlag(CFLAG_ALLOW_SUSPENDED)))
{
- notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name.c_str());
- Alog() << "Access denied for user " << u->nick << " with service " << service
+ notice_lang(bi->nick, u, CHAN_X_FORBIDDEN, ci->name.c_str());
+ Alog() << "Access denied for user " << u->nick << " with service " << bi->nick
<<" and command " << cmd << " because of SUSPENDED channel " << ci->name;
return;
}
}
else if (!c->HasFlag(CFLAG_ALLOW_UNREGISTEREDCHANNEL))
{
- notice_lang(service, u, CHAN_X_NOT_REGISTERED, params[0].c_str());
+ notice_lang(bi->nick, u, CHAN_X_NOT_REGISTERED, params[0].c_str());
return;
}
}
/* A user not giving a channel name for a param that should be a channel */
else
{
- notice_lang(service, u, CHAN_X_INVALID, params[0].c_str());
+ notice_lang(bi->nick, u, CHAN_X_INVALID, params[0].c_str());
return;
}
}
@@ -175,8 +136,8 @@ void mod_run_cmd(const std::string &service, User * u, CommandHash * cmdTable[],
{
if (!u->Account()->HasCommand(c->permission))
{
- notice_lang(service, u, ACCESS_DENIED);
- Alog() << "Access denied for user " << u->nick << " with service " << service << " and command " << cmd;
+ notice_lang(bi->nick, u, ACCESS_DENIED);
+ Alog() << "Access denied for user " << u->nick << " with service " << bi->nick << " and command " << cmd;
return;
}
@@ -190,8 +151,6 @@ void mod_run_cmd(const std::string &service, User * u, CommandHash * cmdTable[],
}
}
-/*************************************************************************/
-
/**
* Prints the help message for a given command.
* @param services Services Client
@@ -200,36 +159,38 @@ void mod_run_cmd(const std::string &service, User * u, CommandHash * cmdTable[],
* @param cmd Command
* @return void
*/
-void mod_help_cmd(char *service, User * u, CommandHash * cmdTable[], const char *cmd)
+void mod_help_cmd(BotInfo *bi, User *u, const ci::string &cmd)
{
+ if (!bi || !u || cmd.empty())
+ return;
+
spacesepstream tokens(cmd);
- std::string token;
+ ci::string token;
tokens.GetToken(token);
- Command *c = findCommand(cmdTable, token.c_str());
+ Command *c = FindCommand(bi, token);
ci::string subcommand = tokens.StreamEnd() ? "" : tokens.GetRemaining().c_str();
if (!c || !c->OnHelp(u, subcommand))
- notice_lang(service, u, NO_HELP_AVAILABLE, cmd);
+ notice_lang(bi->nick, u, NO_HELP_AVAILABLE, cmd.c_str());
else
{
- u->SendMessage(service, " ");
+ u->SendMessage(bi->nick, " ");
/* Inform the user what permission is required to use the command */
if (!c->permission.empty())
- notice_lang(service, u, COMMAND_REQUIRES_PERM, c->permission.c_str());
+ notice_lang(bi->nick, u, COMMAND_REQUIRES_PERM, c->permission.c_str());
/* User isn't identified and needs to be to use this command */
if (!c->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !u->IsIdentified())
- notice_lang(service, u, COMMAND_IDENTIFY_REQUIRED);
+ notice_lang(bi->nick, u, COMMAND_IDENTIFY_REQUIRED);
/* User doesn't have the proper permission to use this command */
else if (!c->permission.empty() && (!u->Account() || (!u->Account()->HasCommand(c->permission))))
- notice_lang(service, u, COMMAND_CANNOT_USE);
+ notice_lang(bi->nick, u, COMMAND_CANNOT_USE);
/* User can use this command */
else
- notice_lang(service, u, COMMAND_CAN_USE);
+ notice_lang(bi->nick, u, COMMAND_CAN_USE);
}
}
-/*************************************************************************/
diff --git a/src/config.c b/src/config.c
index 82a92bc70..1dd312723 100644
--- a/src/config.c
+++ b/src/config.c
@@ -474,13 +474,9 @@ static bool DoneOperTypes(ServerConfig *, const char *, bool)
static bool InitOpers(ServerConfig *, const char *, bool)
{
- int i;
- NickCore *nc;
+ for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
+ it->second->ot = NULL;
- for (i = 0; i < 1024; ++i)
- for (nc = nclists[i]; nc; nc = nc->next)
- nc->ot = NULL;
-
Config.Opers.clear();
return true;
diff --git a/src/core/bs_act.c b/src/core/bs_act.c
index d0b9c8b08..1bf11e078 100644
--- a/src/core/bs_act.c
+++ b/src/core/bs_act.c
@@ -75,7 +75,7 @@ class BSAct : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(BOTSERV, new CommandBSAct());
+ this->AddCommand(BotServ, new CommandBSAct());
ModuleManager::Attach(I_OnBotServHelp, this);
}
diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c
index f37db9aca..dc847eb66 100644
--- a/src/core/bs_assign.c
+++ b/src/core/bs_assign.c
@@ -85,7 +85,7 @@ class BSAssign : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(BOTSERV, new CommandBSAssign);
+ this->AddCommand(BotServ, new CommandBSAssign);
ModuleManager::Attach(I_OnBotServHelp, this);
}
diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c
index af616c41a..3db6f1e42 100644
--- a/src/core/bs_badwords.c
+++ b/src/core/bs_badwords.c
@@ -229,7 +229,7 @@ class BSBadwords : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(BOTSERV, new CommandBSBadwords);
+ this->AddCommand(BotServ, new CommandBSBadwords);
ModuleManager::Attach(I_OnBotServHelp, this);
}
diff --git a/src/core/bs_bot.c b/src/core/bs_bot.c
index 8abfecde8..d8cb3db6d 100644
--- a/src/core/bs_bot.c
+++ b/src/core/bs_bot.c
@@ -414,7 +414,7 @@ class BSBot : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(BOTSERV, new CommandBSBot());
+ this->AddCommand(BotServ, new CommandBSBot());
ModuleManager::Attach(I_OnBotServHelp, this);
}
diff --git a/src/core/bs_botlist.c b/src/core/bs_botlist.c
index 540cac30d..935e6d18a 100644
--- a/src/core/bs_botlist.c
+++ b/src/core/bs_botlist.c
@@ -23,34 +23,39 @@ class CommandBSBotList : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- int i, count = 0;
- BotInfo *bi;
+ unsigned count = 0;
- if (!nbots) {
+ if (BotList.empty())
+ {
notice_lang(Config.s_BotServ, u, BOT_BOTLIST_EMPTY);
return MOD_CONT;
}
- for (i = 0; i < 256; i++) {
- for (bi = botlists[i]; bi; bi = bi->next) {
- if (!(bi->HasFlag(BI_PRIVATE))) {
- if (!count)
- notice_lang(Config.s_BotServ, u, BOT_BOTLIST_HEADER);
- count++;
- u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str());
- }
+ for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it)
+ {
+ BotInfo *bi = it->second;
+
+ if (!bi->HasFlag(BI_PRIVATE))
+ {
+ if (!count)
+ notice_lang(Config.s_BotServ, u, BOT_BOTLIST_HEADER);
+ count++;
+ u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str());
}
}
- if (u->Account()->HasCommand("botserv/botlist") && count < nbots) {
+ if (u->Account()->HasCommand("botserv/botlist") && count < BotList.size())
+ {
notice_lang(Config.s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER);
- for (i = 0; i < 256; i++) {
- for (bi = botlists[i]; bi; bi = bi->next) {
- if (bi->HasFlag(BI_PRIVATE)) {
- u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str());
- count++;
- }
+ for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it)
+ {
+ BotInfo *bi = it->second;
+
+ if (bi->HasFlag(BI_PRIVATE))
+ {
+ u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str());
+ count++;
}
}
}
@@ -59,6 +64,7 @@ class CommandBSBotList : public Command
notice_lang(Config.s_BotServ, u, BOT_BOTLIST_EMPTY);
else
notice_lang(Config.s_BotServ, u, BOT_BOTLIST_FOOTER, count);
+
return MOD_CONT;
}
@@ -77,7 +83,7 @@ class BSBotList : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(BOTSERV, new CommandBSBotList());
+ this->AddCommand(BotServ, new CommandBSBotList());
ModuleManager::Attach(I_OnBotServHelp, this);
}
diff --git a/src/core/bs_help.c b/src/core/bs_help.c
index d28595986..a3e53df5c 100644
--- a/src/core/bs_help.c
+++ b/src/core/bs_help.c
@@ -25,7 +25,7 @@ class CommandBSHelp : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- mod_help_cmd(Config.s_BotServ, u, BOTSERV, params[0].c_str());
+ mod_help_cmd(findbot(Config.s_BotServ), u, params[0].c_str());
return MOD_CONT;
}
@@ -46,7 +46,7 @@ class BSHelp : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(BOTSERV, new CommandBSHelp());
+ this->AddCommand(BotServ, new CommandBSHelp());
}
};
diff --git a/src/core/bs_info.c b/src/core/bs_info.c
index 3ac3e9540..3f873aafd 100644
--- a/src/core/bs_info.c
+++ b/src/core/bs_info.c
@@ -19,25 +19,24 @@ class CommandBSInfo : public Command
private:
void send_bot_channels(User * u, BotInfo * bi)
{
- int i;
- ChannelInfo *ci;
char buf[307], *end;
*buf = 0;
end = buf;
- for (i = 0; i < 256; i++) {
- for (ci = chanlists[i]; ci; ci = ci->next) {
- if (ci->bi == bi) {
- if (strlen(buf) + strlen(ci->name.c_str()) > 300) {
- u->SendMessage(Config.s_BotServ, "%s", buf);
- *buf = 0;
- end = buf;
- }
- end +=
- snprintf(end, sizeof(buf) - (end - buf), " %s ",
- ci->name.c_str());
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
+ {
+ ChannelInfo *ci = it->second;
+
+ if (ci->bi == bi)
+ {
+ if (strlen(buf) + strlen(ci->name.c_str()) > 300)
+ {
+ u->SendMessage(Config.s_BotServ, "%s", buf);
+ *buf = 0;
+ end = buf;
}
+ end += snprintf(end, sizeof(buf) - (end - buf), " %s ", ci->name.c_str());
}
}
@@ -251,7 +250,7 @@ class BSInfo : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(BOTSERV, new CommandBSInfo());
+ this->AddCommand(BotServ, new CommandBSInfo());
ModuleManager::Attach(I_OnBotServHelp, this);
}
diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c
index 766239c73..ab2782c8d 100644
--- a/src/core/bs_kick.c
+++ b/src/core/bs_kick.c
@@ -335,7 +335,7 @@ class BSKick : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(BOTSERV, new CommandBSKick());
+ this->AddCommand(BotServ, new CommandBSKick());
ModuleManager::Attach(I_OnBotServHelp, this);
}
diff --git a/src/core/bs_say.c b/src/core/bs_say.c
index 9cd630eb8..8dfc55115 100644
--- a/src/core/bs_say.c
+++ b/src/core/bs_say.c
@@ -81,7 +81,7 @@ class BSSay : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(BOTSERV, new CommandBSSay());
+ this->AddCommand(BotServ, new CommandBSSay());
ModuleManager::Attach(I_OnBotServHelp, this);
}
diff --git a/src/core/bs_set.c b/src/core/bs_set.c
index 0614651cc..3468198a2 100644
--- a/src/core/bs_set.c
+++ b/src/core/bs_set.c
@@ -185,7 +185,7 @@ class BSSet : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(BOTSERV, new CommandBSSet());
+ this->AddCommand(BotServ, new CommandBSSet());
ModuleManager::Attach(I_OnBotServHelp, this);
}
diff --git a/src/core/bs_unassign.c b/src/core/bs_unassign.c
index e053f75d7..067e4cc14 100644
--- a/src/core/bs_unassign.c
+++ b/src/core/bs_unassign.c
@@ -63,7 +63,7 @@ class BSUnassign : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(BOTSERV, new CommandBSUnassign);
+ this->AddCommand(BotServ, new CommandBSUnassign);
ModuleManager::Attach(I_OnBotServHelp, this);
}
diff --git a/src/core/cs_access.c b/src/core/cs_access.c
index e4e1d0e4b..718a7dc0f 100644
--- a/src/core/cs_access.c
+++ b/src/core/cs_access.c
@@ -573,8 +573,8 @@ class CSAccess : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSAccess());
- this->AddCommand(CHANSERV, new CommandCSLevels());
+ this->AddCommand(ChanServ, new CommandCSAccess());
+ this->AddCommand(ChanServ, new CommandCSLevels());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c
index ac17ef504..abd00be6a 100644
--- a/src/core/cs_akick.c
+++ b/src/core/cs_akick.c
@@ -152,7 +152,6 @@ class CommandCSAKick : public Command
NickAlias *na = findnick(mask.c_str());
NickCore *nc = NULL;
AutoKick *akick;
- int i;
if (!na)
{
@@ -197,42 +196,40 @@ class CommandCSAKick : public Command
}
else if ((ci->HasFlag(CI_PEACE)))
{
- char buf[BUFSIZE];
/* Match against all currently online users with equal or
* higher access. - Viper */
- for (i = 0; i < 1024; i++)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
- for (User *u2 = userlist[i]; u2; u2 = u2->next)
+ User *u2 = it->second;
+
+ if (IsFounder(u2, ci) || (get_access(u2, ci) >= get_access(u, ci)))
{
- if (IsFounder(u2, ci) || (get_access(u2, ci) >= get_access(u, ci)))
+ if (match_usermask(mask.c_str(), u2))
{
- if (match_usermask(mask.c_str(), u2))
- {
- notice_lang(Config.s_ChanServ, u, ACCESS_DENIED);
- return;
- }
+ notice_lang(Config.s_ChanServ, u, ACCESS_DENIED);
+ return;
}
}
- }
-
+ }
- /* Match against the lastusermask of all nickalias's with equal
- * or higher access. - Viper */
- for (i = 0; i < 1024; i++)
+ /* Match against the lastusermask of all nickalias's with equal
+ * or higher access. - Viper */
+ for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
{
- for (NickAlias *na2 = nalists[i]; na2; na2 = na2->next)
+ NickAlias *na2 = it->second;
+
+ if (na2->HasFlag(NS_FORBIDDEN))
+ continue;
+
+ if (na2->nc && ((na2->nc == ci->founder) || (get_access_nc(na2->nc, ci) >= get_access(u, ci))))
{
- if (na2->HasFlag(NS_FORBIDDEN))
- continue;
+ char buf[BUFSIZE];
- if (na2->nc && ((na2->nc == ci->founder) || (get_access_nc(na2->nc, ci) >= get_access(u, ci))))
+ snprintf(buf, BUFSIZE, "%s!%s", na2->nick, na2->last_usermask);
+ if (Anope::Match(buf, mask.c_str(), false))
{
- snprintf(buf, BUFSIZE, "%s!%s", na2->nick, na2->last_usermask);
- if (Anope::Match(buf, mask.c_str(), false))
- {
- notice_lang(Config.s_ChanServ, u, ACCESS_DENIED);
- return;
- }
+ notice_lang(Config.s_ChanServ, u, ACCESS_DENIED);
+ return;
}
}
}
@@ -577,7 +574,7 @@ class CSAKick : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSAKick());
+ this->AddCommand(ChanServ, new CommandCSAKick());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c
index 95c5c6556..39f290d98 100644
--- a/src/core/cs_ban.c
+++ b/src/core/cs_ban.c
@@ -104,8 +104,8 @@ class CSBan : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSBan("BAN"));
- this->AddCommand(CHANSERV, new CommandCSBan("KB"));
+ this->AddCommand(ChanServ, new CommandCSBan("BAN"));
+ this->AddCommand(ChanServ, new CommandCSBan("KB"));
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_clear.c b/src/core/cs_clear.c
index bb86e3b74..5e7ef2674 100644
--- a/src/core/cs_clear.c
+++ b/src/core/cs_clear.c
@@ -171,7 +171,7 @@ class CSClear : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSClear());
+ this->AddCommand(ChanServ, new CommandCSClear());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_drop.c b/src/core/cs_drop.c
index b91fdc846..f7c7a8571 100644
--- a/src/core/cs_drop.c
+++ b/src/core/cs_drop.c
@@ -79,7 +79,7 @@ class CommandCSDrop : public Command
*/
if (Config.WallDrop) {
if ((level < ACCESS_FOUNDER) || (!IsRealFounder(u, ci) && ci->HasFlag(CI_SECUREFOUNDER)))
- ircdproto->SendGlobops(findbot(Config.s_ChanServ), "\2%s\2 used DROP on channel \2%s\2", u->nick.c_str(), chan);
+ ircdproto->SendGlobops(ChanServ, "\2%s\2 used DROP on channel \2%s\2", u->nick.c_str(), chan);
}
notice_lang(Config.s_ChanServ, u, CHAN_DROPPED, chan);
@@ -113,7 +113,7 @@ class CSDrop : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSDrop());
+ this->AddCommand(ChanServ, new CommandCSDrop());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_forbid.c b/src/core/cs_forbid.c
index b47982a7e..06447c800 100644
--- a/src/core/cs_forbid.c
+++ b/src/core/cs_forbid.c
@@ -78,12 +78,12 @@ class CommandCSForbid : public Command
if (is_oper(uc->user))
continue;
- c->Kick(findbot(Config.s_ChanServ), uc->user, "%s", reason ? reason : getstring(uc->user->Account(), CHAN_FORBID_REASON));
+ c->Kick(ChanServ, uc->user, "%s", reason ? reason : getstring(uc->user->Account(), CHAN_FORBID_REASON));
}
}
if (Config.WallForbid)
- ircdproto->SendGlobops(findbot(Config.s_ChanServ), "\2%s\2 used FORBID on channel \2%s\2", u->nick.c_str(), ci->name.c_str());
+ ircdproto->SendGlobops(ChanServ, "\2%s\2 used FORBID on channel \2%s\2", u->nick.c_str(), ci->name.c_str());
if (ircd->chansqline)
{
@@ -118,7 +118,7 @@ class CSForbid : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSForbid());
+ this->AddCommand(ChanServ, new CommandCSForbid());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_getkey.c b/src/core/cs_getkey.c
index a0937911b..935a2bdbe 100644
--- a/src/core/cs_getkey.c
+++ b/src/core/cs_getkey.c
@@ -66,7 +66,7 @@ class CSGetKey : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSGetKey());
+ this->AddCommand(ChanServ, new CommandCSGetKey());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_help.c b/src/core/cs_help.c
index d975647b2..941634483 100644
--- a/src/core/cs_help.c
+++ b/src/core/cs_help.c
@@ -46,7 +46,7 @@ class CommandCSHelp : public Command
}
}
else
- mod_help_cmd(Config.s_ChanServ, u, CHANSERV, cmd.c_str());
+ mod_help_cmd(ChanServ, u, cmd.c_str());
return MOD_CONT;
}
@@ -71,7 +71,7 @@ class CSHelp : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSHelp());
+ this->AddCommand(ChanServ, new CommandCSHelp());
}
};
diff --git a/src/core/cs_info.c b/src/core/cs_info.c
index b3e7a1077..c0c99c856 100644
--- a/src/core/cs_info.c
+++ b/src/core/cs_info.c
@@ -168,7 +168,7 @@ class CSInfo : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSInfo());
+ this->AddCommand(ChanServ, new CommandCSInfo());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_invite.c b/src/core/cs_invite.c
index b71e487cc..2abcf82bb 100644
--- a/src/core/cs_invite.c
+++ b/src/core/cs_invite.c
@@ -84,7 +84,7 @@ class CSInvite : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSInvite());
+ this->AddCommand(ChanServ, new CommandCSInvite());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_kick.c b/src/core/cs_kick.c
index 42059a01b..1c05ea77e 100644
--- a/src/core/cs_kick.c
+++ b/src/core/cs_kick.c
@@ -89,8 +89,8 @@ class CSKick : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSKick("KICK"));
- this->AddCommand(CHANSERV, new CommandCSKick("K"));
+ this->AddCommand(ChanServ, new CommandCSKick("KICK"));
+ this->AddCommand(ChanServ, new CommandCSKick("K"));
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_list.c b/src/core/cs_list.c
index cb86bb300..4b6f1d242 100644
--- a/src/core/cs_list.c
+++ b/src/core/cs_list.c
@@ -28,8 +28,7 @@ public:
const char *pattern = params[0].c_str();
int spattern_size;
char *spattern;
- ChannelInfo *ci;
- unsigned nchans, i;
+ unsigned nchans;
char buf[BUFSIZE];
bool is_servadmin = u->Account()->HasCommand("chanserv/list");
int count = 0, from = 0, to = 0, tofree = 0;
@@ -111,55 +110,56 @@ public:
snprintf(spattern, spattern_size, "#%s", pattern);
notice_lang(Config.s_ChanServ, u, CHAN_LIST_HEADER, pattern);
- for (i = 0; i < 256; i++)
+
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
{
- for (ci = chanlists[i]; ci; ci = ci->next)
+ ChannelInfo *ci = it->second;
+
+ if (!is_servadmin && ((ci->HasFlag(CI_PRIVATE))
+ || (ci->HasFlag(CI_FORBIDDEN)) || (ci->HasFlag(CI_SUSPENDED))))
+ continue;
+ if (forbidden && !ci->HasFlag(CI_FORBIDDEN))
+ continue;
+ else if (suspended && !ci->HasFlag(CI_SUSPENDED))
+ continue;
+ else if (channoexpire && !ci->HasFlag(CI_NO_EXPIRE))
+ continue;
+
+ if ((stricmp(pattern, ci->name.c_str()) == 0)
+ || (stricmp(spattern, ci->name.c_str()) == 0)
+ || Anope::Match(ci->name, pattern, false)
+ || Anope::Match(ci->name, spattern, false))
{
- if (!is_servadmin && ((ci->HasFlag(CI_PRIVATE))
- || (ci->HasFlag(CI_FORBIDDEN)) || (ci->HasFlag(CI_SUSPENDED))))
- continue;
- if (forbidden && !ci->HasFlag(CI_FORBIDDEN))
- continue;
- else if (suspended && !ci->HasFlag(CI_SUSPENDED))
- continue;
- else if (channoexpire && !ci->HasFlag(CI_NO_EXPIRE))
- continue;
-
- if ((stricmp(pattern, ci->name.c_str()) == 0)
- || (stricmp(spattern, ci->name.c_str()) == 0)
- || Anope::Match(ci->name, pattern, false)
- || Anope::Match(ci->name, spattern, false))
+ if ((((count + 1 >= from) && (count + 1 <= to))
+ || ((from == 0) && (to == 0)))
+ && (++nchans <= Config.CSListMax))
{
- if ((((count + 1 >= from) && (count + 1 <= to))
- || ((from == 0) && (to == 0)))
- && (++nchans <= Config.CSListMax))
+ char noexpire_char = ' ';
+ if (is_servadmin && (ci->HasFlag(CI_NO_EXPIRE)))
+ noexpire_char = '!';
+
+ if (ci->HasFlag(CI_FORBIDDEN))
+ {
+ snprintf(buf, sizeof(buf),
+ "%-20s [Forbidden]", ci->name.c_str());
+ }
+ else if (ci->HasFlag(CI_SUSPENDED))
{
- char noexpire_char = ' ';
- if (is_servadmin && (ci->HasFlag(CI_NO_EXPIRE)))
- noexpire_char = '!';
-
- if (ci->HasFlag(CI_FORBIDDEN))
- {
- snprintf(buf, sizeof(buf),
- "%-20s [Forbidden]", ci->name.c_str());
- }
- else if (ci->HasFlag(CI_SUSPENDED))
- {
- snprintf(buf, sizeof(buf),
- "%-20s [Suspended]", ci->name.c_str());
- }
- else
- {
- snprintf(buf, sizeof(buf), "%-20s %s",
- ci->name.c_str(), ci->desc ? ci->desc : "");
- }
-
- u->SendMessage(Config.s_ChanServ, " %c%s", noexpire_char, buf);
+ snprintf(buf, sizeof(buf),
+ "%-20s [Suspended]", ci->name.c_str());
}
- count++;
+ else
+ {
+ snprintf(buf, sizeof(buf), "%-20s %s",
+ ci->name.c_str(), ci->desc ? ci->desc : "");
+ }
+
+ u->SendMessage(Config.s_ChanServ, " %c%s", noexpire_char, buf);
}
+ count++;
}
}
+
notice_lang(Config.s_ChanServ, u, CHAN_LIST_END,
nchans > Config.CSListMax ? Config.CSListMax : nchans, nchans);
delete [] spattern;
@@ -188,7 +188,7 @@ public:
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSList());
+ this->AddCommand(ChanServ, new CommandCSList());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c
index 788c1adac..3480ca1b6 100644
--- a/src/core/cs_modes.c
+++ b/src/core/cs_modes.c
@@ -375,10 +375,10 @@ class CSModes : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSOp());
- this->AddCommand(CHANSERV, new CommandCSDeOp());
- this->AddCommand(CHANSERV, new CommandCSVoice());
- this->AddCommand(CHANSERV, new CommandCSDeVoice());
+ this->AddCommand(ChanServ, new CommandCSOp());
+ this->AddCommand(ChanServ, new CommandCSDeOp());
+ this->AddCommand(ChanServ, new CommandCSVoice());
+ this->AddCommand(ChanServ, new CommandCSDeVoice());
if (Me && Me->IsSynced())
OnUplinkSync();
@@ -393,31 +393,31 @@ class CSModes : public Module
{
if (ModeManager::FindChannelModeByName(CMODE_OWNER))
{
- this->AddCommand(CHANSERV, new CommandCSOwner());
- this->AddCommand(CHANSERV, new CommandCSDeOwner());
+ this->AddCommand(ChanServ, new CommandCSOwner());
+ this->AddCommand(ChanServ, new CommandCSDeOwner());
}
if (ModeManager::FindChannelModeByName(CMODE_PROTECT))
{
- this->AddCommand(CHANSERV, new CommandCSProtect());
- this->AddCommand(CHANSERV, new CommandCSDeProtect());
+ this->AddCommand(ChanServ, new CommandCSProtect());
+ this->AddCommand(ChanServ, new CommandCSDeProtect());
}
if (ModeManager::FindChannelModeByName(CMODE_HALFOP))
{
- this->AddCommand(CHANSERV, new CommandCSHalfOp());
- this->AddCommand(CHANSERV, new CommandCSDeHalfOp());
+ this->AddCommand(ChanServ, new CommandCSHalfOp());
+ this->AddCommand(ChanServ, new CommandCSDeHalfOp());
}
}
void OnServerDisconnect()
{
- this->DelCommand(CHANSERV, "OWNER");
- this->DelCommand(CHANSERV, "DEOWNER");
- this->DelCommand(CHANSERV, "PROTECT");
- this->DelCommand(CHANSERV, "DEPROTECT");
- this->DelCommand(CHANSERV, "HALFOP");
- this->DelCommand(CHANSERV, "DEHALFOP");
+ this->DelCommand(ChanServ, FindCommand(ChanServ, "OWNER"));
+ this->DelCommand(ChanServ, FindCommand(ChanServ, "DEOWNER"));
+ this->DelCommand(ChanServ, FindCommand(ChanServ, "PROTECT"));
+ this->DelCommand(ChanServ, FindCommand(ChanServ, "DEPROTECT"));
+ this->DelCommand(ChanServ, FindCommand(ChanServ, "HALFOP"));
+ this->DelCommand(ChanServ, FindCommand(ChanServ, "DEHALFOP"));
}
void OnChanServHelp(User *u)
diff --git a/src/core/cs_register.c b/src/core/cs_register.c
index 2c6531226..882e0e17c 100644
--- a/src/core/cs_register.c
+++ b/src/core/cs_register.c
@@ -44,8 +44,6 @@ class CommandCSRegister : public Command
notice_lang(Config.s_ChanServ, u, CHAN_X_INVALID, chan);
else if ((ci = cs_findchan(chan)))
notice_lang(Config.s_ChanServ, u, CHAN_ALREADY_REGISTERED, chan);
- else if (!stricmp(chan, "#"))
- notice_lang(Config.s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan);
else if (c && !c->HasUserStatus(u, CMODE_OP))
notice_lang(Config.s_ChanServ, u, CHAN_MUST_BE_CHANOP);
else if (Config.CSMaxReg && u->Account()->channelcount >= Config.CSMaxReg && !u->Account()->HasPriv("chanserv/no-register-limit"))
@@ -125,7 +123,7 @@ class CSRegister : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSRegister());
+ this->AddCommand(ChanServ, new CommandCSRegister());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_set.c b/src/core/cs_set.c
index c964d26fc..0a8d6ac5b 100644
--- a/src/core/cs_set.c
+++ b/src/core/cs_set.c
@@ -557,7 +557,7 @@ class CommandCSSet : public Command
/* Give them ChanServ
* Yes, this works fine with no Config.s_BotServ
*/
- findbot(Config.s_ChanServ)->Assign(NULL, ci);
+ ChanServ->Assign(NULL, ci);
}
/* Set the perm mode */
@@ -587,7 +587,7 @@ class CommandCSSet : public Command
if (!cm && !Config.s_BotServ && ci->bi)
{
/* Unassign bot */
- findbot(Config.s_ChanServ)->UnAssign(NULL, ci);
+ ChanServ->UnAssign(NULL, ci);
}
if (ci->c && ci->c->users.empty())
@@ -700,7 +700,7 @@ class CommandCSSet : public Command
DoSetOpNotice(u, ci, param);
else if (cmd == "XOP")
{
- if (!findModule("cs_xop"))
+ if (!FindModule("cs_xop"))
notice_lang(Config.s_ChanServ, u, CHAN_XOP_NOT_AVAILABLE, cmd.c_str());
else
DoSetXOP(u, ci, param);
@@ -826,7 +826,7 @@ class CSSet : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSSet());
+ this->AddCommand(ChanServ, new CommandCSSet());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_status.c b/src/core/cs_status.c
index 18d175f34..9db2b2d00 100644
--- a/src/core/cs_status.c
+++ b/src/core/cs_status.c
@@ -66,7 +66,7 @@ class CSStatus : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSStatus());
+ this->AddCommand(ChanServ, new CommandCSStatus());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_suspend.c b/src/core/cs_suspend.c
index 39b1f9fd5..654dd9711 100644
--- a/src/core/cs_suspend.c
+++ b/src/core/cs_suspend.c
@@ -73,7 +73,7 @@ class CommandCSSuspend : public Command
}
if (Config.WallForbid)
- ircdproto->SendGlobops(findbot(Config.s_ChanServ), "\2%s\2 used SUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str());
+ ircdproto->SendGlobops(ChanServ, "\2%s\2 used SUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str());
Alog() << Config.s_ChanServ << ": " << u->GetMask() << " set SUSPEND for channel " << ci->name;
notice_lang(Config.s_ChanServ, u, CHAN_SUSPEND_SUCCEEDED, chan);
@@ -143,7 +143,7 @@ class CommandCSUnSuspend : public Command
}
if (Config.WallForbid)
- ircdproto->SendGlobops(findbot(Config.s_ChanServ), "\2%s\2 used UNSUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str());
+ ircdproto->SendGlobops(ChanServ, "\2%s\2 used UNSUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str());
Alog() << Config.s_ChanServ << ": " << u->GetMask() << " set UNSUSPEND for channel " << ci->name;
notice_lang(Config.s_ChanServ, u, CHAN_UNSUSPEND_SUCCEEDED, chan);
@@ -179,8 +179,8 @@ class CSSuspend : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSSuspend());
- this->AddCommand(CHANSERV, new CommandCSUnSuspend());
+ this->AddCommand(ChanServ, new CommandCSSuspend());
+ this->AddCommand(ChanServ, new CommandCSUnSuspend());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_topic.c b/src/core/cs_topic.c
index da41e0ac3..b8642666c 100644
--- a/src/core/cs_topic.c
+++ b/src/core/cs_topic.c
@@ -55,14 +55,14 @@ class CommandCSTopic : public Command
if (!check_access(u, ci, CA_TOPIC))
Alog() << Config.s_NickServ << ": " << u->GetMask() << " changed topic of " << c->name << " as services admin.";
- if (ircd->join2set && whosends(ci) == findbot(Config.s_ChanServ))
+ if (ircd->join2set && whosends(ci) == ChanServ)
{
- ircdproto->SendJoin(findbot(Config.s_ChanServ), c->name.c_str(), c->creation_time);
+ ircdproto->SendJoin(ChanServ, c->name.c_str(), c->creation_time);
ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ);
}
ircdproto->SendTopic(whosends(ci), c, u->nick.c_str(), topic ? topic : "");
- if (ircd->join2set && whosends(ci) == findbot(Config.s_ChanServ))
- ircdproto->SendPart(findbot(Config.s_ChanServ), c, NULL);
+ if (ircd->join2set && whosends(ci) == ChanServ)
+ ircdproto->SendPart(ChanServ, c, NULL);
}
return MOD_CONT;
}
@@ -88,7 +88,7 @@ class CSTopic : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSTopic());
+ this->AddCommand(ChanServ, new CommandCSTopic());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_unban.c b/src/core/cs_unban.c
index aa6184fbb..0ae2077ed 100644
--- a/src/core/cs_unban.c
+++ b/src/core/cs_unban.c
@@ -78,7 +78,7 @@ class CSUnban : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSUnban());
+ this->AddCommand(ChanServ, new CommandCSUnban());
ModuleManager::Attach(I_OnChanServHelp, this);
}
diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c
index 18ff222b1..522c28001 100644
--- a/src/core/cs_xop.c
+++ b/src/core/cs_xop.c
@@ -540,9 +540,9 @@ class CSXOP : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(CHANSERV, new CommandCSSOP());
- this->AddCommand(CHANSERV, new CommandCSAOP());
- this->AddCommand(CHANSERV, new CommandCSVOP());
+ this->AddCommand(ChanServ, new CommandCSSOP());
+ this->AddCommand(ChanServ, new CommandCSAOP());
+ this->AddCommand(ChanServ, new CommandCSVOP());
if (Me && Me->IsSynced())
OnUplinkSync();
@@ -556,15 +556,15 @@ class CSXOP : public Module
void OnUplinkSync()
{
if (ModeManager::FindChannelModeByName(CMODE_OWNER))
- this->AddCommand(CHANSERV, new CommandCSQOP());
+ this->AddCommand(ChanServ, new CommandCSQOP());
if (ModeManager::FindChannelModeByName(CMODE_HALFOP))
- this->AddCommand(CHANSERV, new CommandCSHOP());
+ this->AddCommand(ChanServ, new CommandCSHOP());
}
void OnServerDisconnect()
{
- this->DelCommand(CHANSERV, "QOP");
- this->DelCommand(CHANSERV, "HOP");
+ this->DelCommand(ChanServ, FindCommand(ChanServ, "QOP"));
+ this->DelCommand(ChanServ, FindCommand(ChanServ, "HOP"));
}
void OnChanServHelp(User *u)
diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp
index 24b494d82..095082009 100644
--- a/src/core/db_plain.cpp
+++ b/src/core/db_plain.cpp
@@ -422,11 +422,11 @@ static void LoadBotInfo(const std::vector<std::string> &params)
BotInfo *bi = findbot(params[0]);
if (!bi)
bi = new BotInfo(params[0]);
- bi->user = sstrdup(params[1].c_str());
- bi->host = sstrdup(params[2].c_str());
+ bi->user = params[1];
+ bi->host = params[2];
bi->created = atol(params[3].c_str());
bi->chancount = atol(params[4].c_str());
- bi->real = sstrdup(params[5].c_str());
+ bi->real = params[5];
Alog(LOG_DEBUG_2) << "[db_plain]: Loaded botinfo for " << bi->nick;
}
@@ -560,7 +560,7 @@ class DBPlain : public Module
Alog(LOG_DEBUG) << "db_plain: Attemping to rename " << DatabaseFile << " to " << newname;
if (rename(DatabaseFile.c_str(), newname) != 0)
{
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "Unable to backup database!");
+ ircdproto->SendGlobops(OperServ, "Unable to backup database!");
Alog() << "Unable to back up database!";
if (!Config.NoBackupOkay)
@@ -698,20 +698,6 @@ class DBPlain : public Module
{
if (params[j] == "PRIVATE")
bi->SetFlag(BI_PRIVATE);
- else if (params[j] == "CHANSERV")
- bi->SetFlag(BI_CHANSERV);
- else if (params[j] == "BOTSERV")
- bi->SetFlag(BI_BOTSERV);
- else if (params[j] == "HOSTSERV")
- bi->SetFlag(BI_HOSTSERV);
- else if (params[j] == "OPERSERV")
- bi->SetFlag(BI_OPERSERV);
- else if (params[j] == "MEMOSERV")
- bi->SetFlag(BI_MEMOSERV);
- else if (params[j] == "NICKSERV")
- bi->SetFlag(BI_NICKSERV);
- else if (params[j] == "GLOBAL")
- bi->SetFlag(BI_GLOBAL);
}
}
@@ -936,277 +922,255 @@ class DBPlain : public Module
db << "VER 1" << endl;
- for (int i = 0; i < 1024; ++i)
+ for (nickrequest_map::const_iterator it = NickRequestList.begin(); it != NickRequestList.end(); ++it)
{
- for (NickRequest *nr = nrlists[i]; nr; nr = nr->next)
- {
- db << "NR " << nr->nick << " " << nr->passcode << " " << nr->password << " " << nr->email << " " << nr->requested << endl;
+ NickRequest *nr = it->second;
+
+ db << "NR " << nr->nick << " " << nr->passcode << " " << nr->password << " " << nr->email << " " << nr->requested << endl;
- FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, nr));
- }
+ FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, nr));
}
- for (int i = 0; i < 1024; ++i)
+ for (nickcore_map::const_iterator nit = NickCoreList.begin(); nit != NickCoreList.end(); ++nit)
{
- for (NickCore *nc = nclists[i]; nc; nc = nc->next)
+ NickCore *nc = nit->second;
+
+ if (nc->HasFlag(NI_FORBIDDEN))
{
- if (nc->HasFlag(NI_FORBIDDEN))
- {
- db << "NC " << nc->display << endl;
- db << "MD FLAGS FORBIDDEN" << endl;
- FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, nc));
- continue;
- }
- else
- {
- db << "NC " << nc->display << " " << nc->pass << " ";
- }
- for (int j = 0; LangInfos[j].LanguageId != -1; ++j)
- if (nc->language == LangInfos[j].LanguageId)
- db << LangInfos[j].Name;
- db << " " << nc->memos.memomax << " " << nc->channelcount << endl;
-
- if (nc->email)
- db << "MD EMAIL " << nc->email << endl;
- if (nc->greet)
- db << "MD GREET :" << nc->greet << endl;
- if (nc->icq)
- db << "MD ICQ :" << nc->icq << endl;
- if (nc->url)
- db << "MD URL :" << nc->url << endl;
- if (!nc->access.empty())
- {
- for (std::vector<std::string>::iterator it = nc->access.begin(); it != nc->access.end(); ++it)
- db << "MD ACCESS " << *it << endl;
- }
- if (nc->FlagCount())
- {
- db << "MD FLAGS";
- for (int j = 0; NickCoreFlags[j].Flag != -1; ++j)
- if (nc->HasFlag(NickCoreFlags[j].Flag))
- db << " " << NickCoreFlags[j].Name;
- db << endl;
- }
- if (!nc->memos.memos.empty())
+ db << "NC " << nc->display << endl;
+ db << "MD FLAGS FORBIDDEN" << endl;
+ FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, nc));
+ continue;
+ }
+ else
+ {
+ db << "NC " << nc->display << " " << nc->pass << " ";
+ }
+ for (int j = 0; LangInfos[j].LanguageId != -1; ++j)
+ if (nc->language == LangInfos[j].LanguageId)
+ db << LangInfos[j].Name;
+ db << " " << nc->memos.memomax << " " << nc->channelcount << endl;
+
+ if (nc->email)
+ db << "MD EMAIL " << nc->email << endl;
+ if (nc->greet)
+ db << "MD GREET :" << nc->greet << endl;
+ if (nc->icq)
+ db << "MD ICQ :" << nc->icq << endl;
+ if (nc->url)
+ db << "MD URL :" << nc->url << endl;
+ if (!nc->access.empty())
+ {
+ for (std::vector<std::string>::iterator it = nc->access.begin(); it != nc->access.end(); ++it)
+ db << "MD ACCESS " << *it << endl;
+ }
+ if (nc->FlagCount())
+ {
+ db << "MD FLAGS";
+ for (int j = 0; NickCoreFlags[j].Flag != -1; ++j)
+ if (nc->HasFlag(NickCoreFlags[j].Flag))
+ db << " " << NickCoreFlags[j].Name;
+ db << endl;
+ }
+ if (!nc->memos.memos.empty())
+ {
+ MemoInfo *mi = &nc->memos;
+ for (unsigned k = 0; k < mi->memos.size(); ++k)
{
- MemoInfo *mi = &nc->memos;
- for (unsigned k = 0; k < mi->memos.size(); ++k)
- {
- db << "MD MI " << mi->memos[k]->number << " " << mi->memos[k]->time << " " << mi->memos[k]->sender;
- if (mi->memos[k]->HasFlag(MF_UNREAD))
- db << " UNREAD";
- if (mi->memos[k]->HasFlag(MF_RECEIPT))
- db << " RECEIPT";
- if (mi->memos[k]->HasFlag(MF_NOTIFYS))
- db << " NOTIFYS";
- db << " :" << mi->memos[k]->text << endl;
- }
+ db << "MD MI " << mi->memos[k]->number << " " << mi->memos[k]->time << " " << mi->memos[k]->sender;
+ if (mi->memos[k]->HasFlag(MF_UNREAD))
+ db << " UNREAD";
+ if (mi->memos[k]->HasFlag(MF_RECEIPT))
+ db << " RECEIPT";
+ if (mi->memos[k]->HasFlag(MF_NOTIFYS))
+ db << " NOTIFYS";
+ db << " :" << mi->memos[k]->text << endl;
}
-
- FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, nc));
-
}
+ FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, nc));
+
}
- for (int i = 0; i < 1024; ++i)
+ for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
{
- for (NickAlias *na = nalists[i]; na; na = na->next)
+ NickAlias *na = it->second;
+
+ db << "NA " << na->nc->display << " " << na->nick << " " << na->time_registered << " " << na->last_seen << endl;
+ if (na->last_usermask)
+ db << "MD LAST_USERMASK " << na->last_usermask << endl;
+ if (na->last_realname)
+ db << "MD LAST_REALNAME :" << na->last_realname << endl;
+ if (na->last_quit)
+ db << "MD LAST_QUIT :" << na->last_quit << endl;
+ if (na->HasFlag(NS_FORBIDDEN) || na->HasFlag(NS_NO_EXPIRE))
{
- db << "NA " << na->nc->display << " " << na->nick << " " << na->time_registered << " " << na->last_seen << endl;
- if (na->last_usermask)
- db << "MD LAST_USERMASK " << na->last_usermask << endl;
- if (na->last_realname)
- db << "MD LAST_REALNAME :" << na->last_realname << endl;
- if (na->last_quit)
- db << "MD LAST_QUIT :" << na->last_quit << endl;
- if (na->HasFlag(NS_FORBIDDEN) || na->HasFlag(NS_NO_EXPIRE))
- {
- db << "MD FLAGS" << (na->HasFlag(NS_FORBIDDEN) ? " FORBIDDEN" : "") << (na->HasFlag(NS_NO_EXPIRE) ? " NOEXPIRE " : "") << endl;
- }
- if (na->hostinfo.HasVhost())
- {
- db << "MD VHOST " << na->hostinfo.GetCreator() << " " << na->hostinfo.GetTime() << " " << na->hostinfo.GetHost() << " :" << na->hostinfo.GetIdent() << endl;
- }
-
- FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, na));
+ db << "MD FLAGS" << (na->HasFlag(NS_FORBIDDEN) ? " FORBIDDEN" : "") << (na->HasFlag(NS_NO_EXPIRE) ? " NOEXPIRE " : "") << endl;
+ }
+ if (na->hostinfo.HasVhost())
+ {
+ db << "MD VHOST " << na->hostinfo.GetCreator() << " " << na->hostinfo.GetTime() << " " << na->hostinfo.GetHost() << " :" << na->hostinfo.GetIdent() << endl;
}
+
+ FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, na));
}
- for (int i = 0; i < 256; ++i)
+ for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it)
{
- for (BotInfo *bi = botlists[i]; bi; bi = bi->next)
+ BotInfo *bi = it->second;
+
+ db << "BI " << bi->nick << " " << bi->user << " " << bi->host << " " << bi->created << " " << bi->chancount << " :" << bi->real << endl;
+ if (bi->FlagCount())
{
- db << "BI " << bi->nick << " " << bi->user << " " << bi->host << " " << bi->created << " " << bi->chancount << " :" << bi->real << endl;
- if (bi->FlagCount())
- {
- db << "MD FLAGS";
- if (bi->HasFlag(BI_PRIVATE))
- db << " PRIVATE";
- if (bi->HasFlag(BI_CHANSERV))
- db << " CHANSERV";
- else if (bi->HasFlag(BI_BOTSERV))
- db << " BOTSERV";
- else if (bi->HasFlag(BI_HOSTSERV))
- db << " HOSTSERV";
- else if (bi->HasFlag(BI_OPERSERV))
- db << " OPERSERV";
- else if (bi->HasFlag(BI_MEMOSERV))
- db << " MEMOSERV";
- else if (bi->HasFlag(BI_NICKSERV))
- db << " NICKSERV";
- else if (bi->HasFlag(BI_GLOBAL))
- db << " GLOBAL";
- db << endl;
- }
-
- FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, bi));
+ db << "MD FLAGS";
+ if (bi->HasFlag(BI_PRIVATE))
+ db << " PRIVATE";
+ db << endl;
}
}
- for (int i = 0; i < 256; ++i)
+ for (registered_channel_map::const_iterator cit = RegisteredChannelList.begin(); cit != RegisteredChannelList.end(); ++cit)
{
- for (ChannelInfo *ci = chanlists[i]; ci; ci = ci->next)
+ ChannelInfo *ci = cit->second;
+
+ db << "CH " << ci->name << " " << ci->time_registered << " " << ci->last_used;
+ db << " " << ci->bantype << " " << ci->memos.memomax << endl;
+ if (ci->founder)
+ db << "MD FOUNDER " << ci->founder->display << endl;
+ if (ci->successor)
+ db << "MD SUCCESSOR " << ci->successor->display << endl;
+ if (ci->desc)
+ db << "MD DESC :" << ci->desc << endl;
+ if (ci->url)
+ db << "MD URL :" << ci->url << endl;
+ if (ci->email)
+ db << "MD EMAIL :" << ci->email << endl;
+ if (ci->last_topic)
+ db << "MD TOPIC " << ci->last_topic_setter << " " << ci->last_topic_time << " :" << ci->last_topic << endl;
+ db << "MD LEVELS";
+ for (int j = 0; ChannelLevels[j].Level != -1; ++j)
+ db << " " << ChannelLevels[j].Name << " " << ci->levels[ChannelLevels[j].Level];
+ db << endl;
+ if (ci->FlagCount())
{
- db << "CH " << ci->name << " " << ci->time_registered << " " << ci->last_used;
- db << " " << ci->bantype << " " << ci->memos.memomax << endl;
- if (ci->founder)
- db << "MD FOUNDER " << ci->founder->display << endl;
- if (ci->successor)
- db << "MD SUCCESSOR " << ci->successor->display << endl;
- if (ci->desc)
- db << "MD DESC :" << ci->desc << endl;
- if (ci->url)
- db << "MD URL :" << ci->url << endl;
- if (ci->email)
- db << "MD EMAIL :" << ci->email << endl;
- if (ci->last_topic)
- db << "MD TOPIC " << ci->last_topic_setter << " " << ci->last_topic_time << " :" << ci->last_topic << endl;
- db << "MD LEVELS";
- for (int j = 0; ChannelLevels[j].Level != -1; ++j)
- db << " " << ChannelLevels[j].Name << " " << ci->levels[ChannelLevels[j].Level];
+ db << "MD FLAGS";
+ for (int j = 0; ChannelInfoFlags[j].Flag != -1; ++j)
+ if (ci->HasFlag(ChannelInfoFlags[j].Flag))
+ db << " " << ChannelInfoFlags[j].Name;
db << endl;
- if (ci->FlagCount())
- {
- db << "MD FLAGS";
- for (int j = 0; ChannelInfoFlags[j].Flag != -1; ++j)
- if (ci->HasFlag(ChannelInfoFlags[j].Flag))
- db << " " << ChannelInfoFlags[j].Name;
- db << endl;
- if (ci->HasFlag(CI_FORBIDDEN))
- db << "MD FORBID " << ci->forbidby << " :" << ci->forbidreason << endl;
- }
- for (unsigned k = 0; k < ci->GetAccessCount(); ++k)
- if (ci->GetAccess(k)->in_use)
- db << "MD ACCESS " << ci->GetAccess(k)->nc->display << " " << ci->GetAccess(k)->level << " "
- << ci->GetAccess(k)->last_seen << " " << ci->GetAccess(k)->creator << endl;
- for (unsigned k = 0; k < ci->GetAkickCount(); ++k)
- {
- db << "MD AKICK "
- << (ci->GetAkick(k)->HasFlag(AK_STUCK) ? "STUCK " : "UNSTUCK ")
- << (ci->GetAkick(k)->HasFlag(AK_ISNICK) ? "NICK " : "MASK ")
- << (ci->GetAkick(k)->HasFlag(AK_ISNICK) ? ci->GetAkick(k)->nc->display : ci->GetAkick(k)->mask)
- << " " << ci->GetAkick(k)->creator << " " << ci->GetAkick(k)->addtime
- << " " << ci->last_used << " :";
- if (!ci->GetAkick(k)->reason.empty())
- db << ci->GetAkick(k)->reason;
- db << endl;
- }
- if (ci->GetMLockCount(true))
+ if (ci->HasFlag(CI_FORBIDDEN))
+ db << "MD FORBID " << ci->forbidby << " :" << ci->forbidreason << endl;
+ }
+ for (unsigned k = 0; k < ci->GetAccessCount(); ++k)
+ if (ci->GetAccess(k)->in_use)
+ db << "MD ACCESS " << ci->GetAccess(k)->nc->display << " " << ci->GetAccess(k)->level << " "
+ << ci->GetAccess(k)->last_seen << " " << ci->GetAccess(k)->creator << endl;
+ for (unsigned k = 0; k < ci->GetAkickCount(); ++k)
+ {
+ db << "MD AKICK "
+ << (ci->GetAkick(k)->HasFlag(AK_STUCK) ? "STUCK " : "UNSTUCK ")
+ << (ci->GetAkick(k)->HasFlag(AK_ISNICK) ? "NICK " : "MASK ")
+ << (ci->GetAkick(k)->HasFlag(AK_ISNICK) ? ci->GetAkick(k)->nc->display : ci->GetAkick(k)->mask)
+ << " " << ci->GetAkick(k)->creator << " " << ci->GetAkick(k)->addtime
+ << " " << ci->last_used << " :";
+ if (!ci->GetAkick(k)->reason.empty())
+ db << ci->GetAkick(k)->reason;
+ db << endl;
+ }
+ if (ci->GetMLockCount(true))
+ {
+ db << "MD MLOCK_ON";
+ for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
{
- db << "MD MLOCK_ON";
- for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
+ if ((*it)->Class == MC_CHANNEL)
{
- if ((*it)->Class == MC_CHANNEL)
- {
- ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
+ ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
- if (ci->HasMLock(cm->Name, true))
- {
- db << " " << cm->NameAsString;
- }
- }
- }
- db << endl;
- }
- if (ci->GetMLockCount(false))
- {
- db << "MD MLOCK_OFF";
- for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
- {
- if ((*it)->Class == MC_CHANNEL)
+ if (ci->HasMLock(cm->Name, true))
{
- ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
-
- if (ci->HasMLock(cm->Name, false))
- {
- db << " " << cm->NameAsString;
- }
+ db << " " << cm->NameAsString;
}
}
- db << endl;
}
- std::string Param;
+ db << endl;
+ }
+ if (ci->GetMLockCount(false))
+ {
+ db << "MD MLOCK_OFF";
for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
{
if ((*it)->Class == MC_CHANNEL)
{
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
- if (ci->GetParam(cm->Name, Param))
+ if (ci->HasMLock(cm->Name, false))
{
- db << "MD MLP " << cm->NameAsString << " " << Param << endl;
+ db << " " << cm->NameAsString;
}
}
}
- if (!ci->memos.memos.empty())
+ db << endl;
+ }
+ std::string Param;
+ for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
+ {
+ if ((*it)->Class == MC_CHANNEL)
{
- MemoInfo *memos = &ci->memos;
+ ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
- for (unsigned k = 0; k < memos->memos.size(); ++k)
+ if (ci->GetParam(cm->Name, Param))
{
- db << "MD MI " << memos->memos[k]->number << " " << memos->memos[k]->time << " " << memos->memos[k]->sender;
- if (memos->memos[k]->HasFlag(MF_UNREAD))
- db << " UNREAD";
- if (memos->memos[k]->HasFlag(MF_RECEIPT))
- db << " RECEIPT";
- if (memos->memos[k]->HasFlag(MF_NOTIFYS))
- db << " NOTIFYS";
- db << " :" << memos->memos[k]->text << endl;
+ db << "MD MLP " << cm->NameAsString << " " << Param << endl;
}
}
- if (ci->entry_message)
- db << "MD ENTRYMSG :" << ci->entry_message << endl;
- if (ci->bi)
- db << "MD BI NAME " << ci->bi->nick << endl;
- if (ci->botflags.FlagCount())
+ }
+ if (!ci->memos.memos.empty())
+ {
+ MemoInfo *memos = &ci->memos;
+
+ for (unsigned k = 0; k < memos->memos.size(); ++k)
{
- db << "MD BI FLAGS";
- for (int j = 0; BotFlags[j].Flag != -1; ++j)
- if (ci->botflags.HasFlag(BotFlags[j].Flag))
- db << " " << BotFlags[j].Name;
- db << endl;
+ db << "MD MI " << memos->memos[k]->number << " " << memos->memos[k]->time << " " << memos->memos[k]->sender;
+ if (memos->memos[k]->HasFlag(MF_UNREAD))
+ db << " UNREAD";
+ if (memos->memos[k]->HasFlag(MF_RECEIPT))
+ db << " RECEIPT";
+ if (memos->memos[k]->HasFlag(MF_NOTIFYS))
+ db << " NOTIFYS";
+ db << " :" << memos->memos[k]->text << endl;
}
- db << "MD BI TTB BOLDS " << ci->ttb[0] << " COLORS " << ci->ttb[1] << " REVERSES " << ci->ttb[2] << " UNDERLINES " << ci->ttb[3] << " BADWORDS " << ci->ttb[4] << " CAPS " << ci->ttb[5] << " FLOOD " << ci->ttb[6] << " REPEAT " << ci->ttb[7] << endl;
- if (ci->capsmin)
- db << "MD BI CAPSMIN " << ci->capsmin << endl;
- if (ci->capspercent)
- db << "MD BI CAPSPERCENT " << ci->capspercent << endl;
- if (ci->floodlines)
- db << "MD BI FLOODLINES " << ci->floodlines << endl;
- if (ci->floodsecs)
- db << "MD BI FLOODSECS " << ci->floodsecs << endl;
- if (ci->repeattimes)
- db << "MD BI REPEATTIMES " << ci->repeattimes << endl;
- for (unsigned k = 0; k < ci->GetBadWordCount(); ++k)
- db << "MD BI BADWORD "
- << (ci->GetBadWord(k)->type == BW_ANY ? "ANY " : "")
- << (ci->GetBadWord(k)->type == BW_SINGLE ? "SINGLE " : "")
- << (ci->GetBadWord(k)->type == BW_START ? "START " : "")
- << (ci->GetBadWord(k)->type == BW_END ? "END " : "")
- << ":" << ci->GetBadWord(k)->word << endl;
-
- FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, ci));
}
+ if (ci->entry_message)
+ db << "MD ENTRYMSG :" << ci->entry_message << endl;
+ if (ci->bi)
+ db << "MD BI NAME " << ci->bi->nick << endl;
+ if (ci->botflags.FlagCount())
+ {
+ db << "MD BI FLAGS";
+ for (int j = 0; BotFlags[j].Flag != -1; ++j)
+ if (ci->botflags.HasFlag(BotFlags[j].Flag))
+ db << " " << BotFlags[j].Name;
+ db << endl;
+ }
+ db << "MD BI TTB BOLDS " << ci->ttb[0] << " COLORS " << ci->ttb[1] << " REVERSES " << ci->ttb[2] << " UNDERLINES " << ci->ttb[3] << " BADWORDS " << ci->ttb[4] << " CAPS " << ci->ttb[5] << " FLOOD " << ci->ttb[6] << " REPEAT " << ci->ttb[7] << endl;
+ if (ci->capsmin)
+ db << "MD BI CAPSMINS " << ci->capsmin << endl;
+ if (ci->capspercent)
+ db << "MD BI CAPSPERCENT " << ci->capspercent << endl;
+ if (ci->floodlines)
+ db << "MD BI FLOODLINES " << ci->floodlines << endl;
+ if (ci->floodsecs)
+ db << "MD BI FLOODSECS " << ci->floodsecs << endl;
+ if (ci->repeattimes)
+ db << "MD BI REPEATTIMES " << ci->repeattimes << endl;
+ for (unsigned k = 0; k < ci->GetBadWordCount(); ++k)
+ db << "MD BI BADWORD "
+ << (ci->GetBadWord(k)->type == BW_ANY ? "ANY " : "")
+ << (ci->GetBadWord(k)->type == BW_SINGLE ? "SINGLE " : "")
+ << (ci->GetBadWord(k)->type == BW_START ? "START " : "")
+ << (ci->GetBadWord(k)->type == BW_END ? "END " : "")
+ << ":" << ci->GetBadWord(k)->word << endl;
+
+ FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, ci));
}
for (int i = 0; i < akills.count; ++i)
diff --git a/src/core/hs_del.c b/src/core/hs_del.c
index 286366735..12610d31f 100644
--- a/src/core/hs_del.c
+++ b/src/core/hs_del.c
@@ -63,7 +63,7 @@ class HSDel : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(HOSTSERV, new CommandHSDel());
+ this->AddCommand(HostServ, new CommandHSDel());
ModuleManager::Attach(I_OnHostServHelp, this);
}
diff --git a/src/core/hs_delall.c b/src/core/hs_delall.c
index b40565e3d..05c67660d 100644
--- a/src/core/hs_delall.c
+++ b/src/core/hs_delall.c
@@ -70,7 +70,7 @@ class HSDelAll : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(HOSTSERV, new CommandHSDelAll());
+ this->AddCommand(HostServ, new CommandHSDelAll());
ModuleManager::Attach(I_OnHostServHelp, this);
}
diff --git a/src/core/hs_group.c b/src/core/hs_group.c
index e4117ba9c..3c744ef90 100644
--- a/src/core/hs_group.c
+++ b/src/core/hs_group.c
@@ -56,7 +56,7 @@ class HSGroup : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(HOSTSERV, new CommandHSGroup());
+ this->AddCommand(HostServ, new CommandHSGroup());
ModuleManager::Attach(I_OnHostServHelp, this);
}
diff --git a/src/core/hs_help.c b/src/core/hs_help.c
index 0522c09d4..7e8d1e69a 100644
--- a/src/core/hs_help.c
+++ b/src/core/hs_help.c
@@ -24,7 +24,7 @@ class CommandHSHelp : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- mod_help_cmd(Config.s_HostServ, u, HOSTSERV, params[0].c_str());
+ mod_help_cmd(HostServ, u, params[0].c_str());
return MOD_CONT;
}
@@ -44,7 +44,7 @@ class HSHelp : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(HOSTSERV, new CommandHSHelp());
+ this->AddCommand(HostServ, new CommandHSHelp());
}
};
diff --git a/src/core/hs_list.c b/src/core/hs_list.c
index e86f2d0dc..427864e54 100644
--- a/src/core/hs_list.c
+++ b/src/core/hs_list.c
@@ -53,47 +53,46 @@ class CommandHSList : public Command
}
}
- for (int j = 0; j < 1024; ++j)
+ for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
{
- for (NickAlias *na = nalists[j]; na; na = na->next)
- {
- if (!na->hostinfo.HasVhost())
- continue;
+ NickAlias *na = it->second;
+
+ if (!na->hostinfo.HasVhost())
+ continue;
- if (!key.empty() && key[0] != '#')
+ if (!key.empty() && key[0] != '#')
+ {
+ if ((Anope::Match(na->nick, key) || Anope::Match(na->hostinfo.GetHost(), key.c_str())) && display_counter < Config.NSListMax)
{
- if ((Anope::Match(na->nick, key) || Anope::Match(na->hostinfo.GetHost(), key.c_str())) && display_counter < Config.NSListMax)
- {
- ++display_counter;
- time_t time = na->hostinfo.GetTime();
- tm = localtime(&time);
- strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
- if (!na->hostinfo.GetIdent().empty())
- notice_lang(Config.s_HostServ, u, HOST_IDENT_ENTRY, counter, na->nick, na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
- else
- notice_lang(Config.s_HostServ, u, HOST_ENTRY, counter, na->nick, na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
- }
+ ++display_counter;
+ time_t time = na->hostinfo.GetTime();
+ tm = localtime(&time);
+ strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
+ if (!na->hostinfo.GetIdent().empty())
+ notice_lang(Config.s_HostServ, u, HOST_IDENT_ENTRY, counter, na->nick, na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
+ else
+ notice_lang(Config.s_HostServ, u, HOST_ENTRY, counter, na->nick, na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
}
- else
+ }
+ else
+ {
+ /**
+ * List the host if its in the display range, and not more
+ * than NSListMax records have been displayed...
+ **/
+ if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < Config.NSListMax)
{
- /**
- * List the host if its in the display range, and not more
- * than NSListMax records have been displayed...
- **/
- if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < Config.NSListMax)
- {
- ++display_counter;
- time_t time = na->hostinfo.GetTime();
- tm = localtime(&time);
- strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
- if (!na->hostinfo.GetIdent().empty())
- notice_lang(Config.s_HostServ, u, HOST_IDENT_ENTRY, counter, na->nick, na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
- else
- notice_lang(Config.s_HostServ, u, HOST_ENTRY, counter, na->nick, na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
- }
+ ++display_counter;
+ time_t time = na->hostinfo.GetTime();
+ tm = localtime(&time);
+ strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
+ if (!na->hostinfo.GetIdent().empty())
+ notice_lang(Config.s_HostServ, u, HOST_IDENT_ENTRY, counter, na->nick, na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
+ else
+ notice_lang(Config.s_HostServ, u, HOST_ENTRY, counter, na->nick, na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
}
- ++counter;
}
+ ++counter;
}
if (!key.empty())
notice_lang(Config.s_HostServ, u, HOST_LIST_KEY_FOOTER, key.c_str(), display_counter);
@@ -123,7 +122,7 @@ class HSList : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(HOSTSERV, new CommandHSList());
+ this->AddCommand(HostServ, new CommandHSList());
ModuleManager::Attach(I_OnHostServHelp, this);
}
diff --git a/src/core/hs_off.c b/src/core/hs_off.c
index 5943e8850..ac6416cea 100644
--- a/src/core/hs_off.c
+++ b/src/core/hs_off.c
@@ -52,7 +52,7 @@ class HSOff : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(HOSTSERV, new CommandHSOff());
+ this->AddCommand(HostServ, new CommandHSOff());
ModuleManager::Attach(I_OnHostServHelp, this);
}
diff --git a/src/core/hs_on.c b/src/core/hs_on.c
index 2194e2d2b..d04040de1 100644
--- a/src/core/hs_on.c
+++ b/src/core/hs_on.c
@@ -66,7 +66,7 @@ class HSOn : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(HOSTSERV, new CommandHSOn());
+ this->AddCommand(HostServ, new CommandHSOn());
ModuleManager::Attach(I_OnHostServHelp, this);
}
diff --git a/src/core/hs_set.c b/src/core/hs_set.c
index b382cb0ea..a570986ac 100644
--- a/src/core/hs_set.c
+++ b/src/core/hs_set.c
@@ -160,7 +160,7 @@ class HSSet : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(HOSTSERV, new CommandHSSet());
+ this->AddCommand(HostServ, new CommandHSSet());
ModuleManager::Attach(I_OnHostServHelp, this);
}
diff --git a/src/core/hs_setall.c b/src/core/hs_setall.c
index 9afb26206..dd90d4153 100644
--- a/src/core/hs_setall.c
+++ b/src/core/hs_setall.c
@@ -158,7 +158,7 @@ class HSSetAll : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(HOSTSERV, new CommandHSSetAll());
+ this->AddCommand(HostServ, new CommandHSSetAll());
ModuleManager::Attach(I_OnHostServHelp, this);
}
diff --git a/src/core/ms_cancel.c b/src/core/ms_cancel.c
index c2eeee4c5..33d8006db 100644
--- a/src/core/ms_cancel.c
+++ b/src/core/ms_cancel.c
@@ -79,7 +79,7 @@ class MSCancel : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSCancel());
+ this->AddCommand(MemoServ, new CommandMSCancel());
ModuleManager::Attach(I_OnMemoServHelp, this);
}
diff --git a/src/core/ms_check.c b/src/core/ms_check.c
index 47270a4ab..51281574e 100644
--- a/src/core/ms_check.c
+++ b/src/core/ms_check.c
@@ -95,7 +95,7 @@ class MSCheck : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSCheck());
+ this->AddCommand(MemoServ, new CommandMSCheck());
ModuleManager::Attach(I_OnMemoServHelp, this);
}
diff --git a/src/core/ms_del.c b/src/core/ms_del.c
index f5c27cc4e..b2fd08fa1 100644
--- a/src/core/ms_del.c
+++ b/src/core/ms_del.c
@@ -168,7 +168,7 @@ class MSDel : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSDel());
+ this->AddCommand(MemoServ, new CommandMSDel());
ModuleManager::Attach(I_OnMemoServHelp, this);
}
diff --git a/src/core/ms_help.c b/src/core/ms_help.c
index baa74aa93..09570eca2 100644
--- a/src/core/ms_help.c
+++ b/src/core/ms_help.c
@@ -24,7 +24,7 @@ class CommandMSHelp : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- mod_help_cmd(Config.s_MemoServ, u, MEMOSERV, params[0].c_str());
+ mod_help_cmd(MemoServ, u, params[0].c_str());
return MOD_CONT;
}
@@ -44,7 +44,7 @@ class MSHelp : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSHelp());
+ this->AddCommand(MemoServ, new CommandMSHelp());
}
};
diff --git a/src/core/ms_info.c b/src/core/ms_info.c
index a1066f466..0519fd5b8 100644
--- a/src/core/ms_info.c
+++ b/src/core/ms_info.c
@@ -208,7 +208,7 @@ class MSInfo : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSInfo());
+ this->AddCommand(MemoServ, new CommandMSInfo());
ModuleManager::Attach(I_OnMemoServHelp, this);
}
diff --git a/src/core/ms_list.c b/src/core/ms_list.c
index 5e97615ab..a2e63c2da 100644
--- a/src/core/ms_list.c
+++ b/src/core/ms_list.c
@@ -115,7 +115,7 @@ class MSList : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSList());
+ this->AddCommand(MemoServ, new CommandMSList());
ModuleManager::Attach(I_OnMemoServHelp, this);
}
diff --git a/src/core/ms_read.c b/src/core/ms_read.c
index d5e10b213..65b5c3a4b 100644
--- a/src/core/ms_read.c
+++ b/src/core/ms_read.c
@@ -124,7 +124,7 @@ class MSRead : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSRead());
+ this->AddCommand(MemoServ, new CommandMSRead());
ModuleManager::Attach(I_OnMemoServHelp, this);
}
diff --git a/src/core/ms_rsend.c b/src/core/ms_rsend.c
index d8ebc1245..7759edb2c 100644
--- a/src/core/ms_rsend.c
+++ b/src/core/ms_rsend.c
@@ -79,7 +79,7 @@ class MSRSend : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSRSend());
+ this->AddCommand(MemoServ, new CommandMSRSend());
if (!Config.MSMemoReceipt)
throw ModuleException("Don't like memo reciepts, or something.");
diff --git a/src/core/ms_send.c b/src/core/ms_send.c
index 12123fda8..ffd3a911c 100644
--- a/src/core/ms_send.c
+++ b/src/core/ms_send.c
@@ -50,7 +50,7 @@ class MSSend : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSSend());
+ this->AddCommand(MemoServ, new CommandMSSend());
ModuleManager::Attach(I_OnMemoServHelp, this);
}
diff --git a/src/core/ms_sendall.c b/src/core/ms_sendall.c
index 4a09457e2..2e3abe640 100644
--- a/src/core/ms_sendall.c
+++ b/src/core/ms_sendall.c
@@ -23,8 +23,7 @@ class CommandMSSendAll : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- int i, z = 1;
- NickCore *nc;
+ int z = 1;
const char *text = params[0].c_str();
if (readonly)
@@ -33,14 +32,15 @@ class CommandMSSendAll : public Command
return MOD_CONT;
}
- for (i = 0; i < 1024; ++i)
+ NickAlias *na = findnick(u->nick);
+
+ for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
{
- for (nc = nclists[i]; nc; nc = nc->next)
- {
- if (stricmp(u->nick.c_str(), nc->display))
- memo_send(u, nc->display, text, z);
- } /* /nc */
- } /* /i */
+ NickCore *nc = it->second;
+
+ if ((na && na->nc == nc) || stricmp(u->nick.c_str(), nc->display))
+ memo_send(u, nc->display, text, z);
+ }
notice_lang(Config.s_MemoServ, u, MEMO_MASS_SENT);
return MOD_CONT;
@@ -66,7 +66,7 @@ class MSSendAll : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSSendAll());
+ this->AddCommand(MemoServ, new CommandMSSendAll());
ModuleManager::Attach(I_OnMemoServHelp, this);
}
diff --git a/src/core/ms_set.c b/src/core/ms_set.c
index 150224f1e..bac493ade 100644
--- a/src/core/ms_set.c
+++ b/src/core/ms_set.c
@@ -262,7 +262,7 @@ class MSSet : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSSet());
+ this->AddCommand(MemoServ, new CommandMSSet());
ModuleManager::Attach(I_OnMemoServHelp, this);
}
diff --git a/src/core/ms_staff.c b/src/core/ms_staff.c
index 939322269..d3ff161c9 100644
--- a/src/core/ms_staff.c
+++ b/src/core/ms_staff.c
@@ -23,8 +23,7 @@ class CommandMSStaff : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- NickCore *nc;
- int i, z = 0;
+ int z = 0;
const char *text = params[0].c_str();
if (readonly)
@@ -33,14 +32,14 @@ class CommandMSStaff : public Command
return MOD_CONT;
}
- for (i = 0; i < 1024; ++i)
+ for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
{
- for (nc = nclists[i]; nc; nc = nc->next)
- {
- if (nc->IsServicesOper())
- memo_send(u, nc->display, text, z);
- }
+ NickCore *nc = it->second;
+
+ if (nc->IsServicesOper())
+ memo_send(u, nc->display, text, z);
}
+
return MOD_CONT;
}
@@ -64,7 +63,7 @@ class MSStaff : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(MEMOSERV, new CommandMSStaff());
+ this->AddCommand(MemoServ, new CommandMSStaff());
ModuleManager::Attach(I_OnMemoServHelp, this);
}
diff --git a/src/core/ns_access.c b/src/core/ns_access.c
index bebf1491f..e64bc1b16 100644
--- a/src/core/ns_access.c
+++ b/src/core/ns_access.c
@@ -171,7 +171,7 @@ class NSAccess : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSAccess());
+ this->AddCommand(NickServ, new CommandNSAccess());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_alist.c b/src/core/ns_alist.c
index 57b09ab10..0fd7b47af 100644
--- a/src/core/ns_alist.c
+++ b/src/core/ns_alist.c
@@ -88,37 +88,35 @@ class CommandNSAList : public Command
notice_lang(Config.s_NickServ, u, CHAN_ACCESS_LEVEL_RANGE, ACCESS_INVALID + 1, ACCESS_FOUNDER - 1);
else
{
- int i, level;
+ int level;
int chan_count = 0;
int match_count = 0;
- ChannelInfo *ci;
notice_lang(Config.s_NickServ, u, is_servadmin ? NICK_ALIST_HEADER_X : NICK_ALIST_HEADER, na->nick);
- for (i = 0; i < 256; ++i)
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
{
- for (ci = chanlists[i]; ci; ci = ci->next)
+ ChannelInfo *ci = it->second;
+
+ if ((level = get_access_level(ci, na)))
{
- if ((level = get_access_level(ci, na)))
- {
- ++chan_count;
+ ++chan_count;
- if (min_level > level)
- continue;
+ if (min_level > level)
+ continue;
- ++match_count;
+ ++match_count;
- if ((ci->HasFlag(CI_XOP)) || level == ACCESS_FOUNDER)
- {
- const char *xop;
+ if ((ci->HasFlag(CI_XOP)) || level == ACCESS_FOUNDER)
+ {
+ const char *xop;
- xop = get_xop_level(level);
+ xop = get_xop_level(level);
- notice_lang(Config.s_NickServ, u, NICK_ALIST_XOP_FORMAT, match_count, ci->HasFlag(CI_NO_EXPIRE) ? '!' : ' ', ci->name.c_str(), xop, ci->desc ? ci->desc : "");
- }
- else
- notice_lang(Config.s_NickServ, u, NICK_ALIST_ACCESS_FORMAT, match_count, ci->HasFlag(CI_NO_EXPIRE) ? '!' : ' ', ci->name.c_str(), level, ci->desc ? ci->desc : "");
+ notice_lang(Config.s_NickServ, u, NICK_ALIST_XOP_FORMAT, match_count, ci->HasFlag(CI_NO_EXPIRE) ? '!' : ' ', ci->name.c_str(), xop, ci->desc ? ci->desc : "");
}
+ else
+ notice_lang(Config.s_NickServ, u, NICK_ALIST_ACCESS_FORMAT, match_count, ci->HasFlag(CI_NO_EXPIRE) ? '!' : ' ', ci->name.c_str(), level, ci->desc ? ci->desc : "");
}
}
@@ -147,7 +145,7 @@ class NSAList : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSAList());
+ this->AddCommand(NickServ, new CommandNSAList());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_drop.c b/src/core/ns_drop.c
index ce87626c1..72f99cf7a 100644
--- a/src/core/ns_drop.c
+++ b/src/core/ns_drop.c
@@ -42,7 +42,7 @@ class CommandNSDrop : public Command
if ((nr = findrequestnick(nick)) && u->Account()->IsServicesOper())
{
if (Config.WallDrop)
- ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used DROP on \2%s\2", u->nick.c_str(), nick);
+ ircdproto->SendGlobops(NickServ, "\2%s\2 used DROP on \2%s\2", u->nick.c_str(), nick);
Alog() << Config.s_NickServ << ": " << u->GetMask() << " dropped nickname " << nr->nick << " (e-mail: " << nr->email << ")";
delete nr;
notice_lang(Config.s_NickServ, u, NICK_X_DROPPED, nick);
@@ -79,7 +79,7 @@ class CommandNSDrop : public Command
if (!is_mine)
{
if (Config.WallDrop)
- ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used DROP on \2%s\2", u->nick.c_str(), nick);
+ ircdproto->SendGlobops(NickServ, "\2%s\2 used DROP on \2%s\2", u->nick.c_str(), nick);
notice_lang(Config.s_NickServ, u, NICK_X_DROPPED, nick);
}
else
@@ -115,7 +115,7 @@ class NSDrop : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSDrop());
+ this->AddCommand(NickServ, new CommandNSDrop());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_forbid.c b/src/core/ns_forbid.c
index 14101a335..e4c179243 100644
--- a/src/core/ns_forbid.c
+++ b/src/core/ns_forbid.c
@@ -72,7 +72,7 @@ class CommandNSForbid : public Command
ircdproto->SendSQLine(na->nick, reason ? reason : "Forbidden");
if (Config.WallForbid)
- ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used FORBID on \2%s\2", u->nick.c_str(), nick);
+ ircdproto->SendGlobops(NickServ, "\2%s\2 used FORBID on \2%s\2", u->nick.c_str(), nick);
Alog() << Config.s_NickServ << ": " << u->nick << " set FORBID for nick " << nick;
notice_lang(Config.s_NickServ, u, NICK_FORBID_SUCCEEDED, nick);
@@ -108,7 +108,7 @@ class NSForbid : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSForbid());
+ this->AddCommand(NickServ, new CommandNSForbid());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_getemail.c b/src/core/ns_getemail.c
index 9c72ea023..2c15a0042 100644
--- a/src/core/ns_getemail.c
+++ b/src/core/ns_getemail.c
@@ -29,29 +29,30 @@ class CommandNSGetEMail : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
ci::string email = params[0];
- int i, j = 0;
- NickCore *nc;
+ int j = 0;
Alog() << Config.s_NickServ << ": " << u->GetMask() << " used GETEMAIL on " << email;
- for (i = 0; i < 1024; ++i)
+
+ for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
{
- for (nc = nclists[i]; nc; nc = nc->next)
+ NickCore *nc = it->second;
+
+ if (nc->email)
{
- if (nc->email)
+ if (nc->email == email)
{
- if (nc->email == email)
- {
- ++j;
- notice_lang(Config.s_NickServ, u, NICK_GETEMAIL_EMAILS_ARE, nc->display, email.c_str());
- }
+ ++j;
+ notice_lang(Config.s_NickServ, u, NICK_GETEMAIL_EMAILS_ARE, nc->display, email.c_str());
}
}
}
+
if (j <= 0)
{
notice_lang(Config.s_NickServ, u, NICK_GETEMAIL_NOT_USED, email.c_str());
return MOD_CONT;
}
+
return MOD_CONT;
}
@@ -76,7 +77,7 @@ class NSGetEMail : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSGetEMail());
+ this->AddCommand(NickServ, new CommandNSGetEMail());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_getpass.c b/src/core/ns_getpass.c
index 01ce31c90..f1acaf6ca 100644
--- a/src/core/ns_getpass.c
+++ b/src/core/ns_getpass.c
@@ -34,7 +34,7 @@ class CommandNSGetPass : public Command
{
Alog() << Config.s_NickServ << ": " << u->GetMask() << " used GETPASS on " << nick;
if (Config.WallGetpass)
- ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used GETPASS on \2%s\2", u->nick.c_str(), nick);
+ ircdproto->SendGlobops(NickServ, "\2%s\2 used GETPASS on \2%s\2", u->nick.c_str(), nick);
notice_lang(Config.s_NickServ, u, NICK_GETPASS_PASSCODE_IS, nick, nr->passcode.c_str());
}
else
@@ -50,7 +50,7 @@ class CommandNSGetPass : public Command
{
Alog() << Config.s_NickServ << ": " << u->GetMask() << " used GETPASS on " << nick;
if (Config.WallGetpass)
- ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used GETPASS on \2%s\2", u->nick.c_str(), nick);
+ ircdproto->SendGlobops(NickServ, "\2%s\2 used GETPASS on \2%s\2", u->nick.c_str(), nick);
notice_lang(Config.s_NickServ, u, NICK_GETPASS_PASSWORD_IS, nick, tmp_pass.c_str());
}
else
@@ -80,7 +80,7 @@ class NSGetPass : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSGetPass());
+ this->AddCommand(NickServ, new CommandNSGetPass());
std::string tmp_pass = "plain:tmp";
if (enc_decrypt(tmp_pass, tmp_pass) == -1)
diff --git a/src/core/ns_ghost.c b/src/core/ns_ghost.c
index 41c0a68a4..674fb3d08 100644
--- a/src/core/ns_ghost.c
+++ b/src/core/ns_ghost.c
@@ -93,7 +93,7 @@ class NSGhost : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSGhost());
+ this->AddCommand(NickServ, new CommandNSGhost());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_group.c b/src/core/ns_group.c
index e74b69e2e..10478f8a1 100644
--- a/src/core/ns_group.c
+++ b/src/core/ns_group.c
@@ -198,7 +198,7 @@ class CommandNSUngroup : public Command
if (user)
{
/* The user on the nick who was ungrouped may be identified to the old group, set -r */
- user->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ user->RemoveMode(NickServ, UMODE_REGISTERED);
}
}
@@ -276,9 +276,9 @@ class NSGroup : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSGroup());
- this->AddCommand(NICKSERV, new CommandNSUngroup());
- this->AddCommand(NICKSERV, new CommandNSGList());
+ this->AddCommand(NickServ, new CommandNSGroup());
+ this->AddCommand(NickServ, new CommandNSUngroup());
+ this->AddCommand(NickServ, new CommandNSGList());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_help.c b/src/core/ns_help.c
index a2485c6dc..233c7252f 100644
--- a/src/core/ns_help.c
+++ b/src/core/ns_help.c
@@ -34,7 +34,7 @@ class CommandNSHelp : public Command
u->SendMessage(Config.s_NickServ, " %2d) %s", i + 1, langnames[langlist[i]]);
}
else
- mod_help_cmd(Config.s_NickServ, u, NICKSERV, cmd.c_str());
+ mod_help_cmd(NickServ, u, cmd.c_str());
return MOD_CONT;
}
@@ -60,7 +60,7 @@ class NSHelp : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSHelp());
+ this->AddCommand(NickServ, new CommandNSHelp());
}
};
diff --git a/src/core/ns_identify.c b/src/core/ns_identify.c
index b574c1207..bf8a4548f 100644
--- a/src/core/ns_identify.c
+++ b/src/core/ns_identify.c
@@ -115,8 +115,8 @@ class NSIdentify : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSIdentify("IDENTIFY"));
- this->AddCommand(NICKSERV, new CommandNSIdentify("ID"));
+ this->AddCommand(NickServ, new CommandNSIdentify("IDENTIFY"));
+ this->AddCommand(NickServ, new CommandNSIdentify("ID"));
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_info.c b/src/core/ns_info.c
index 976e3d458..a73766c06 100644
--- a/src/core/ns_info.c
+++ b/src/core/ns_info.c
@@ -210,7 +210,7 @@ class NSInfo : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSInfo());
+ this->AddCommand(NickServ, new CommandNSInfo());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_list.c b/src/core/ns_list.c
index 195763037..bc27e9619 100644
--- a/src/core/ns_list.c
+++ b/src/core/ns_list.c
@@ -38,12 +38,10 @@ class CommandNSList : public Command
* UPDATE: SUSPENDED keyword is now accepted as well.
*/
const char *pattern = params[0].c_str();
- NickAlias *na;
NickCore *mync;
- unsigned nnicks, i;
+ unsigned nnicks;
char buf[BUFSIZE];
bool is_servadmin = u->Account()->IsServicesOper();
- NickRequest *nr = NULL;
char noexpire_char = ' ';
int count = 0, from = 0, to = 0, tofree = 0;
char *tmp = NULL;
@@ -123,46 +121,45 @@ class CommandNSList : public Command
notice_lang(Config.s_NickServ, u, NICK_LIST_HEADER, pattern);
if (!unconfirmed)
{
- for (i = 0; i < 1024; ++i)
+ for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
{
- for (na = nalists[i]; na; na = na->next)
+ NickAlias *na = it->second;
+
+ /* Don't show private and forbidden nicks to non-services admins. */
+ if ((na->HasFlag(NS_FORBIDDEN)) && !is_servadmin)
+ continue;
+ if ((na->nc->HasFlag(NI_PRIVATE)) && !is_servadmin && na->nc != mync)
+ continue;
+ if (forbidden && !na->HasFlag(NS_FORBIDDEN))
+ continue;
+ else if (nsnoexpire && !na->HasFlag(NS_NO_EXPIRE))
+ continue;
+ else if (suspended && !na->nc->HasFlag(NI_SUSPENDED))
+ continue;
+
+ /* We no longer compare the pattern against the output buffer.
+ * Instead we build a nice nick!user@host buffer to compare.
+ * The output is then generated separately. -TheShadow */
+ snprintf(buf, sizeof(buf), "%s!%s", na->nick, na->last_usermask && !(na->HasFlag(NS_FORBIDDEN)) ? na->last_usermask : "*@*");
+ if (!stricmp(pattern, na->nick) || Anope::Match(buf, pattern, false))
{
- /* Don't show private and forbidden nicks to non-services admins. */
- if ((na->HasFlag(NS_FORBIDDEN)) && !is_servadmin)
- continue;
- if ((na->nc->HasFlag(NI_PRIVATE)) && !is_servadmin && na->nc != mync)
- continue;
- if (forbidden && !na->HasFlag(NS_FORBIDDEN))
- continue;
- else if (nsnoexpire && !na->HasFlag(NS_NO_EXPIRE))
- continue;
- else if (suspended && !na->nc->HasFlag(NI_SUSPENDED))
- continue;
-
- /* We no longer compare the pattern against the output buffer.
- * Instead we build a nice nick!user@host buffer to compare.
- * The output is then generated separately. -TheShadow */
- snprintf(buf, sizeof(buf), "%s!%s", na->nick, na->last_usermask && !(na->HasFlag(NS_FORBIDDEN)) ? na->last_usermask : "*@*");
- if (!stricmp(pattern, na->nick) || Anope::Match(buf, pattern, false))
+ if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nnicks <= Config.NSListMax)
{
- if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nnicks <= Config.NSListMax)
- {
- if (is_servadmin && (na->HasFlag(NS_NO_EXPIRE)))
- noexpire_char = '!';
- else
- noexpire_char = ' ';
- if ((na->nc->HasFlag(NI_HIDE_MASK)) && !is_servadmin && na->nc != mync)
- snprintf(buf, sizeof(buf), "%-20s [Hostname Hidden]", na->nick);
- else if (na->HasFlag(NS_FORBIDDEN))
- snprintf(buf, sizeof(buf), "%-20s [Forbidden]", na->nick);
- else if (na->nc->HasFlag(NI_SUSPENDED))
- snprintf(buf, sizeof(buf), "%-20s [Suspended]", na->nick);
- else
- snprintf(buf, sizeof(buf), "%-20s %s", na->nick, na->last_usermask);
- u->SendMessage(Config.s_NickServ, " %c%s", noexpire_char, buf);
- }
- ++count;
+ if (is_servadmin && (na->HasFlag(NS_NO_EXPIRE)))
+ noexpire_char = '!';
+ else
+ noexpire_char = ' ';
+ if ((na->nc->HasFlag(NI_HIDE_MASK)) && !is_servadmin && na->nc != mync)
+ snprintf(buf, sizeof(buf), "%-20s [Hostname Hidden]", na->nick);
+ else if (na->HasFlag(NS_FORBIDDEN))
+ snprintf(buf, sizeof(buf), "%-20s [Forbidden]", na->nick);
+ else if (na->nc->HasFlag(NI_SUSPENDED))
+ snprintf(buf, sizeof(buf), "%-20s [Suspended]", na->nick);
+ else
+ snprintf(buf, sizeof(buf), "%-20s %s", na->nick, na->last_usermask);
+ u->SendMessage(Config.s_NickServ, " %c%s", noexpire_char, buf);
}
+ ++count;
}
}
}
@@ -170,18 +167,18 @@ class CommandNSList : public Command
if (unconfirmed || is_servadmin)
{
noexpire_char = ' ';
- for (i = 0; i < 1024; ++i)
+
+ for (nickrequest_map::const_iterator it = NickRequestList.begin(); it != NickRequestList.end(); ++it)
{
- for (nr = nrlists[i]; nr; nr = nr->next)
+ NickRequest *nr = it->second;
+
+ snprintf(buf, sizeof(buf), "%s!*@*", nr->nick);
+ if (!stricmp(pattern, nr->nick) || Anope::Match(buf, pattern, false))
{
- snprintf(buf, sizeof(buf), "%s!*@*", nr->nick);
- if (!stricmp(pattern, nr->nick) || Anope::Match(buf, pattern, false))
+ if (++nnicks <= Config.NSListMax)
{
- if (++nnicks <= Config.NSListMax)
- {
- snprintf(buf, sizeof(buf), "%-20s [UNCONFIRMED]", nr->nick);
- u->SendMessage(Config.s_NickServ, " %c%s", noexpire_char, buf);
- }
+ snprintf(buf, sizeof(buf), "%-20s [UNCONFIRMED]", nr->nick);
+ u->SendMessage(Config.s_NickServ, " %c%s", noexpire_char, buf);
}
}
}
@@ -220,7 +217,7 @@ class NSList : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSList());
+ this->AddCommand(NickServ, new CommandNSList());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_logout.c b/src/core/ns_logout.c
index 373dbabbd..463916082 100644
--- a/src/core/ns_logout.c
+++ b/src/core/ns_logout.c
@@ -88,7 +88,7 @@ class NSLogout : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSLogout());
+ this->AddCommand(NickServ, new CommandNSLogout());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_recover.c b/src/core/ns_recover.c
index 7484da87c..b44998d86 100644
--- a/src/core/ns_recover.c
+++ b/src/core/ns_recover.c
@@ -114,7 +114,7 @@ class NSRecover : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSRecover());
+ this->AddCommand(NickServ, new CommandNSRecover());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_register.c b/src/core/ns_register.c
index 89495eb57..beb2e26ac 100644
--- a/src/core/ns_register.c
+++ b/src/core/ns_register.c
@@ -369,9 +369,9 @@ class NSRegister : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSRegister());
- this->AddCommand(NICKSERV, new CommandNSConfirm("CONFIRM", 1, 1));
- this->AddCommand(NICKSERV, new CommandNSResend());
+ this->AddCommand(NickServ, new CommandNSRegister());
+ this->AddCommand(NickServ, new CommandNSConfirm("CONFIRM", 1, 1));
+ this->AddCommand(NickServ, new CommandNSResend());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_release.c b/src/core/ns_release.c
index 0855bc46d..7201f3493 100644
--- a/src/core/ns_release.c
+++ b/src/core/ns_release.c
@@ -96,7 +96,7 @@ class NSRelease : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSRelease());
+ this->AddCommand(NickServ, new CommandNSRelease());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_resetpass.c b/src/core/ns_resetpass.c
index fc904d66c..42e38b108 100644
--- a/src/core/ns_resetpass.c
+++ b/src/core/ns_resetpass.c
@@ -69,7 +69,7 @@ class NSResetPass : public Module
if (!Config.UseMail)
throw ModuleException("Not using mail.");
- this->AddCommand(NICKSERV, new CommandNSResetPass());
+ this->AddCommand(NickServ, new CommandNSResetPass());
Implementation i[] = { I_OnNickServHelp, I_OnPreCommand };
ModuleManager::Attach(i, this, 2);
diff --git a/src/core/ns_saset.c b/src/core/ns_saset.c
index 6978ba356..3bedbd301 100644
--- a/src/core/ns_saset.c
+++ b/src/core/ns_saset.c
@@ -94,7 +94,7 @@ private:
Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SASET PASSWORD on " << nc->display << " (e-mail: "<< (nc->email ? nc->email : "none") << ")";
if (Config.WallSetpass)
- ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used SASET PASSWORD on \2%s\2", u->nick.c_str(), nc->display);
+ ircdproto->SendGlobops(NickServ, "\2%s\2 used SASET PASSWORD on \2%s\2", u->nick.c_str(), nc->display);
return MOD_CONT;
}
@@ -586,7 +586,7 @@ public:
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSSASet());
+ this->AddCommand(NickServ, new CommandNSSASet());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_sendpass.c b/src/core/ns_sendpass.c
index ffa4b6ece..70ec1ab9d 100644
--- a/src/core/ns_sendpass.c
+++ b/src/core/ns_sendpass.c
@@ -73,7 +73,7 @@ class NSSendPass : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSSendPass());
+ this->AddCommand(NickServ, new CommandNSSendPass());
if (!Config.UseMail)
throw ModuleException("Not using mail, whut.");
diff --git a/src/core/ns_set.c b/src/core/ns_set.c
index 1cd797881..79561af76 100644
--- a/src/core/ns_set.c
+++ b/src/core/ns_set.c
@@ -544,7 +544,7 @@ class NSSet : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSSet());
+ this->AddCommand(NickServ, new CommandNSSet());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_status.c b/src/core/ns_status.c
index 978b1f69f..f6bc6ca34 100644
--- a/src/core/ns_status.c
+++ b/src/core/ns_status.c
@@ -67,7 +67,7 @@ class NSStatus : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSStatus());
+ this->AddCommand(NickServ, new CommandNSStatus());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_suspend.c b/src/core/ns_suspend.c
index 8a909f151..1f0b885a4 100644
--- a/src/core/ns_suspend.c
+++ b/src/core/ns_suspend.c
@@ -79,7 +79,7 @@ class CommandNSSuspend : public Command
}
if (Config.WallForbid)
- ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used SUSPEND on \2%s\2", u->nick.c_str(), nick);
+ ircdproto->SendGlobops(NickServ, "\2%s\2 used SUSPEND on \2%s\2", u->nick.c_str(), nick);
Alog() << Config.s_NickServ << ": " << u->nick << " set SUSPEND for nick " << nick;
notice_lang(Config.s_NickServ, u, NICK_SUSPEND_SUCCEEDED, nick);
@@ -147,7 +147,7 @@ class CommandNSUnSuspend : public Command
na->nc->UnsetFlag(NI_SUSPENDED);
if (Config.WallForbid)
- ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used UNSUSPEND on \2%s\2", u->nick.c_str(), nick);
+ ircdproto->SendGlobops(NickServ, "\2%s\2 used UNSUSPEND on \2%s\2", u->nick.c_str(), nick);
Alog() << Config.s_NickServ << ": " << u->nick << " set UNSUSPEND for nick " << nick;
notice_lang(Config.s_NickServ, u, NICK_UNSUSPEND_SUCCEEDED, nick);
@@ -183,8 +183,8 @@ class NSSuspend : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSSuspend());
- this->AddCommand(NICKSERV, new CommandNSUnSuspend());
+ this->AddCommand(NickServ, new CommandNSSuspend());
+ this->AddCommand(NickServ, new CommandNSUnSuspend());
ModuleManager::Attach(I_OnNickServHelp, this);
}
diff --git a/src/core/ns_update.c b/src/core/ns_update.c
index 739f1dc7e..755df4dc0 100644
--- a/src/core/ns_update.c
+++ b/src/core/ns_update.c
@@ -56,7 +56,7 @@ class NSUpdate : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NICKSERV, new CommandNSUpdate());
+ this->AddCommand(NickServ, new CommandNSUpdate());
ModuleManager::Attach(I_OnNickServHelp, this);
}
void OnNickServHelp(User *u)
diff --git a/src/core/os_akill.c b/src/core/os_akill.c
index a83b0aa98..590767bbe 100644
--- a/src/core/os_akill.c
+++ b/src/core/os_akill.c
@@ -131,7 +131,7 @@ class CommandOSAKill : public Command
snprintf(buf, sizeof(buf), "expires in %d %s%s", wall_expiry, s, wall_expiry == 1 ? "" : "s");
}
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s added an AKILL for %s (%s) (%s)", u->nick.c_str(), mask, realreason.c_str(), buf);
+ ircdproto->SendGlobops(OperServ, "%s added an AKILL for %s (%s) (%s)", u->nick.c_str(), mask, realreason.c_str(), buf);
}
if (readonly)
@@ -334,7 +334,7 @@ class OSAKill : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSAKill());
+ this->AddCommand(OperServ, new CommandOSAKill());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_chankill.c b/src/core/os_chankill.c
index e945728f7..6d06f75c5 100644
--- a/src/core/os_chankill.c
+++ b/src/core/os_chankill.c
@@ -83,7 +83,7 @@ class CommandOSChanKill : public Command
check_akill(uc->user->nick.c_str(), uc->user->GetIdent().c_str(), uc->user->host, NULL, NULL);
}
if (Config.WallOSAkill)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s used CHANKILL on %s (%s)", u->nick.c_str(), channel, realreason.c_str());
+ ircdproto->SendGlobops(OperServ, "%s used CHANKILL on %s (%s)", u->nick.c_str(), channel, realreason.c_str());
}
else
notice_lang(Config.s_OperServ, u, CHAN_X_NOT_IN_USE, channel);
@@ -113,7 +113,7 @@ class OSChanKill : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSChanKill());
+ this->AddCommand(OperServ, new CommandOSChanKill());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_chanlist.c b/src/core/os_chanlist.c
index 48846255a..5d1ab1873 100644
--- a/src/core/os_chanlist.c
+++ b/src/core/os_chanlist.c
@@ -38,9 +38,9 @@ class CommandOSChanList : public Command
{
notice_lang(Config.s_OperServ, u, OPER_CHANLIST_HEADER_USER, u2->nick.c_str());
- for (UChannelList::iterator it = u2->chans.begin(); it != u2->chans.end(); ++it)
+ for (UChannelList::iterator uit = u2->chans.begin(); uit != u2->chans.end(); ++uit)
{
- ChannelContainer *cc = *it;
+ ChannelContainer *cc = *uit;
if (!Modes.empty())
{
@@ -56,27 +56,24 @@ class CommandOSChanList : public Command
}
else
{
- int i;
- Channel *c;
-
notice_lang(Config.s_OperServ, u, OPER_CHANLIST_HEADER);
- for (i = 0; i < 1024; ++i)
+ for (channel_map::const_iterator cit = ChannelList.begin(); cit != ChannelList.end(); ++cit)
{
- for (c = chanlist[i]; c; c = c->next)
+ Channel *c = cit->second;
+
+ if (pattern && !Anope::Match(c->name, pattern, false))
+ continue;
+ if (!Modes.empty())
{
- if (pattern && !Anope::Match(c->name, pattern, false))
- continue;
- if (!Modes.empty())
+ for (std::list<ChannelModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
{
- for (std::list<ChannelModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
- {
- if (!c->HasMode(*it))
- continue;
- }
+ if (!c->HasMode(*it))
+ continue;
}
- notice_lang(Config.s_OperServ, u, OPER_CHANLIST_RECORD, c->name.c_str(), c->users.size(), chan_get_modes(c, 1, 1), c->topic ? c->topic : "");
}
+
+ notice_lang(Config.s_OperServ, u, OPER_CHANLIST_RECORD, c->name.c_str(), c->users.size(), chan_get_modes(c, 1, 1), c->topic ? c->topic : "");
}
}
@@ -100,7 +97,7 @@ class OSChanList : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSChanList());
+ this->AddCommand(OperServ, new CommandOSChanList());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_clearmodes.c b/src/core/os_clearmodes.c
index 8d50b92e5..89b10a4a1 100644
--- a/src/core/os_clearmodes.c
+++ b/src/core/os_clearmodes.c
@@ -52,7 +52,7 @@ class CommandOSClearModes : public Command
}
if (Config.WallOSClearmodes)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s used CLEARMODES%s on %s", u->nick.c_str(), all ? " ALL" : "", chan);
+ ircdproto->SendGlobops(OperServ, "%s used CLEARMODES%s on %s", u->nick.c_str(), all ? " ALL" : "", chan);
if (all)
{
/* Clear mode +o */
@@ -177,7 +177,7 @@ class OSClearModes : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSClearModes());
+ this->AddCommand(OperServ, new CommandOSClearModes());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_defcon.c b/src/core/os_defcon.c
index 654ed89cc..edb2a51aa 100644
--- a/src/core/os_defcon.c
+++ b/src/core/os_defcon.c
@@ -36,7 +36,7 @@ class DefConTimeout : public Timer
Config.DefConLevel = level;
FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(level));
Alog() << "Defcon level timeout, returning to lvl " << level;
- ircdproto->SendGlobops(findbot(Config.s_OperServ), getstring(OPER_DEFCON_WALL), Config.s_OperServ, level);
+ ircdproto->SendGlobops(OperServ, getstring(OPER_DEFCON_WALL), Config.s_OperServ, level);
if (Config.GlobalOnDefcon)
{
@@ -95,7 +95,7 @@ class CommandOSDEFCON : public Command
notice_lang(Config.s_OperServ, u, OPER_DEFCON_CHANGED, Config.DefConLevel);
defcon_sendlvls(u);
Alog() << "Defcon level changed to " << newLevel << " by Oper " << u->nick;
- ircdproto->SendGlobops(findbot(Config.s_OperServ), getstring(OPER_DEFCON_WALL), u->nick.c_str(), newLevel);
+ ircdproto->SendGlobops(OperServ, getstring(OPER_DEFCON_WALL), u->nick.c_str(), newLevel);
/* Global notice the user what is happening. Also any Message that
the Admin would like to add. Set in config file. */
if (Config.GlobalOnDefcon)
@@ -144,7 +144,7 @@ class OSDEFCON : public Module
Implementation i[] = { I_OnOperServHelp, I_OnPreUserConnect, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnPreCommandRun, I_OnPreCommand, I_OnUserConnect, I_OnChannelModeAdd, I_OnChannelCreate };
ModuleManager::Attach(i, this, 9);
- this->AddCommand(OPERSERV, new CommandOSDEFCON());
+ this->AddCommand(OperServ, new CommandOSDEFCON());
defconParseModeString(Config.DefConChanModes);
}
@@ -183,7 +183,7 @@ class OSDEFCON : public Module
if (CheckDefCon(DEFCON_FORCE_CHAN_MODES) && cm && DefConModesOff.HasFlag(Name))
{
- c->RemoveMode(findbot(Config.s_OperServ), Name, param);
+ c->RemoveMode(OperServ, Name, param);
return EVENT_STOP;
}
@@ -201,10 +201,10 @@ class OSDEFCON : public Module
if (GetDefConParam(Name, &param))
{
- c->SetMode(findbot(Config.s_OperServ), Name, param);
+ c->SetMode(OperServ, Name, param);
}
else
- c->SetMode(findbot(Config.s_OperServ), Name);
+ c->SetMode(OperServ, Name);
return EVENT_STOP;
@@ -293,9 +293,9 @@ class OSDEFCON : public Module
if (session && session->count > Config.DefConSessionLimit)
{
if (Config.SessionLimitExceeded)
- ircdproto->SendMessage(findbot(Config.s_OperServ), u->nick.c_str(), Config.SessionLimitExceeded, u->host);
+ ircdproto->SendMessage(OperServ, u->nick.c_str(), Config.SessionLimitExceeded, u->host);
if (Config.SessionLimitDetailsLoc)
- ircdproto->SendMessage(findbot(Config.s_OperServ), u->nick.c_str(), "%s", Config.SessionLimitDetailsLoc);
+ ircdproto->SendMessage(OperServ, u->nick.c_str(), "%s", Config.SessionLimitDetailsLoc);
kill_user(Config.s_OperServ, u->nick, "Session limit exceeded");
session->hits++;
@@ -304,7 +304,7 @@ class OSDEFCON : public Module
char akillmask[BUFSIZE];
snprintf(akillmask, sizeof(akillmask), "*@%s", u->host);
add_akill(NULL, akillmask, Config.s_OperServ, time(NULL) + Config.SessionAutoKillExpiry, "Session limit exceeded");
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "Added a temporary AKILL for \2%s\2 due to excessive connections", akillmask);
+ ircdproto->SendGlobops(OperServ, "Added a temporary AKILL for \2%s\2 due to excessive connections", akillmask);
}
}
}
@@ -330,7 +330,7 @@ class OSDEFCON : public Module
{
if (CheckDefCon(DEFCON_FORCE_CHAN_MODES))
{
- c->SetModes(findbot(Config.s_OperServ), false, Config.DefConChanModes);
+ c->SetModes(OperServ, false, Config.DefConChanModes);
}
}
};
@@ -374,7 +374,7 @@ void runDefCon()
{
Alog() << "DEFCON: setting " << Config.DefConChanModes << " on all channels";
DefConModesSet = 1;
- MassChannelModes(findbot(Config.s_OperServ), Config.DefConChanModes);
+ MassChannelModes(OperServ, Config.DefConChanModes);
}
}
}
@@ -388,7 +388,7 @@ void runDefCon()
if ((newmodes = defconReverseModes(Config.DefConChanModes)))
{
Alog() << "DEFCON: setting " << newmodes << " on all channels";
- MassChannelModes(findbot(Config.s_OperServ), newmodes);
+ MassChannelModes(OperServ, newmodes);
delete [] newmodes;
}
}
diff --git a/src/core/os_global.c b/src/core/os_global.c
index 4c2c81e22..791bdcbc0 100644
--- a/src/core/os_global.c
+++ b/src/core/os_global.c
@@ -26,7 +26,7 @@ class CommandOSGlobal : public Command
const char *msg = params[0].c_str();
if (Config.WallOSGlobal)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "\2%s\2 just used GLOBAL command.", u->nick.c_str());
+ ircdproto->SendGlobops(OperServ, "\2%s\2 just used GLOBAL command.", u->nick.c_str());
oper_global(const_cast<char *>(u->nick.c_str()), "%s", msg);
return MOD_CONT;
}
@@ -52,7 +52,7 @@ class OSGlobal : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSGlobal());
+ this->AddCommand(OperServ, new CommandOSGlobal());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_help.c b/src/core/os_help.c
index baeb5a45f..8e9893407 100644
--- a/src/core/os_help.c
+++ b/src/core/os_help.c
@@ -23,7 +23,7 @@ class CommandOSHelp : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- mod_help_cmd(Config.s_OperServ, u, OPERSERV, params[0].c_str());
+ mod_help_cmd(OperServ, u, params[0].c_str());
return MOD_CONT;
}
@@ -43,7 +43,7 @@ class OSHelp : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSHelp());
+ this->AddCommand(OperServ, new CommandOSHelp());
}
};
diff --git a/src/core/os_ignore.c b/src/core/os_ignore.c
index 335fa8d63..f71a1cd2c 100644
--- a/src/core/os_ignore.c
+++ b/src/core/os_ignore.c
@@ -137,7 +137,7 @@ class OSIgnore : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSIgnore());
+ this->AddCommand(OperServ, new CommandOSIgnore());
Implementation i[] = { I_OnOperServHelp, I_OnDatabaseRead, I_OnDatabaseWrite };
ModuleManager::Attach(i, this, 3);
diff --git a/src/core/os_jupe.c b/src/core/os_jupe.c
index 899dd4ea4..11d9fafee 100644
--- a/src/core/os_jupe.c
+++ b/src/core/os_jupe.c
@@ -42,7 +42,7 @@ class CommandOSJupe : public Command
ircdproto->SendServer(juped_server);
if (Config.WallOSJupe)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "\2%s\2 used JUPE on \2%s\2", u->nick.c_str(), jserver);
+ ircdproto->SendGlobops(OperServ, "\2%s\2 used JUPE on \2%s\2", u->nick.c_str(), jserver);
}
return MOD_CONT;
}
@@ -68,7 +68,7 @@ class OSJupe : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSJupe());
+ this->AddCommand(OperServ, new CommandOSJupe());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_kick.c b/src/core/os_kick.c
index 803a2c970..72a47b9c4 100644
--- a/src/core/os_kick.c
+++ b/src/core/os_kick.c
@@ -43,9 +43,9 @@ class CommandOSKick : public Command
return MOD_CONT;
}
- c->Kick(findbot(Config.s_OperServ), u2, "%s (%s)", u->nick.c_str(), s);
+ c->Kick(OperServ, u2, "%s (%s)", u->nick.c_str(), s);
if (Config.WallOSKick)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s used KICK on %s/%s", u->nick.c_str(), u2->nick.c_str(), chan);
+ ircdproto->SendGlobops(OperServ, "%s used KICK on %s/%s", u->nick.c_str(), u2->nick.c_str(), chan);
return MOD_CONT;
}
@@ -70,7 +70,7 @@ class OSKick : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSKick());
+ this->AddCommand(OperServ, new CommandOSKick());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_mode.c b/src/core/os_mode.c
index 0eddcd82b..c72ab9e26 100644
--- a/src/core/os_mode.c
+++ b/src/core/os_mode.c
@@ -32,10 +32,10 @@ class CommandOSMode : public Command
notice_lang(Config.s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
else
{
- c->SetModes(findbot(Config.s_OperServ), false, modes);
+ c->SetModes(OperServ, false, modes);
if (Config.WallOSMode)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s used MODE %s on %s", u->nick.c_str(), modes, chan);
+ ircdproto->SendGlobops(OperServ, "%s used MODE %s on %s", u->nick.c_str(), modes, chan);
}
return MOD_CONT;
}
@@ -61,7 +61,7 @@ class OSMode : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSMode());
+ this->AddCommand(OperServ, new CommandOSMode());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_modinfo.c b/src/core/os_modinfo.c
index 2a1d8a8f8..0a000bc00 100644
--- a/src/core/os_modinfo.c
+++ b/src/core/os_modinfo.c
@@ -14,7 +14,7 @@
#include "module.h"
-int showModuleCmdLoaded(CommandHash *cmdList, const char *mod_name, User *u);
+static int showModuleCmdLoaded(BotInfo *bi, const ci::string &mod_name, User *u);
class CommandOSModInfo : public Command
{
@@ -25,30 +25,27 @@ class CommandOSModInfo : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- const char *file = params[0].c_str();
+ const std::string file = params[0].c_str();
struct tm tm;
char timebuf[64];
- Module *m;
- int idx = 0;
- m = findModule(file);
+ Module *m = FindModule(file.c_str());
if (m)
{
tm = *localtime(&m->created);
strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT, &tm);
notice_lang(Config.s_OperServ, u, OPER_MODULE_INFO_LIST, m->name.c_str(), !m->version.empty() ? m->version.c_str() : "?", !m->author.empty() ? m->author.c_str() : "?", timebuf);
- for (idx = 0; idx < MAX_CMD_HASH; ++idx)
- {
- showModuleCmdLoaded(HOSTSERV[idx], m->name.c_str(), u);
- showModuleCmdLoaded(OPERSERV[idx], m->name.c_str(), u);
- showModuleCmdLoaded(NICKSERV[idx], m->name.c_str(), u);
- showModuleCmdLoaded(CHANSERV[idx], m->name.c_str(), u);
- showModuleCmdLoaded(BOTSERV[idx], m->name.c_str(), u);
- showModuleCmdLoaded(MEMOSERV[idx], m->name.c_str(), u);
- }
+
+ showModuleCmdLoaded(HostServ, m->name.c_str(), u);
+ showModuleCmdLoaded(OperServ, m->name.c_str(), u);
+ showModuleCmdLoaded(NickServ, m->name.c_str(), u);
+ showModuleCmdLoaded(ChanServ, m->name.c_str(), u);
+ showModuleCmdLoaded(BotServ, m->name.c_str(), u);
+ showModuleCmdLoaded(MemoServ, m->name.c_str(), u);
}
else
- notice_lang(Config.s_OperServ, u, OPER_MODULE_NO_INFO, file);
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_NO_INFO, file.c_str());
+
return MOD_CONT;
}
@@ -72,7 +69,7 @@ class OSModInfo : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSModInfo());
+ this->AddCommand(OperServ, new CommandOSModInfo());
ModuleManager::Attach(I_OnOperServHelp, this);
}
@@ -82,21 +79,21 @@ class OSModInfo : public Module
}
};
-int showModuleCmdLoaded(CommandHash *cmdList, const char *mod_name, User *u)
+static int showModuleCmdLoaded(BotInfo *bi, const ci::string &mod_name, User *u)
{
- Command *c;
- CommandHash *current;
+ if (!bi)
+ return 0;
+
int display = 0;
- for (current = cmdList; current; current = current->next)
+ for (std::map<ci::string, Command *>::iterator it = bi->Commands.begin(); it != bi->Commands.end(); ++it)
{
- for (c = current->c; c; c = c->next)
+ Command *c = it->second;
+
+ if (c->module && c->module->name == mod_name)
{
- if (c->mod_name && !stricmp(c->mod_name, mod_name))
- {
- notice_lang(Config.s_OperServ, u, OPER_MODULE_CMD_LIST, c->service, c->name.c_str());
- ++display;
- }
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_CMD_LIST, c->service, c->name.c_str());
+ ++display;
}
}
return display;
diff --git a/src/core/os_modlist.c b/src/core/os_modlist.c
index 3619a466b..b51be2067 100644
--- a/src/core/os_modlist.c
+++ b/src/core/os_modlist.c
@@ -23,7 +23,6 @@ class CommandOSModList : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- int idx;
int count = 0;
int showCore = 0;
int showThird = 1;
@@ -34,7 +33,6 @@ class CommandOSModList : public Command
int showDB = 1;
ci::string param = params.size() ? params[0] : "";
- ModuleHash *current = NULL;
char core[] = "Core";
char third[] = "3rd";
@@ -120,61 +118,60 @@ class CommandOSModList : public Command
notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST_HEADER);
- for (idx = 0; idx != MAX_CMD_HASH; ++idx)
+ for (std::deque<Module *>::iterator it = Modules.begin(); it != Modules.end(); ++it)
{
- for (current = MODULE_HASH[idx]; current; current = current->next)
+ Module *m = *it;
+
+ switch (m->type)
{
- switch (current->m->type)
- {
- case CORE:
- if (showCore)
- {
- notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, current->name, current->m->version.c_str(), core);
- ++count;
- }
- break;
- case THIRD:
- if (showThird)
- {
- notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, current->name, current->m->version.c_str(), third);
- ++count;
- }
- break;
- case PROTOCOL:
- if (showProto)
- {
- notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, current->name, current->m->version.c_str(), proto);
- ++count;
- }
- break;
- case SUPPORTED:
- if (showSupported)
- {
- notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, current->name, current->m->version.c_str(), supported);
- ++count;
- }
- break;
- case QATESTED:
- if (showQA)
- {
- notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, current->name, current->m->version.c_str(), qa);
- ++count;
- }
- break;
- case ENCRYPTION:
- if (showEnc)
- {
- notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, current->name, current->m->version.c_str(), enc);
- ++count;
- }
- break;
- case DATABASE:
- if (showDB)
- {
- notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, current->name, current->m->version.c_str(), db);
- ++count;
- }
- }
+ case CORE:
+ if (showCore)
+ {
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, m->name.c_str(), m->version.c_str(), core);
+ ++count;
+ }
+ break;
+ case THIRD:
+ if (showThird)
+ {
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, m->name.c_str(), m->version.c_str(), third);
+ ++count;
+ }
+ break;
+ case PROTOCOL:
+ if (showProto)
+ {
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, m->name.c_str(), m->version.c_str(), proto);
+ ++count;
+ }
+ break;
+ case SUPPORTED:
+ if (showSupported)
+ {
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, m->name.c_str(), m->version.c_str(), supported);
+ ++count;
+ }
+ break;
+ case QATESTED:
+ if (showQA)
+ {
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, m->name.c_str(), m->version.c_str(), qa);
+ ++count;
+ }
+ break;
+ case ENCRYPTION:
+ if (showEnc)
+ {
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, m->name.c_str(), m->version.c_str(), enc);
+ ++count;
+ }
+ break;
+ case DATABASE:
+ if (showDB)
+ {
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_LIST, m->name.c_str(), m->version.c_str(), db);
+ ++count;
+ }
}
}
if (!count)
@@ -201,7 +198,7 @@ class OSModList : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSModList());
+ this->AddCommand(OperServ, new CommandOSModList());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_modload.c b/src/core/os_modload.c
index 870c7b0a4..ddda212d5 100644
--- a/src/core/os_modload.c
+++ b/src/core/os_modload.c
@@ -23,19 +23,19 @@ class CommandOSModLoad : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- const char *name = params[0].c_str();
+ const std::string mname = params[0].c_str();
- Module *m = findModule(name);
+ Module *m = FindModule(mname);
if (m)
{
- notice_lang(Config.s_OperServ, u, OPER_MODULE_ALREADY_LOADED, name);
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_ALREADY_LOADED, mname.c_str());
return MOD_CONT;
}
- int status = ModuleManager::LoadModule(name, u);
+ int status = ModuleManager::LoadModule(mname, u);
if (status != MOD_ERR_OK)
{
- notice_lang(Config.s_OperServ, u, OPER_MODULE_LOAD_FAIL, name);
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_LOAD_FAIL, mname.c_str());
}
return MOD_CONT;
@@ -63,7 +63,7 @@ class OSModLoad : public Module
this->SetType(CORE);
this->SetPermanent(true);
- this->AddCommand(OPERSERV, new CommandOSModLoad());
+ this->AddCommand(OperServ, new CommandOSModLoad());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_modunload.c b/src/core/os_modunload.c
index 6f6de9e81..8c5fee850 100644
--- a/src/core/os_modunload.c
+++ b/src/core/os_modunload.c
@@ -23,22 +23,22 @@ class CommandOSModUnLoad : public Command
CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- const char *name = params[0].c_str();
+ const std::string mname = params[0].c_str();
int status;
- Module *m = findModule(name);
+ Module *m = FindModule(mname);
if (!m)
{
- notice_lang(Config.s_OperServ, u, OPER_MODULE_ISNT_LOADED, name);
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_ISNT_LOADED, mname.c_str());
return MOD_CONT;
}
- Alog() << "Trying to unload module [" << name << "]";
+ Alog() << "Trying to unload module [" << mname << "]";
status = ModuleManager::UnloadModule(m, u);
if (status != MOD_ERR_OK)
- notice_lang(Config.s_OperServ, u, OPER_MODULE_REMOVE_FAIL, name);
+ notice_lang(Config.s_OperServ, u, OPER_MODULE_REMOVE_FAIL, mname.c_str());
return MOD_CONT;
}
@@ -65,7 +65,7 @@ class OSModUnLoad : public Module
this->SetType(CORE);
this->SetPermanent(true);
- this->AddCommand(OPERSERV, new CommandOSModUnLoad());
+ this->AddCommand(OperServ, new CommandOSModUnLoad());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_news.c b/src/core/os_news.c
index e39db8011..30ae8a090 100644
--- a/src/core/os_news.c
+++ b/src/core/os_news.c
@@ -396,9 +396,9 @@ class OSNews : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSLogonNews());
- this->AddCommand(OPERSERV, new CommandOSOperNews());
- this->AddCommand(OPERSERV, new CommandOSRandomNews());
+ this->AddCommand(OperServ, new CommandOSLogonNews());
+ this->AddCommand(OperServ, new CommandOSOperNews());
+ this->AddCommand(OperServ, new CommandOSRandomNews());
Implementation i[] = { I_OnOperServHelp, I_OnUserModeSet, I_OnUserConnect, I_OnDatabaseRead, I_OnDatabaseWrite };
ModuleManager::Attach(i, this, 5);
diff --git a/src/core/os_noop.c b/src/core/os_noop.c
index eec054ea4..bfa1fcbeb 100644
--- a/src/core/os_noop.c
+++ b/src/core/os_noop.c
@@ -28,8 +28,6 @@ class CommandOSNOOP : public Command
if (cmd == "SET")
{
- User *u2;
- User *u3 = NULL;
std::string reason;
/* Remove the O:lines */
@@ -37,13 +35,15 @@ class CommandOSNOOP : public Command
reason = "NOOP command used by " + u->nick;
if (Config.WallOSNoOp)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "\2%s\2 used NOOP on \2%s\2", u->nick.c_str(), server);
+ ircdproto->SendGlobops(OperServ, "\2%s\2 used NOOP on \2%s\2", u->nick.c_str(), server);
notice_lang(Config.s_OperServ, u, OPER_NOOP_SET, server);
/* Kill all the IRCops of the server */
- for (u2 = firstuser(); u2; u2 = u3)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
{
- u3 = nextuser();
+ User *u2 = it->second;
+ ++it;
+
if (u2 && is_oper(u2) && Anope::Match(u2->server->GetName(), server, true))
kill_user(Config.s_OperServ, u2->nick.c_str(), reason.c_str());
}
@@ -79,7 +79,7 @@ class OSNOOP : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSNOOP());
+ this->AddCommand(OperServ, new CommandOSNOOP());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_oline.c b/src/core/os_oline.c
index 52f7d7ac0..f02484352 100644
--- a/src/core/os_oline.c
+++ b/src/core/os_oline.c
@@ -33,16 +33,16 @@ class CommandOSOLine : public Command
else if (u2 && flag[0] == '+')
{
ircdproto->SendSVSO(Config.s_OperServ, nick, flag);
- u2->SetMode(findbot(Config.s_OperServ), UMODE_OPER);
+ u2->SetMode(OperServ, UMODE_OPER);
notice_lang(Config.s_OperServ, u2, OPER_OLINE_IRCOP);
notice_lang(Config.s_OperServ, u, OPER_OLINE_SUCCESS, flag, nick);
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "\2%s\2 used OLINE for %s", u->nick.c_str(), nick);
+ ircdproto->SendGlobops(OperServ, "\2%s\2 used OLINE for %s", u->nick.c_str(), nick);
}
else if (u2 && flag[0] == '-')
{
ircdproto->SendSVSO(Config.s_OperServ, nick, flag);
notice_lang(Config.s_OperServ, u, OPER_OLINE_SUCCESS, flag, nick);
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "\2%s\2 used OLINE for %s", u->nick.c_str(), nick);
+ ircdproto->SendGlobops(OperServ, "\2%s\2 used OLINE for %s", u->nick.c_str(), nick);
}
else
this->OnSyntaxError(u, "");
@@ -70,7 +70,7 @@ class OSOLine : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSOLine());
+ this->AddCommand(OperServ, new CommandOSOLine());
if (!ircd->omode)
throw ModuleException("Your IRCd does not support OMODE.");
diff --git a/src/core/os_quit.c b/src/core/os_quit.c
index 4c6d09587..5d3630a2d 100644
--- a/src/core/os_quit.c
+++ b/src/core/os_quit.c
@@ -52,7 +52,7 @@ class OSQuit : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSQuit());
+ this->AddCommand(OperServ, new CommandOSQuit());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_reload.c b/src/core/os_reload.c
index 10afe2aa7..67c1c679f 100644
--- a/src/core/os_reload.c
+++ b/src/core/os_reload.c
@@ -54,7 +54,7 @@ class OSReload : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSReload());
+ this->AddCommand(OperServ, new CommandOSReload());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_restart.c b/src/core/os_restart.c
index 051b92155..8904381f5 100644
--- a/src/core/os_restart.c
+++ b/src/core/os_restart.c
@@ -51,7 +51,7 @@ class OSRestart : public Module
this->SetAuthor("Anope");
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSRestart());
+ this->AddCommand(OperServ, new CommandOSRestart());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_session.c b/src/core/os_session.c
index f450cf6a1..2f272ab1a 100644
--- a/src/core/os_session.c
+++ b/src/core/os_session.c
@@ -19,8 +19,7 @@ class CommandOSSession : public Command
private:
CommandReturn DoList(User *u, const std::vector<ci::string> &params)
{
- Session *session;
- int mincount, i;
+ int mincount;
const char *param = params[1].c_str();
if ((mincount = atoi(param)) <= 1)
@@ -29,13 +28,13 @@ class CommandOSSession : public Command
{
notice_lang(Config.s_OperServ, u, OPER_SESSION_LIST_HEADER, mincount);
notice_lang(Config.s_OperServ, u, OPER_SESSION_LIST_COLHEAD);
- for (i = 0; i < 1024; ++i)
+
+ for (session_map::const_iterator it = SessionList.begin(); it != SessionList.end(); ++it)
{
- for (session = sessionlist[i]; session; session = session->next)
- {
- if (session->count >= mincount)
- notice_lang(Config.s_OperServ, u, OPER_SESSION_LIST_FORMAT, session->count, session->host);
- }
+ Session *session = it->second;
+
+ if (session->count >= mincount)
+ notice_lang(Config.s_OperServ, u, OPER_SESSION_LIST_FORMAT, session->count, session->host);
}
}
@@ -460,8 +459,8 @@ class OSSession : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSSession());
- this->AddCommand(OPERSERV, new CommandOSException());
+ this->AddCommand(OperServ, new CommandOSSession());
+ this->AddCommand(OperServ, new CommandOSException());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_set.c b/src/core/os_set.c
index dea5286d6..419802871 100644
--- a/src/core/os_set.c
+++ b/src/core/os_set.c
@@ -113,7 +113,7 @@ class CommandOSSet : public Command
if (ircd->join2msg)
{
c = findchan(Config.LogChannel);
- ircdproto->SendJoin(findbot(Config.s_GlobalNoticer), Config.LogChannel, c ? c->creation_time : time(NULL));
+ ircdproto->SendJoin(Global, Config.LogChannel, c ? c->creation_time : time(NULL));
}
LogChan = true;
Alog() << "Now sending log messages to " << Config.LogChannel;
@@ -123,7 +123,7 @@ class CommandOSSet : public Command
{
Alog() << "No longer sending log messages to a channel";
if (ircd->join2msg)
- ircdproto->SendPart(findbot(Config.s_GlobalNoticer), findchan(Config.LogChannel), NULL);
+ ircdproto->SendPart(Global, findchan(Config.LogChannel), NULL);
LogChan = false;
notice_lang(Config.s_OperServ, u, OPER_SET_LOGCHAN_OFF);
}
@@ -155,14 +155,14 @@ class CommandOSSet : public Command
u->isSuperAdmin = 1;
notice_lang(Config.s_OperServ, u, OPER_SUPER_ADMIN_ON);
Alog() << Config.s_OperServ << ": " << u->nick << " is a SuperAdmin";
- ircdproto->SendGlobops(findbot(Config.s_OperServ), getstring(OPER_SUPER_ADMIN_WALL_ON), u->nick.c_str());
+ ircdproto->SendGlobops(OperServ, getstring(OPER_SUPER_ADMIN_WALL_ON), u->nick.c_str());
}
else if (setting == "OFF")
{
u->isSuperAdmin = 0;
notice_lang(Config.s_OperServ, u, OPER_SUPER_ADMIN_OFF);
Alog() << Config.s_OperServ << ": " << u->nick << " is no longer a SuperAdmin";
- ircdproto->SendGlobops(findbot(Config.s_OperServ), getstring(OPER_SUPER_ADMIN_WALL_OFF), u->nick.c_str());
+ ircdproto->SendGlobops(OperServ, getstring(OPER_SUPER_ADMIN_WALL_OFF), u->nick.c_str());
}
else
notice_lang(Config.s_OperServ, u, OPER_SUPER_ADMIN_SYNTAX);
@@ -298,7 +298,7 @@ class OSSet : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSSet());
+ this->AddCommand(OperServ, new CommandOSSet());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_sgline.c b/src/core/os_sgline.c
index 4a4e5a13b..27b062ee0 100644
--- a/src/core/os_sgline.c
+++ b/src/core/os_sgline.c
@@ -135,7 +135,7 @@ class CommandOSSGLine : public Command
snprintf(buf, sizeof(buf), "expires in %d %s%s", wall_expiry, s, wall_expiry == 1 ? "" : "s");
}
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s added an SGLINE for %s (%s)", u->nick.c_str(), cmask, buf);
+ ircdproto->SendGlobops(OperServ, "%s added an SGLINE for %s (%s)", u->nick.c_str(), cmask, buf);
}
if (readonly)
@@ -336,7 +336,7 @@ class OSSGLine : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSSGLine());
+ this->AddCommand(OperServ, new CommandOSSGLine());
if (!ircd->sgline)
throw ModuleException("Your IRCd does not support SGLine");
diff --git a/src/core/os_shutdown.c b/src/core/os_shutdown.c
index be97153b4..99801b8d0 100644
--- a/src/core/os_shutdown.c
+++ b/src/core/os_shutdown.c
@@ -52,7 +52,7 @@ class OSShutdown : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSShutdown());
+ this->AddCommand(OperServ, new CommandOSShutdown());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_sqline.c b/src/core/os_sqline.c
index c48791620..b73c3ce8b 100644
--- a/src/core/os_sqline.c
+++ b/src/core/os_sqline.c
@@ -121,7 +121,7 @@ class CommandOSSQLine : public Command
snprintf(buf, sizeof(buf), "expires in %d %s%s", wall_expiry, s, wall_expiry == 1 ? "" : "s");
}
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s added an SQLINE for %s (%s)", u->nick.c_str(), mask, buf);
+ ircdproto->SendGlobops(OperServ, "%s added an SQLINE for %s (%s)", u->nick.c_str(), mask, buf);
}
if (readonly)
@@ -322,7 +322,7 @@ class OSSQLine : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSSQLine());
+ this->AddCommand(OperServ, new CommandOSSQLine());
if (!ircd->sqline)
throw ModuleException("Your IRCd does not support QLines.");
diff --git a/src/core/os_staff.c b/src/core/os_staff.c
index f0e831bfc..80d1f95a1 100644
--- a/src/core/os_staff.c
+++ b/src/core/os_staff.c
@@ -34,8 +34,10 @@ class CommandOSStaff : public Command
if (na)
{
/* We have to loop all users as some may be logged into an account but not a nick */
- for (User *u2 = firstuser(); u2; u2 = nextuser())
+ for (user_map::iterator uit = UserListByNick.begin(); uit != UserListByNick.end(); ++uit)
{
+ User *u2 = uit->second;
+
if (u2->Account() && u2->Account() == na->nc)
{
found = 1;
@@ -72,7 +74,7 @@ class OSStaff : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSStaff());
+ this->AddCommand(OperServ, new CommandOSStaff());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_stats.c b/src/core/os_stats.c
index 9dae3474a..f98e94a19 100644
--- a/src/core/os_stats.c
+++ b/src/core/os_stats.c
@@ -304,7 +304,7 @@ class OSStats : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSStats());
+ this->AddCommand(OperServ, new CommandOSStats());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_svsnick.c b/src/core/os_svsnick.c
index 856f460bc..83906794f 100644
--- a/src/core/os_svsnick.c
+++ b/src/core/os_svsnick.c
@@ -61,7 +61,7 @@ class CommandOSSVSNick : public Command
else
{
notice_lang(Config.s_OperServ, u, OPER_SVSNICK_NEWNICK, nick, newnick.c_str());
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s used SVSNICK to change %s to %s", u->nick.c_str(), nick, newnick.c_str());
+ ircdproto->SendGlobops(OperServ, "%s used SVSNICK to change %s to %s", u->nick.c_str(), nick, newnick.c_str());
ircdproto->SendForceNickChange(u2, newnick.c_str(), time(NULL));
}
return MOD_CONT;
@@ -88,7 +88,7 @@ class OSSVSNick : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSSVSNick());
+ this->AddCommand(OperServ, new CommandOSSVSNick());
if (!ircd->svsnick)
throw ModuleException("Your IRCd does not support SVSNICK");
diff --git a/src/core/os_szline.c b/src/core/os_szline.c
index b99844835..b45c5eed2 100644
--- a/src/core/os_szline.c
+++ b/src/core/os_szline.c
@@ -121,7 +121,7 @@ class CommandOSSZLine : public Command
snprintf(buf, sizeof(buf), "expires in %d %s%s", wall_expiry, s, wall_expiry == 1 ? "" : "s");
}
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s added an SZLINE for %s (%s)", u->nick.c_str(), mask, buf);
+ ircdproto->SendGlobops(OperServ, "%s added an SZLINE for %s (%s)", u->nick.c_str(), mask, buf);
}
if (readonly)
@@ -321,7 +321,7 @@ class OSSZLine : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSSZLine());
+ this->AddCommand(OperServ, new CommandOSSZLine());
if (!ircd->szline)
throw ModuleException("Your IRCd does not support ZLINEs");
diff --git a/src/core/os_umode.c b/src/core/os_umode.c
index 4911aded3..2532d531d 100644
--- a/src/core/os_umode.c
+++ b/src/core/os_umode.c
@@ -41,13 +41,13 @@ class CommandOSUMode : public Command
notice_lang(Config.s_OperServ, u, NICK_X_NOT_IN_USE, nick);
else
{
- u2->SetModes(findbot(Config.s_OperServ), modes);
+ u2->SetModes(OperServ, modes);
notice_lang(Config.s_OperServ, u, OPER_UMODE_SUCCESS, nick);
notice_lang(Config.s_OperServ, u2, OPER_UMODE_CHANGED, u->nick.c_str());
if (Config.WallOSMode)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "\2%s\2 used UMODE on %s", u->nick.c_str(), nick);
+ ircdproto->SendGlobops(OperServ, "\2%s\2 used UMODE on %s", u->nick.c_str(), nick);
}
return MOD_CONT;
}
@@ -73,7 +73,7 @@ class OSUMode : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSUMode());
+ this->AddCommand(OperServ, new CommandOSUMode());
if (!ircd->umode)
throw ModuleException("Your IRCd does not support setting umodes");
diff --git a/src/core/os_update.c b/src/core/os_update.c
index 32ec6d804..750bb0e14 100644
--- a/src/core/os_update.c
+++ b/src/core/os_update.c
@@ -44,7 +44,7 @@ class OSUpdate : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSUpdate());
+ this->AddCommand(OperServ, new CommandOSUpdate());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/os_userlist.c b/src/core/os_userlist.c
index 93caa7a60..fbc57f406 100644
--- a/src/core/os_userlist.c
+++ b/src/core/os_userlist.c
@@ -55,32 +55,28 @@ class CommandOSUserList : public Command
}
else
{
- char mask[BUFSIZE];
- int i;
- User *u2;
-
notice_lang(Config.s_OperServ, u, OPER_USERLIST_HEADER);
- for (i = 0; i < 1024; ++i)
+ for (user_map::const_iterator uit = UserListByNick.begin(); uit != UserListByNick.end(); ++uit)
{
- for (u2 = userlist[i]; u2; u2 = u2->next)
+ User *u2 = uit->second;
+
+ if (pattern)
{
- if (pattern)
+ char mask[BUFSIZE];
+ snprintf(mask, sizeof(mask), "%s!%s@%s", u2->nick.c_str(), u2->GetIdent().c_str(), u2->GetDisplayedHost().c_str());
+ if (!Anope::Match(mask, pattern, false))
+ continue;
+ if (!Modes.empty())
{
- snprintf(mask, sizeof(mask), "%s!%s@%s", u2->nick.c_str(), u2->GetIdent().c_str(), u2->GetDisplayedHost().c_str());
- if (!Anope::Match(mask, pattern, false))
- continue;
- if (!Modes.empty())
+ for (std::list<UserModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
{
- for (std::list<UserModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
- {
- if (!u2->HasMode(*it))
- continue;
- }
+ if (!u2->HasMode(*it))
+ continue;
}
}
- notice_lang(Config.s_OperServ, u, OPER_USERLIST_RECORD, u2->nick.c_str(), u2->GetIdent().c_str(), u2->GetDisplayedHost().c_str());
}
+ notice_lang(Config.s_OperServ, u, OPER_USERLIST_RECORD, u2->nick.c_str(), u2->GetIdent().c_str(), u2->GetDisplayedHost().c_str());
}
}
@@ -104,7 +100,7 @@ class OSUserList : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(OPERSERV, new CommandOSUserList());
+ this->AddCommand(OperServ, new CommandOSUserList());
ModuleManager::Attach(I_OnOperServHelp, this);
}
diff --git a/src/core/ss_main.c b/src/core/ss_main.c
index 271f6f87e..d0578b16d 100644
--- a/src/core/ss_main.c
+++ b/src/core/ss_main.c
@@ -14,7 +14,6 @@
#include "module.h"
BotInfo *statserv = NULL;
-CommandHash *cmdTable[MAX_CMD_HASH];
class CommandSSHelp : public Command
{
@@ -40,8 +39,6 @@ class SSMain : public Module
this->SetType(CORE);
this->SetPermanent(true);
- this->AddCommand(cmdTable, new CommandSSHelp());
-
statserv = findbot("StatServ");
if (!statserv)
{
@@ -49,23 +46,19 @@ class SSMain : public Module
statserv = new BotInfo("StatServ", Config.ServiceUser, Config.ServiceHost, "Stats Service");
}
Alog() << "Done creating SS";
- statserv->cmdTable = cmdTable;
+
+ this->AddCommand(statserv, new CommandSSHelp());
}
~SSMain()
{
- CommandHash *current;
- Command *c;
- for (int i = 0; i < MAX_CMD_HASH; ++i)
+ if (statserv)
{
- for (current = cmdTable[i]; current; current = current->next)
+ for (std::map<ci::string, Command *>::iterator it = statserv->Commands.begin(); it != statserv->Commands.end(); ++it)
{
- for (c = current->c; c; c = c->next)
- this->DelCommand(cmdTable, c->name.c_str());
+ this->DelCommand(statserv, it->second);
}
- }
- if (statserv)
- {
+
ircdproto->SendQuit(statserv, "Quit due to module unload.");
delete statserv;
}
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 65e546c9c..462064235 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -164,3 +164,46 @@ bool sepstream::StreamEnd()
{
return n == tokens.end();
}
+
+/** Return a hash value for a string
+ * @param s The string
+ * @return The hash value
+ */
+size_t hash_compare_std_string::operator()(const std::string &s) const
+{
+ register size_t t = 0;
+
+ for (std::string::const_iterator it = s.begin(); it != s.end(); ++it)
+ t = 5 * t + static_cast<const unsigned char>(*it);
+
+ return t;
+}
+
+/** Return a hash value for a string using case insensitivity
+ * @param s The string
+ * @return The hash value
+ */
+size_t hash_compare_ci_string::operator()(const ci::string &s) const
+{
+ register size_t t = 0;
+
+ for (ci::string::const_iterator it = s.begin(); it != s.end(); ++it)
+ t = 5 * t + ascii_case_insensitive_map[static_cast<const unsigned char>(*it)];
+
+ return t;
+}
+
+/** Return a hash value for a string using RFC1459 case sensitivity rules
+ * @param s The string
+ * @return The hash value
+ */
+size_t hash_compare_irc_string::operator()(const irc::string &s) const
+{
+ register size_t t = 0;
+
+ for (irc::string::const_iterator it = s.begin(); it != s.end(); ++it)
+ t = 5 * t + rfc_case_insensitive_map[static_cast<const unsigned char>(*it)];
+
+ return t;
+}
+
diff --git a/src/hostserv.c b/src/hostserv.c
index b34b272a3..e43da5c05 100644
--- a/src/hostserv.c
+++ b/src/hostserv.c
@@ -15,8 +15,6 @@
#include "services.h"
#include "pseudo.h"
-#define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31))
-
E int do_hs_sync(NickCore * nc, char *vIdent, char *hostmask,
char *creator, time_t time);
@@ -40,21 +38,20 @@ void get_hostserv_stats(long *nrec, long *memuse)
{
long count = 0, mem = 0;
- for (int i = 0; i < 1024; ++i)
+ for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
{
- for (NickAlias *na = nalists[i]; na; na = na->next)
- {
- if (!na->hostinfo.HasVhost())
- continue;
-
- if (!na->hostinfo.GetIdent().empty())
- mem += na->hostinfo.GetIdent().size();
- if (!na->hostinfo.GetHost().empty())
- mem += na->hostinfo.GetHost().size();
- if (!na->hostinfo.GetCreator().empty())
- mem += na->hostinfo.GetCreator().size();
- ++count;
- }
+ NickAlias *na = it->second;
+
+ if (!na->hostinfo.HasVhost())
+ continue;
+
+ if (!na->hostinfo.GetIdent().empty())
+ mem += na->hostinfo.GetIdent().size();
+ if (!na->hostinfo.GetHost().empty())
+ mem += na->hostinfo.GetHost().size();
+ if (!na->hostinfo.GetCreator().empty())
+ mem += na->hostinfo.GetCreator().size();
+ ++count;
}
*nrec = count;
@@ -94,10 +91,10 @@ void hostserv(User * u, char *buf)
if (!(s = strtok(NULL, ""))) {
s = "";
}
- ircdproto->SendCTCP(findbot(Config.s_HostServ), u->nick.c_str(), "PING %s", s);
+ ircdproto->SendCTCP(HostServ, u->nick.c_str(), "PING %s", s);
} else {
if (ircd->vhost) {
- mod_run_cmd(Config.s_HostServ, u, HOSTSERV, cmd);
+ mod_run_cmd(HostServ, u, cmd);
} else {
notice_lang(Config.s_HostServ, u, SERVICE_OFFLINE, Config.s_HostServ);
}
diff --git a/src/init.c b/src/init.c
index 5fc1a8ab2..6a2698085 100644
--- a/src/init.c
+++ b/src/init.c
@@ -32,20 +32,17 @@ void introduce_user(const std::string &user)
lasttimes[LTSIZE - 1] = time(NULL);
#undef LTSIZE
/* We make the bots go online */
- BotInfo *bi;
- int i;
/* XXX: it might be nice to have this inside BotInfo's constructor, or something? */
- for (i = 0; i < 256; ++i)
+ for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it)
{
- for (bi = botlists[i]; bi; bi = bi->next)
+ BotInfo *bi = it->second;
+
+ ci::string ci_bi_nick(bi->nick.c_str());
+ if (user.empty() || ci_bi_nick == user)
{
- ci::string ci_bi_nick(bi->nick.c_str());
- if (user.empty() || ci_bi_nick == user)
- {
- ircdproto->SendClientIntroduction(bi->nick, bi->user, bi->host, bi->real, ircd->pseudoclient_mode, bi->uid);
- ircdproto->SendSQLine(bi->nick, "Reserved for services");
- }
+ ircdproto->SendClientIntroduction(bi->nick, bi->user, bi->host, bi->real, ircd->pseudoclient_mode, bi->uid);
+ ircdproto->SendSQLine(bi->nick, "Reserved for services");
}
}
}
@@ -326,9 +323,35 @@ int init_primary(int ac, char **av)
}
/* Add IRCD Protocol Module; exit if there are errors */
- if (protocol_module_init()) {
+ if (protocol_module_init())
return -1;
- }
+
+ /* First thing, add our core bots internally. Before modules are loaded and before the database is read
+ * This is used for modules adding commands and for the BotInfo* poiners in the command classes.
+ * When these bots are loaded from the databases the proper user/host/rname are added.
+ *
+ * If a user renames a bot in the configuration file, the new bot gets created here, and the old bot
+ * that is in the database gets created aswell, on its old nick. The old nick remains in all the channels
+ * etc and the new bot becomes the new client to accept commands. The user can use /bs bot del later
+ * if they want the old bot deleted.
+ *
+ * Note that it is important this is after loading the protocol module. The ircd struct must exist for
+ * the ts6_ functions
+ */
+ if (Config.s_OperServ)
+ new BotInfo(Config.s_OperServ, Config.ServiceUser, Config.ServiceHost, Config.desc_OperServ);
+ if (Config.s_NickServ)
+ new BotInfo(Config.s_NickServ, Config.ServiceUser, Config.ServiceHost, Config.desc_NickServ);
+ if (Config.s_ChanServ)
+ new BotInfo(Config.s_ChanServ, Config.ServiceUser, Config.ServiceHost, Config.desc_ChanServ);
+ if (Config.s_HostServ)
+ new BotInfo(Config.s_HostServ, Config.ServiceUser, Config.ServiceHost, Config.desc_HostServ);
+ if (Config.s_MemoServ)
+ new BotInfo(Config.s_MemoServ, Config.ServiceUser, Config.ServiceHost, Config.desc_MemoServ);
+ if (Config.s_BotServ)
+ new BotInfo(Config.s_BotServ, Config.ServiceUser, Config.ServiceHost, Config.desc_BotServ);
+ if (Config.s_GlobalNoticer)
+ new BotInfo(Config.s_GlobalNoticer, Config.ServiceUser, Config.ServiceHost, Config.desc_GlobalNoticer);
/* Add Encryption Modules */
ModuleManager::LoadModuleList(Config.EncModuleList);
@@ -439,49 +462,6 @@ int init_secondary(int ac, char **av)
FOREACH_RESULT(I_OnLoadDatabase, OnLoadDatabase());
Alog() << "Databases loaded";
- /* this is only used on the first run of Anope. */
- if (!nbots)
- {
- if (Config.s_OperServ)
- new BotInfo(Config.s_OperServ, Config.ServiceUser, Config.ServiceHost, Config.desc_OperServ);
- if (Config.s_NickServ)
- new BotInfo(Config.s_NickServ, Config.ServiceUser, Config.ServiceHost, Config.desc_NickServ);
- if (Config.s_ChanServ)
- new BotInfo(Config.s_ChanServ, Config.ServiceUser, Config.ServiceHost, Config.desc_ChanServ);
- if (Config.s_HostServ)
- new BotInfo(Config.s_HostServ, Config.ServiceUser, Config.ServiceHost, Config.desc_HostServ);
- if (Config.s_MemoServ)
- new BotInfo(Config.s_MemoServ, Config.ServiceUser, Config.ServiceHost, Config.desc_MemoServ);
- if (Config.s_BotServ)
- new BotInfo(Config.s_BotServ, Config.ServiceUser, Config.ServiceHost, Config.desc_BotServ);
- if (Config.s_GlobalNoticer)
- new BotInfo(Config.s_GlobalNoticer, Config.ServiceUser, Config.ServiceHost, Config.desc_GlobalNoticer);
- }
- else
- {
- /* If a botname was changed in the config, reflect it */
- for (int i = 0; i < 256; ++i)
- {
- for (BotInfo *bi = botlists[i]; bi; bi = bi->next)
- {
- if (bi->HasFlag(BI_OPERSERV) && bi->nick != Config.s_OperServ)
- bi->ChangeNick(Config.s_OperServ);
- else if (bi->HasFlag(BI_NICKSERV) && bi->nick != Config.s_NickServ)
- bi->ChangeNick(Config.s_NickServ);
- else if (bi->HasFlag(BI_CHANSERV) && bi->nick != Config.s_ChanServ)
- bi->ChangeNick(Config.s_ChanServ);
- else if (bi->HasFlag(BI_HOSTSERV) && bi->nick != Config.s_HostServ)
- bi->ChangeNick(Config.s_HostServ);
- else if (bi->HasFlag(BI_MEMOSERV) && bi->nick != Config.s_MemoServ)
- bi->ChangeNick(Config.s_MemoServ);
- else if (bi->HasFlag(BI_BOTSERV) && bi->nick != Config.s_BotServ)
- bi->ChangeNick(Config.s_BotServ);
- else if (bi->HasFlag(BI_GLOBAL) && bi->nick != Config.s_GlobalNoticer)
- bi->ChangeNick(Config.s_GlobalNoticer);
- }
- }
- }
-
FOREACH_MOD(I_OnPostLoadDatabases, OnPostLoadDatabases());
return 0;
diff --git a/src/log.c b/src/log.c
index 0ed07a371..d77920cdf 100644
--- a/src/log.c
+++ b/src/log.c
@@ -276,7 +276,7 @@ Alog::~Alog()
else if (Level == LOG_TERMINAL) // XXX dont use this yet unless you know we're at terminal and not daemonized
std::cout << buf.str() << std::endl;
if (Config.LogChannel && LogChan && !debug && findchan(Config.LogChannel)) {
- ircdproto->SendPrivmsg(findbot(Config.s_GlobalNoticer), Config.LogChannel, "%s", buf.str().c_str());
+ ircdproto->SendPrivmsg(Global, Config.LogChannel, "%s", buf.str().c_str());
}
errno = errno_save;
}
diff --git a/src/main.c b/src/main.c
index c5974f029..e14ca373e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -204,8 +204,8 @@ void do_restart_services()
delete UplinkSock;
close_log();
/* First don't unload protocol module, then do so */
- modules_unload_all(false);
- modules_unload_all(true);
+ ModuleManager::UnloadAll(false);
+ ModuleManager::UnloadAll(true);
chdir(binary_dir.c_str());
execve(services_bin.c_str(), my_av, my_envp);
if (!readonly) {
@@ -225,8 +225,6 @@ void do_restart_services()
static void services_shutdown()
{
- User *u, *next;
-
FOREACH_MOD(I_OnPreShutdown, OnPreShutdown());
if (!quitmsg)
@@ -235,11 +233,10 @@ static void services_shutdown()
if (started && UplinkSock)
{
ircdproto->SendSquit(Config.ServerName, quitmsg);
- u = firstuser();
- while (u) {
- next = nextuser();
- delete u;
- u = next;
+
+ while (!UserListByNick.empty())
+ {
+ delete UserListByNick.begin()->second;
}
}
/* Process to send the last bits of information before disconnecting */
@@ -247,8 +244,8 @@ static void services_shutdown()
delete UplinkSock;
FOREACH_MOD(I_OnShutdown, OnShutdown());
/* First don't unload protocol module, then do so */
- modules_unload_all(false);
- modules_unload_all(true);
+ ModuleManager::UnloadAll(false);
+ ModuleManager::UnloadAll(true);
/* just in case they weren't all removed at least run once */
ModuleRunTimeDirCleanUp();
}
diff --git a/src/memoserv.c b/src/memoserv.c
index 4ab9c76ff..0d8765631 100644
--- a/src/memoserv.c
+++ b/src/memoserv.c
@@ -62,9 +62,9 @@ void memoserv(User * u, char *buf)
if (!(s = strtok(NULL, ""))) {
s = "";
}
- ircdproto->SendCTCP(findbot(Config.s_MemoServ), u->nick.c_str(), "PING %s", s);
+ ircdproto->SendCTCP(MemoServ, u->nick.c_str(), "PING %s", s);
} else {
- mod_run_cmd(Config.s_MemoServ, u, MEMOSERV, cmd);
+ mod_run_cmd(MemoServ, u, cmd);
}
}
diff --git a/src/messages.c b/src/messages.c
index 5bac88650..7cf591a76 100644
--- a/src/messages.c
+++ b/src/messages.c
@@ -12,7 +12,7 @@
*/
#include "services.h"
-#include "messages.h"
+#include "modules.h"
#include "language.h"
/*************************************************************************/
@@ -176,7 +176,7 @@ int m_privmsg(const char *source, const std::string &receiver, const char *msg)
{
notice_lang(Config.s_OperServ, u, ACCESS_DENIED);
if (Config.WallBadOS)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "Denied access to %s from %s!%s@%s (non-oper)", Config.s_OperServ, u->nick.c_str(), u->GetIdent().c_str(), u->host);
+ ircdproto->SendGlobops(OperServ, "Denied access to %s from %s!%s@%s (non-oper)", Config.s_OperServ, u->nick.c_str(), u->GetIdent().c_str(), u->host);
}
else
operserv(u, const_cast<char *>(msg)); // XXX Unsafe cast, this needs reviewing -- CyberBotX
@@ -318,20 +318,10 @@ int m_whois(const char *source, const char *who)
}
/* *INDENT-OFF* */
-void moduleAddMsgs() {
- Message *m;
- m = createMessage("STATS", m_stats); addCoreMessage(IRCD,m);
- m = createMessage("TIME", m_time); addCoreMessage(IRCD,m);
- m = createMessage("VERSION", m_version); addCoreMessage(IRCD,m);
-}
-
-/*************************************************************************/
-
-Message *find_message(const char *name)
+void moduleAddMsgs()
{
- Message *m;
- m = findMessage(IRCD, name);
- return m;
+ Anope::AddMessage("STATS", m_stats);
+ Anope::AddMessage("TIME", m_time);
+ Anope::AddMessage("VERSION", m_version);
}
-/*************************************************************************/
diff --git a/src/misc.c b/src/misc.c
index 9b535b1ab..443dec298 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -819,16 +819,17 @@ int nickIsServices(const char *tempnick, int bot)
found++;
else if (Config.s_GlobalNoticer && (stricmp(nick, Config.s_GlobalNoticer) == 0))
found++;
- else if (Config.s_BotServ && bot) {
- BotInfo *bi;
- int i;
- for (i = 0; i < 256; i++) {
- for (bi = botlists[i]; bi; bi = bi->next) {
- ci::string ci_bi_nick(bi->nick.c_str());
- if (ci_bi_nick == nick) {
- found++;
- continue;
- }
+ else if (Config.s_BotServ && bot)
+ {
+ for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it)
+ {
+ BotInfo *bi = it->second;
+
+ ci::string ci_bi_nick(bi->nick.c_str());
+ if (ci_bi_nick == nick)
+ {
+ found++;
+ break;
}
}
}
diff --git a/src/module.cpp b/src/module.cpp
index 4582ac069..b30e2b6a7 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -24,31 +24,12 @@ Module::Module(const std::string &mname, const std::string &creator)
this->lang[i].argc = 0;
}
- int index = 0;
- ModuleHash *current = NULL;
- ModuleHash *newHash = NULL;
- ModuleHash *lastHash = NULL;
-
- index = CMD_HASH(this->name);
-
- for (current = MODULE_HASH[index]; current; current = current->next) {
- if (this->name ==current->name)
- throw CoreException("Module already exists!");
- lastHash = current;
- }
-
- if (!(newHash = new ModuleHash)) {
- fatal("Out of memory");
- }
+ if (FindModule(this->name))
+ throw CoreException("Module already exists!");
+
this->created = time(NULL);
- newHash->next = NULL;
- newHash->name = sstrdup(this->name.c_str());
- newHash->m = this;
-
- if (lastHash == NULL)
- MODULE_HASH[index] = newHash;
- else
- lastHash->next = newHash;
+
+ Modules.push_back(this);
}
Module::~Module()
@@ -60,85 +41,91 @@ Module::~Module()
remove(this->filename.c_str());
- int idx;
- CommandHash *current = NULL;
-
- Command *c;
-
/* Clear any active callbacks this module has */
ModuleManager::ClearCallBacks(this);
/**
* ok, im going to walk every hash looking for commands we own, now, not exactly elegant or efficiant :)
**/
- for (idx = 0; idx < MAX_CMD_HASH; idx++) {
- for (current = HS_cmdTable[idx]; current; current = current->next) {
- for (c = current->c; c; c = c->next) {
- if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) {
- this->DelCommand(HOSTSERV, c->name.c_str());
- }
- }
+ if (HostServ)
+ {
+ for (std::map<ci::string, Command *>::iterator it = HostServ->Commands.begin(); it != HostServ->Commands.end();)
+ {
+ Command *c = it->second;
+ ++it;
+
+ if (c->module == this)
+ this->DelCommand(HostServ, c);
}
+ }
+
+ if (BotServ)
+ {
+ for (std::map<ci::string, Command *>::iterator it = BotServ->Commands.begin(); it != BotServ->Commands.end();)
+ {
+ Command *c = it->second;
+ ++it;
- for (current = BS_cmdTable[idx]; current; current = current->next) {
- for (c = current->c; c; c = c->next) {
- if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) {
- this->DelCommand(BOTSERV, c->name.c_str());
- }
- }
+ if (c->module == this)
+ this->DelCommand(BotServ, c);
}
+ }
+
+ if (MemoServ)
+ {
+ for (std::map<ci::string, Command *>::iterator it = MemoServ->Commands.begin(); it != MemoServ->Commands.end();)
+ {
+ Command *c = it->second;
+ ++it;
- for (current = MS_cmdTable[idx]; current; current = current->next) {
- for (c = current->c; c; c = c->next) {
- if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) {
- this->DelCommand(MEMOSERV, c->name.c_str());
- }
- }
+ if (c->module == this)
+ this->DelCommand(MemoServ, c);
}
+ }
+
+ if (NickServ)
+ {
+ for (std::map<ci::string, Command *>::iterator it = NickServ->Commands.begin(); it != NickServ->Commands.end();)
+ {
+ Command *c = it->second;
+ ++it;
- for (current = NS_cmdTable[idx]; current; current = current->next) {
- for (c = current->c; c; c = c->next) {
- if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) {
- this->DelCommand(NICKSERV, c->name.c_str());
- }
- }
+ if (c->module == this)
+ this->DelCommand(NickServ, c);
}
+ }
+
+ if (ChanServ)
+ {
+ for (std::map<ci::string, Command *>::iterator it = ChanServ->Commands.begin(); it != ChanServ->Commands.end();)
+ {
+ Command *c = it->second;
+ ++it;
- for (current = CS_cmdTable[idx]; current; current = current->next) {
- for (c = current->c; c; c = c->next) {
- if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) {
- this->DelCommand(CHANSERV, c->name.c_str());
- }
- }
+ if (c->module == this)
+ this->DelCommand(ChanServ, c);
}
+ }
- for (current = OS_cmdTable[idx]; current; current = current->next) {
- for (c = current->c; c; c = c->next) {
- if ((c->mod_name) && (stricmp(c->mod_name, this->name.c_str()) == 0)) {
- this->DelCommand(OPERSERV, c->name.c_str());
- }
- }
+ if (OperServ)
+ {
+ for (std::map<ci::string, Command *>::iterator it = OperServ->Commands.begin(); it != OperServ->Commands.end();)
+ {
+ Command *c = it->second;
+ ++it;
+
+ if (c->module == this)
+ this->DelCommand(OperServ, c);
}
}
- int index = 0;
- ModuleHash *lastHash = NULL;
- ModuleHash *mhash = NULL;
-
- index = CMD_HASH(this->name);
-
- for (mhash = MODULE_HASH[index]; mhash; mhash = mhash->next) {
- if (this->name == mhash->name) {
- if (!lastHash) {
- MODULE_HASH[index] = mhash->next;
- } else {
- lastHash->next = mhash->next;
- }
- delete [] mhash->name;
- delete mhash;
+ for (std::deque<Module *>::iterator it = Modules.begin(); it != Modules.end(); ++it)
+ {
+ if (*it == this)
+ {
+ Modules.erase(it);
break;
}
- lastHash = mhash;
}
}
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index 18ab2bda4..b11ad2829 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -18,7 +18,7 @@ void ModuleManager::LoadModuleList(std::list<std::string> &ModuleList)
{
for (std::list<std::string>::iterator it = ModuleList.begin(); it != ModuleList.end(); ++it)
{
- Module *m = findModule(it->c_str());
+ Module *m = FindModule(*it);
if (!m)
ModuleManager::LoadModule(*it, NULL);
}
@@ -79,16 +79,13 @@ static int moduleCopyFile(const char *name, const char *output)
static bool IsOneOfModuleTypeLoaded(MODType mt)
{
- int idx = 0;
- ModuleHash *current = NULL;
int pmods = 0;
- for (idx = 0; idx != MAX_CMD_HASH; idx++)
+ for (std::deque<Module *>::iterator it = Modules.begin(); it != Modules.end(); ++it)
{
- for (current = MODULE_HASH[idx]; current; current = current->next)
+ if ((*it)->type == mt)
{
- if (current->m->type == mt)
- pmods++;
+ ++pmods;
}
}
@@ -127,7 +124,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u)
if (modname.empty())
return MOD_ERR_PARAMS;
- if (findModule(modname.c_str()) != NULL)
+ if (FindModule(modname) != NULL)
return MOD_ERR_EXISTS;
Alog(LOG_DEBUG) << "trying to load [" << modname << "]";
@@ -235,7 +232,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u)
if (u)
{
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s loaded module %s", u->nick.c_str(), modname.c_str());
+ ircdproto->SendGlobops(OperServ, "%s loaded module %s", u->nick.c_str(), modname.c_str());
notice_lang(Config.s_OperServ, u, OPER_MODULE_LOADED, modname.c_str());
/* If a user is loading this module, then the core databases have already been loaded
@@ -267,7 +264,7 @@ int ModuleManager::UnloadModule(Module *m, User *u)
if (u)
{
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s unloaded module %s", u->nick.c_str(), m->name.c_str());
+ ircdproto->SendGlobops(OperServ, "%s unloaded module %s", u->nick.c_str(), m->name.c_str());
notice_lang(Config.s_OperServ, u, OPER_MODULE_UNLOADED, m->name.c_str());
}
@@ -468,3 +465,21 @@ void ModuleManager::ClearCallBacks(Module *m)
delete m->CallBacks.front();
}
+/** Unloading all modules, NEVER call this when Anope isn't shutting down.
+ * Ever.
+ * @param unload_proto true to unload the protocol module
+ */
+void ModuleManager::UnloadAll(bool unload_proto)
+{
+ for (std::deque<Module *>::iterator it = Modules.begin(); it != Modules.end();)
+ {
+ Module *m = *it++;
+
+ if (unload_proto || m->type != PROTOCOL)
+ DeleteModule(m);
+
+ if (Modules.empty())
+ break;
+ }
+}
+
diff --git a/src/modules.c b/src/modules.c
index 97a3b55c6..822d04ea2 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -14,17 +14,8 @@
#include "language.h"
#include "version.h"
-/**
- * Declare all the list's we want to use here
- **/
-CommandHash *HOSTSERV[MAX_CMD_HASH];
-CommandHash *BOTSERV[MAX_CMD_HASH];
-CommandHash *MEMOSERV[MAX_CMD_HASH];
-CommandHash *NICKSERV[MAX_CMD_HASH];
-CommandHash *CHANSERV[MAX_CMD_HASH];
-CommandHash *OPERSERV[MAX_CMD_HASH];
-MessageHash *IRCD[MAX_CMD_HASH];
-ModuleHash *MODULE_HASH[MAX_CMD_HASH];
+std::multimap<std::string, Message *> MessageMap;
+std::deque<Module *> Modules;
char *mod_current_buffer = NULL;
@@ -64,7 +55,7 @@ int protocol_module_init()
if (ret == MOD_ERR_OK)
{
- findModule(Config.IRCDModule)->SetType(PROTOCOL);
+ FindModule(Config.IRCDModule)->SetType(PROTOCOL);
/* This is really NOT the correct place to do config checks, but
* as we only have the ircd struct filled here, we have to over
* here. -GD
@@ -82,32 +73,6 @@ int protocol_module_init()
return ret;
}
-/**
- * Unload ALL loaded modules, no matter what kind of module it is.
- * Do NEVER EVER, and i mean NEVER (and if that isn't clear enough
- * yet, i mean: NEVER AT ALL) call this unless we're shutting down,
- * or we'll fuck up Anope badly (protocol handling won't work for
- * example). If anyone calls this function without a justified need
- * for it, i reserve the right to break their legs in a painful way.
- * And if that isn't enough discouragement, you'll wake up with your
- * both legs broken tomorrow ;) -GD
- */
-void modules_unload_all(bool unload_proto)
-{
- int idx;
- ModuleHash *mh, *next;
-
- for (idx = 0; idx < MAX_CMD_HASH; idx++) {
- mh = MODULE_HASH[idx];
- while (mh) {
- next = mh->next;
- if (unload_proto || (mh->m->type != PROTOCOL))
- ModuleManager::UnloadModule(mh->m, NULL);
- mh = next;
- }
- }
-}
-
void Module::InsertLanguage(int langNumber, int ac, const char **av)
{
int i;
@@ -130,437 +95,128 @@ void Module::InsertLanguage(int langNumber, int ac, const char **av)
* @param name the name of the module to find
* @return a pointer to the module found, or NULL
*/
-Module *findModule(const char *name)
-{
- int idx;
- ModuleHash *current = NULL;
- if (!name) {
- return NULL;
- }
- idx = CMD_HASH(name);
-
- for (current = MODULE_HASH[idx]; current; current = current->next) {
- if (stricmp(name, current->name) == 0) {
- return current->m;
- }
- }
- return NULL;
-
-}
-
-/*******************************************************************************
- * Command Functions
- *******************************************************************************/
-
-/** Add a command to a command table. Only for internal use.
- * only add if were unique, pos = 0;
- * if we want it at the "head" of that command, pos = 1
- * at the tail, pos = 2
- * @param cmdTable the table to add the command to
- * @param c the command to add
- * @return MOD_ERR_OK will be returned on success.
- */
-static int internal_addCommand(Module *m, CommandHash * cmdTable[], Command * c)
+Module *FindModule(const std::string &name)
{
- /* We can assume both param's have been checked by this point.. */
- int index = 0;
- CommandHash *current = NULL;
- CommandHash *newHash = NULL;
- CommandHash *lastHash = NULL;
-
- if (!cmdTable || !c) {
- return MOD_ERR_PARAMS;
- }
-
- index = CMD_HASH(c->name.c_str());
+ for (std::deque<Module *>::iterator it = Modules.begin(); it != Modules.end(); ++it)
+ {
+ Module *m = *it;
- for (current = cmdTable[index]; current; current = current->next) {
- if ((c->service) && (current->c) && (current->c->service)
- && (!strcmp(c->service, current->c->service) == 0)) {
- continue;
- }
- if ((stricmp(c->name.c_str(), current->name) == 0))
+ if (m->name == name)
{
- /* the cmd exists, throw an error */
- return MOD_ERR_EXISTS;
+ return m;
}
- lastHash = current;
}
- newHash = new CommandHash;
- newHash->next = NULL;
- newHash->name = sstrdup(c->name.c_str());
- newHash->c = c;
-
- if (lastHash == NULL)
- cmdTable[index] = newHash;
- else
- lastHash->next = newHash;
-
- return MOD_ERR_OK;
+ return NULL;
}
-int Module::AddCommand(CommandHash * cmdTable[], Command * c)
+/** Add a message to Anope
+ * @param name The message name as sent by the IRCd
+ * @param func A callback function that will be called when this message is received
+ * @return The new message object
+ */
+Message *Anope::AddMessage(const std::string &name, int (*func)(const char *source, int ac, const char **av))
{
- int status;
-
- if (!cmdTable || !c) {
- return MOD_ERR_PARAMS;
- }
- c->core = 0;
- if (!c->mod_name) {
- c->mod_name = sstrdup(this->name.c_str());
- }
+ Message *m = new Message;
+ m->name = name;
+ m->func = func;
- if (cmdTable == HOSTSERV) {
- if (Config.s_HostServ) {
- c->service = sstrdup(Config.s_HostServ);
- } else {
- return MOD_ERR_NOSERVICE;
- }
- } else if (cmdTable == BOTSERV) {
- if (Config.s_BotServ) {
- c->service = sstrdup(Config.s_BotServ);
- } else {
- return MOD_ERR_NOSERVICE;
- }
- } else if (cmdTable == MEMOSERV) {
- if (Config.s_MemoServ) {
- c->service = sstrdup(Config.s_MemoServ);
- } else {
- return MOD_ERR_NOSERVICE;
- }
- } else if (cmdTable == CHANSERV) {
- if (Config.s_ChanServ) {
- c->service = sstrdup(Config.s_ChanServ);
- } else {
- return MOD_ERR_NOSERVICE;
- }
- } else if (cmdTable == NICKSERV) {
- if (Config.s_NickServ) {
- c->service = sstrdup(Config.s_NickServ);
- } else {
- return MOD_ERR_NOSERVICE;
- }
- } else if (cmdTable == OPERSERV) {
- if (Config.s_OperServ) {
- c->service = sstrdup(Config.s_OperServ);
- } else {
- return MOD_ERR_NOSERVICE;
- }
- } else
- c->service = sstrdup("Unknown");
+ MessageMap.insert(std::make_pair(m->name, m));
- status = internal_addCommand(this, cmdTable, c);
- if (status != MOD_ERR_OK)
- {
- Alog() << "ERROR! [ "<< status << "]";
- }
- return status;
+ return m;
}
-
-/** Remove a command from the command hash. Only for internal use.
- * @param cmdTable the command table to remove the command from
- * @param c the command to remove
- * @param mod_name the name of the module who owns the command
- * @return MOD_ERR_OK will be returned on success
+/** Deletes a message from Anope
+ * XXX Im not sure what will happen if this function is called indirectly from a message function pointed to by this message and there
+ * is more than one hook for this message.. must check
+ * @param m The message
+ * @return true if the message was found and deleted, else false
*/
-static int internal_delCommand(CommandHash * cmdTable[], Command * c, const char *mod_name)
+bool Anope::DelMessage(Message *m)
{
- int index = 0;
- CommandHash *current = NULL;
- CommandHash *lastHash = NULL;
- Command *tail = NULL, *last = NULL;
-
- if (!c || !cmdTable) {
- return MOD_ERR_PARAMS;
- }
-
- index = CMD_HASH(c->name.c_str());
- for (current = cmdTable[index]; current; current = current->next) {
- if (stricmp(c->name.c_str(), current->name) == 0) {
- if (!lastHash) {
- tail = current->c;
- if (tail->next) {
- while (tail) {
- if (mod_name && tail->mod_name
- && (stricmp(mod_name, tail->mod_name) == 0)) {
- if (last) {
- last->next = tail->next;
- } else {
- current->c = tail->next;
- }
- return MOD_ERR_OK;
- }
- last = tail;
- tail = tail->next;
- }
- } else {
- cmdTable[index] = current->next;
- delete [] current->name;
- return MOD_ERR_OK;
- }
- } else {
- tail = current->c;
- if (tail->next) {
- while (tail) {
- if (mod_name && tail->mod_name
- && (stricmp(mod_name, tail->mod_name) == 0)) {
- if (last) {
- last->next = tail->next;
- } else {
- current->c = tail->next;
- }
- return MOD_ERR_OK;
- }
- last = tail;
- tail = tail->next;
- }
- } else {
- lastHash->next = current->next;
- delete [] current->name;
- return MOD_ERR_OK;
- }
- }
- }
- lastHash = current;
- }
- return MOD_ERR_NOEXIST;
-}
+ std::multimap<std::string, Message *>::iterator it = MessageMap.find(m->name);
-/**
- * Delete a command from the service given.
- * @param cmdTable the cmdTable for the services to remove the command from
- * @param name the name of the command to delete from the service
- * @return returns MOD_ERR_OK on success
- */
-int Module::DelCommand(CommandHash * cmdTable[], const char *dname)
-{
- Command *c = NULL;
- Command *cmd = NULL;
- int status = 0;
-
- c = findCommand(cmdTable, dname);
- if (!c) {
- return MOD_ERR_NOEXIST;
+ if (it == MessageMap.end())
+ {
+ return false;
}
+ std::multimap<std::string, Message *>::iterator upper = MessageMap.upper_bound(m->name);
- for (cmd = c; cmd; cmd = cmd->next)
+ for (; it != upper; ++it)
{
- if (cmd->mod_name && cmd->mod_name == this->name)
+ if (it->second == m)
{
- status = internal_delCommand(cmdTable, cmd, this->name.c_str());
+ delete m;
+ MessageMap.erase(it);
+ return true;
}
}
- return status;
+
+ return false;
}
/*******************************************************************************
- * Message Functions
+ * Command Functions
*******************************************************************************/
- /**
- * Create a new Message struct.
- * @param name the name of the message
- * @param func a pointer to the function to call when we recive this message
- * @return a new Message object
- **/
-Message *createMessage(const char *name,
- int (*func) (const char *source, int ac, const char **av))
+int Module::AddCommand(BotInfo *bi, Command *c)
{
- Message *m = NULL;
- if (!name || !func) {
- return NULL;
- }
- if (!(m = new Message)) {
- fatal("Out of memory!");
- }
- m->name = sstrdup(name);
- m->func = func;
- m->core = 0;
- m->next = NULL;
- return m;
-}
+ if (!bi || !c)
+ return MOD_ERR_PARAMS;
+
+ c->service = bi;
-/**
- * find a message in the given table.
- * Looks up the message <name> in the MessageHash given
- * @param MessageHash the message table to search for this command, will almost always be IRCD
- * @param name the name of the command were looking for
- * @return NULL if we cant find it, or a pointer to the Message if we can
- **/
-Message *findMessage(MessageHash * msgTable[], const char *name)
-{
- int idx;
- MessageHash *current = NULL;
- if (!msgTable || !name) {
- return NULL;
- }
- idx = CMD_HASH(name);
+ std::pair<std::map<ci::string, Command *>::iterator, bool> it = bi->Commands.insert(std::make_pair(c->name, c));
- for (current = msgTable[idx]; current; current = current->next) {
- if (stricmp(name, current->name) == 0) {
- return current->m;
- }
+ if (it.second != true)
+ {
+ Alog() << "Error creating command " << c->name << ". Command already exists!";
+ delete c;
+ return MOD_ERR_EXISTS;
}
- return NULL;
+
+ return MOD_ERR_OK;
}
/**
- * Add a message to the MessageHash.
- * @param msgTable the MessageHash we want to add a message to
- * @param m the Message we want to add
- * @param pos the position we want to add the message to, E.G. MOD_HEAD, MOD_TAIL, MOD_UNIQUE
- * @return MOD_ERR_OK on a successful add.
- **/
-
-int addMessage(MessageHash * msgTable[], Message * m, int pos)
+ * Delete a command from the service given.
+ * @param cmdTable the cmdTable for the services to remove the command from
+ * @param name the name of the command to delete from the service
+ * @return returns MOD_ERR_OK on success
+ */
+int Module::DelCommand(BotInfo *bi, Command *c)
{
- /* We can assume both param's have been checked by this point.. */
- int index = 0;
- MessageHash *current = NULL;
- MessageHash *newHash = NULL;
- MessageHash *lastHash = NULL;
- Message *tail = NULL;
- int match = 0;
-
- if (!msgTable || !m || (pos < 0 || pos > 2)) {
+ if (!bi || !c)
return MOD_ERR_PARAMS;
- }
-
- index = CMD_HASH(m->name);
-
- for (current = msgTable[index]; current; current = current->next) {
- match = stricmp(m->name, current->name);
- if (match == 0) { /* the msg exist's we are a addHead */
- if (pos == 1) {
- m->next = current->m;
- current->m = m;
- Alog(LOG_DEBUG) << "existing msg: ("<< static_cast<void *>(m->next)
- << "), new msg (" << static_cast<void *>(m) << ")";
- return MOD_ERR_OK;
- } else if (pos == 2) {
- tail = current->m;
- while (tail->next)
- tail = tail->next;
- Alog(LOG_DEBUG) << "existing msg: ("<< static_cast<void *>(tail)
- << "), new msg (" << static_cast<void *>(m) << ")";
- m->next = NULL;
- return MOD_ERR_OK;
- } else
- return MOD_ERR_EXISTS;
- }
- lastHash = current;
- }
+
+ if (!bi->Commands.erase(c->name))
+ return MOD_ERR_NOEXIST;
- if (!(newHash = new MessageHash)) {
- fatal("Out of memory");
- }
- newHash->next = NULL;
- newHash->name = sstrdup(m->name);
- newHash->m = m;
-
- if (lastHash == NULL)
- msgTable[index] = newHash;
- else
- lastHash->next = newHash;
return MOD_ERR_OK;
}
/**
- * Add the given message (m) to the MessageHash marking it as a core command
- * @param msgTable the MessageHash we want to add to
- * @param m the Message we are adding
- * @return MOD_ERR_OK on a successful add.
+ * Find a message in the message table
+ * @param name The name of the message were looking for
+ * @return NULL if we cant find it, or a pointer to the Message if we can
**/
-int addCoreMessage(MessageHash * msgTable[], Message * m)
+std::vector<Message *> FindMessage(const std::string &name)
{
- if (!msgTable || !m) {
- return MOD_ERR_PARAMS;
- }
- m->core = 1;
- return addMessage(msgTable, m, 0);
-}
+ std::vector<Message *> messages;
-/**
- * remove the given message from the given message hash, for the given module
- * @param msgTable which MessageHash we are removing from
- * @param m the Message we want to remove
- * @return MOD_ERR_OK on success, althing else on fail.
- **/
-int delMessage(MessageHash * msgTable[], Message * m)
-{
- int index = 0;
- MessageHash *current = NULL;
- MessageHash *lastHash = NULL;
- Message *tail = NULL, *last = NULL;
+ std::multimap<std::string, Message *>::iterator it = MessageMap.find(name);
- if (!m || !msgTable) {
- return MOD_ERR_PARAMS;
- }
+ if (it == MessageMap.end())
+ return messages;
+
+ std::multimap<std::string, Message *>::iterator upper = MessageMap.upper_bound(name);
- index = CMD_HASH(m->name);
-
- for (current = msgTable[index]; current; current = current->next) {
- if (stricmp(m->name, current->name) == 0) {
- if (!lastHash) {
- tail = current->m;
- if (tail->next) {
- while (tail) {
- if (last) {
- last->next = tail->next;
- } else {
- current->m = tail->next;
- }
- return MOD_ERR_OK;
- }
- } else {
- msgTable[index] = current->next;
- delete [] current->name;
- return MOD_ERR_OK;
- }
- } else {
- tail = current->m;
- if (tail->next) {
- while (tail) {
- if (last) {
- last->next = tail->next;
- } else {
- current->m = tail->next;
- }
- return MOD_ERR_OK;
- }
- } else {
- lastHash->next = current->next;
- delete [] current->name;
- return MOD_ERR_OK;
- }
- }
- }
- lastHash = current;
- }
- return MOD_ERR_NOEXIST;
-}
+ for (; it != upper; ++it)
+ messages.push_back(it->second);
-/**
- * Destory a message, freeing its memory.
- * @param m the message to be destroyed
- * @return MOD_ERR_SUCCESS on success
- **/
-int destroyMessage(Message * m)
-{
- if (!m) {
- return MOD_ERR_PARAMS;
- }
- if (m->name) {
- delete [] m->name;
- }
- m->func = NULL;
- m->next = NULL;
- return MOD_ERR_OK;
+ return messages;
}
/*******************************************************************************
diff --git a/src/modules/cs_appendtopic.c b/src/modules/cs_appendtopic.c
index 22848b74a..311ac0717 100644
--- a/src/modules/cs_appendtopic.c
+++ b/src/modules/cs_appendtopic.c
@@ -141,7 +141,7 @@ class CSAppendTopic : public Module
this->SetVersion(VERSION);
this->SetType(SUPPORTED);
- this->AddCommand(CHANSERV, new CommandCSAppendTopic());
+ this->AddCommand(ChanServ, new CommandCSAppendTopic());
/* English (US) */
const char* langtable_en_us[] = {
diff --git a/src/modules/cs_enforce.c b/src/modules/cs_enforce.c
index 435f07d79..906e42ea6 100644
--- a/src/modules/cs_enforce.c
+++ b/src/modules/cs_enforce.c
@@ -229,7 +229,7 @@ class CSEnforce : public Module
this->SetVersion(VERSION);
this->SetType(SUPPORTED);
- this->AddCommand(CHANSERV, new CommandCSEnforce());
+ this->AddCommand(ChanServ, new CommandCSEnforce());
/* English (US) */
const char* langtable_en_us[] = {
diff --git a/src/modules/cs_tban.c b/src/modules/cs_tban.c
index 12fe8cd65..710840d52 100644
--- a/src/modules/cs_tban.c
+++ b/src/modules/cs_tban.c
@@ -92,7 +92,7 @@ class CSTBan : public Module
{
me = this;
- this->AddCommand(CHANSERV, new CommandCSTBan());
+ this->AddCommand(ChanServ, new CommandCSTBan());
this->SetAuthor(AUTHOR);
this->SetVersion(VERSION);
diff --git a/src/modules/hs_request.c b/src/modules/hs_request.c
index 0113817b7..385dfc8c5 100644
--- a/src/modules/hs_request.c
+++ b/src/modules/hs_request.c
@@ -378,10 +378,10 @@ class HSRequest : public Module
{
me = this;
- this->AddCommand(HOSTSERV, new CommandHSRequest());
- this->AddCommand(HOSTSERV, new CommandHSActivate());
- this->AddCommand(HOSTSERV, new CommandHSReject());
- this->AddCommand(HOSTSERV, new CommandHSWaiting());
+ this->AddCommand(HostServ, new CommandHSRequest());
+ this->AddCommand(HostServ, new CommandHSActivate());
+ this->AddCommand(HostServ, new CommandHSReject());
+ this->AddCommand(HostServ, new CommandHSWaiting());
this->SetAuthor(AUTHOR);
this->SetVersion(VERSION);
@@ -670,7 +670,7 @@ class HSRequest : public Module
if (!key.empty() && key == "+req")
{
std::vector<ci::string> emptyParams;
- Command *c = findCommand(HOSTSERV, "WAITING");
+ Command *c = FindCommand(HostServ, "WAITING");
c->Execute(u, emptyParams);
return EVENT_STOP;
}
diff --git a/src/modules/mysql/db_mysql.h b/src/modules/mysql/db_mysql.h
index 12956262a..f2885408f 100644
--- a/src/modules/mysql/db_mysql.h
+++ b/src/modules/mysql/db_mysql.h
@@ -98,13 +98,6 @@ struct BotServFlagInfo
BotServFlagInfo BotServFlags[] = {
{"PRIVATE", BI_PRIVATE},
- {"CHANSERV", BI_CHANSERV},
- {"BOTSERV", BI_BOTSERV},
- {"HOSTSERV", BI_HOSTSERV},
- {"OPERSERV", BI_OPERSERV},
- {"MEMOSERV", BI_MEMOSERV},
- {"NICKSERV", BI_NICKSERV},
- {"GLOBAL", BI_GLOBAL},
{"", static_cast<BotFlag>(-1)}
};
diff --git a/src/modules/mysql/db_mysql_execute.cpp b/src/modules/mysql/db_mysql_execute.cpp
index 3933d54d1..356f7c0f2 100644
--- a/src/modules/mysql/db_mysql_execute.cpp
+++ b/src/modules/mysql/db_mysql_execute.cpp
@@ -8,17 +8,12 @@ class FakeNickCore : public NickCore
public:
FakeNickCore() : NickCore("-SQLUser")
{
- if (this->next)
- this->next->prev = this->prev;
- if (this->prev)
- this->prev->next = this->next;
- else
- nclists[HASH(this->display)] = this->next;
+ NickCoreList.erase(this->display);
}
~FakeNickCore()
{
- insert_core(this);
+ NickCoreList[this->display] = this;
Users.clear();
}
@@ -39,23 +34,15 @@ class FakeUser : public User
this->vhost = NULL;
this->server = Me;
- if (this->prev)
- this->prev->next = this->next;
- else
- userlist[HASH(this->nick.c_str())] = this->next;
- if (this->next)
- this->next->prev = this->prev;
+ UserListByNick.erase("-SQLUser");
--usercnt;
}
~FakeUser()
{
- User **list = &userlist[HASH(this->nick.c_str())];
- this->next = *list;
- if (*list)
- (*list)->prev = this;
- *list = this;
+ UserListByNick["-SQLUser"] = this;
++usercnt;
+
nc = NULL;
}
@@ -145,7 +132,7 @@ class SQLTimer : public Timer
// XXX this whole strtok thing needs to die
char *cmdbuf = sstrdup(qres[i]["command"].c_str());
char *cmd = strtok(cmdbuf, " ");
- mod_run_cmd(bi->nick, u, bi->cmdTable, cmd);
+ mod_run_cmd(bi, u, cmd);
delete [] cmdbuf;
if (logout)
diff --git a/src/modules/mysql/db_mysql_read.cpp b/src/modules/mysql/db_mysql_read.cpp
index 728e4b882..79e59c9eb 100644
--- a/src/modules/mysql/db_mysql_read.cpp
+++ b/src/modules/mysql/db_mysql_read.cpp
@@ -166,7 +166,13 @@ static void LoadDatabase()
{
for (size_t i = 0; i < qres.num_rows(); ++i)
{
- BotInfo *bi = new BotInfo(SQLAssign(qres[i]["nick"]), SQLAssign(qres[i]["user"]), SQLAssign(qres[i]["host"]), SQLAssign(qres[i]["rname"]));
+ BotInfo *bi = findbot(SQLAssign(qres[i]["nick"]));
+ if (!bi)
+ bi = new BotInfo(SQLAssign(qres[i]["nick"]));
+ bi->user = SQLAssign(qres[i]["user"]);
+ bi->host = SQLAssign(qres[i]["host"]);
+ bi->real = SQLAssign(qres[i]["rname"]);
+
if (qres[i]["flags"].size())
{
spacesepstream sep(SQLAssign(qres[i]["flags"]));
diff --git a/src/modules/mysql/db_mysql_write.cpp b/src/modules/mysql/db_mysql_write.cpp
index 5f3218381..2f7a42bb3 100644
--- a/src/modules/mysql/db_mysql_write.cpp
+++ b/src/modules/mysql/db_mysql_write.cpp
@@ -230,51 +230,47 @@ static void SaveDatabases()
{
mysqlpp::Query query(me->Con);
- query << "TRUNCATE TABLE `anope_ns_core`";
- ExecuteQuery(query);
query << "TRUNCATE TABLE `anope_ns_alias`";
ExecuteQuery(query);
- for (int i = 0; i < 1024; ++i)
+ for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
{
- for (NickAlias *na = nalists[i]; na; na = na->next)
- {
- me->OnNickRegister(na);
- }
+ NickAlias *na = it->second;
+
+ me->OnNickRegister(na);
}
- query << "TRUNCATE TABLE `anope_ns_access`";
+ query << "TRUNCATE TABLE `anope_ns_core`";
ExecuteQuery(query);
query << "TRUNCATE TABLE `anope_ms_info`";
ExecuteQuery(query);
-
- for (int i = 0; i < 1024; ++i)
+
+ for (nickcore_map::const_iterator nit = NickCoreList.begin(); nit != NickCoreList.end(); ++nit)
{
- for (NickCore *nc = nclists[i]; nc; nc = nc->next)
+ NickCore *nc = nit->second;
+
+ for (std::vector<std::string>::iterator it = nc->access.begin(); it != nc->access.end(); ++it)
{
- for (std::vector<std::string>::iterator it = nc->access.begin(); it != nc->access.end(); ++it)
- {
- query << "INSERT DELAYED INTO `anope_ns_access` (display, access) VALUES(" << mysqlpp::quote << nc->display << ", " << mysqlpp::quote << *it << ")";
- ExecuteQuery(query);
- }
+ query << "INSERT DELAYED INTO `anope_ns_access` (display, access) VALUES(" << mysqlpp::quote << nc->display << ", " << mysqlpp::quote << *it << ")";
+ ExecuteQuery(query);
+ }
- for (unsigned j = 0; j < nc->memos.memos.size(); ++j)
- {
- Memo *m = nc->memos.memos[j];
+ for (unsigned j = 0; j < nc->memos.memos.size(); ++j)
+ {
+ Memo *m = nc->memos.memos[j];
- me->OnMemoSend(NULL, nc, m);
- }
+ me->OnMemoSend(NULL, nc, m);
}
}
+
query << "TRUNCATE TABLE `anope_bs_core`";
ExecuteQuery(query);
- for (int i = 0; i < 256; ++i)
+
+ for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it)
{
- for (BotInfo *bi = botlists[i]; bi; bi = bi->next)
- {
- me->OnBotCreate(bi);
- }
+ BotInfo *bi = it->second;
+ me->OnBotCreate(bi);
}
query << "TRUNCATE TABLE `anope_cs_info`";
@@ -288,67 +284,54 @@ static void SaveDatabases()
query << "TRUNCATE TABLE `anope_cs_levels`";
ExecuteQuery(query);
- for (int i = 0; i < 256; ++i)
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
{
- for (ChannelInfo *ci = chanlists[i]; ci; ci = ci->next)
- {
- me->OnChanRegistered(ci);
+ ChannelInfo *ci = it->second;
+
+ me->OnChanRegistered(ci);
- for (unsigned j = 0; j < ci->GetBadWordCount(); ++j)
- {
- BadWord *bw = ci->GetBadWord(j);
+ for (unsigned j = 0; j < ci->GetBadWordCount(); ++j)
+ {
+ BadWord *bw = ci->GetBadWord(j);
- if (bw->InUse)
- {
- me->OnBadWordAdd(ci, bw);
- }
- }
+ me->OnBadWordAdd(ci, bw);
+ }
- for (unsigned j = 0; j < ci->GetAccessCount(); ++j)
- {
- ChanAccess *access = ci->GetAccess(j);
+ for (unsigned j = 0; j < ci->GetAccessCount(); ++j)
+ {
+ ChanAccess *access = ci->GetAccess(j);
- if (access->in_use)
- {
- query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES('" << access->level << "', " << mysqlpp::quote << access->nc->display << ", " << mysqlpp::quote << ci->name << ", " << access->last_seen << ", " << mysqlpp::quote << access->creator << ") ON DUPLICATE KEY UPDATE level=VALUES(level), last_seen=VALUES(last_seen), creator=VALUES(creator)";
- ExecuteQuery(query);
- }
- }
+ query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES('" << access->level << "', " << mysqlpp::quote << access->nc->display << ", " << mysqlpp::quote << ci->name << ", " << access->last_seen << ", " << mysqlpp::quote << access->creator << ") ON DUPLICATE KEY UPDATE level=VALUES(level), last_seen=VALUES(last_seen), creator=VALUES(creator)";
+ ExecuteQuery(query);
+ }
- for (unsigned j = 0; j < ci->GetAkickCount(); ++j)
- {
- AutoKick *ak = ci->GetAkick(j);
+ for (unsigned j = 0; j < ci->GetAkickCount(); ++j)
+ {
+ AutoKick *ak = ci->GetAkick(j);
- if (ak->InUse)
- {
- me->OnAkickAdd(ci, ak);
- }
- }
+ me->OnAkickAdd(ci, ak);
+ }
- for (int k = 0; k < CA_SIZE; ++k)
- {
- query << "INSERT DELAYED INTO `anope_cs_levels` (channel, position, level) VALUES(" << mysqlpp::quote << ci->name << ", '" << k << "', '" << ci->levels[k] << "') ON DUPLICATE KEY UPDATE position=VALUES(position), level=VALUES(level)";
- ExecuteQuery(query);
- }
+ for (int k = 0; k < CA_SIZE; ++k)
+ {
+ query << "INSERT DELAYED INTO `anope_cs_levels` (channel, position, level) VALUES(" << mysqlpp::quote << ci->name << ", '" << k << "', '" << ci->levels[k] << "') ON DUPLICATE KEY UPDATE position=VALUES(position), level=VALUES(level)";
+ ExecuteQuery(query);
+ }
- for (unsigned j = 0; j < ci->memos.memos.size(); ++j)
- {
- Memo *m = ci->memos.memos[j];
+ for (unsigned j = 0; j < ci->memos.memos.size(); ++j)
+ {
+ Memo *m = ci->memos.memos[j];
- me->OnMemoSend(NULL, ci, m);
- }
+ me->OnMemoSend(NULL, ci, m);
}
}
query << "TRUNCATE TABLE `anope_ns_request`";
ExecuteQuery(query);
- for (int i = 0; i < 1024; i++)
+ for (nickrequest_map::const_iterator it = NickRequestList.begin(); it != NickRequestList.end(); ++it)
{
- for (NickRequest *nr = nrlists[i]; nr; nr = nr->next)
- {
- me->OnMakeNickRequest(nr);
- }
+ me->OnMakeNickRequest(it->second);
}
for (int i = 0; i < akills.count; ++i)
@@ -418,7 +401,7 @@ class DBMySQLWrite : public DBMySQL
ModuleManager::Attach(I_OnServerConnect, this);
- this->AddCommand(OPERSERV, new CommandSyncSQL("SQLSYNC"));
+ this->AddCommand(OperServ, new CommandSyncSQL("SQLSYNC"));
if (uplink_server)
OnServerConnect();
@@ -470,46 +453,35 @@ class DBMySQLWrite : public DBMySQL
query << maxusercnt << ", " << maxusertime << ", " << akills.count << ", " << sqlines.count << ", " << sglines.count << ", " << szlines.count << ")";
ExecuteQuery(query);
- for (int i = 0; i < 1024; ++i)
+ for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
{
- for (NickCore *nc = nclists[i]; nc; nc = nc->next)
- {
- CurCore = nc;
- FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteCoreMetadata, nc));
- }
+ CurCore = it->second;
+ FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteCoreMetadata, CurCore));
}
- for (int i = 0; i < 1024; ++i)
+ for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
{
- for (NickAlias *na = nalists[i]; na; na = na->next)
- {
- CurNick = na;
- FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteNickMetadata, na));
- }
+ CurNick = it->second;
+ FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteNickMetadata, CurNick));
}
- for (int i = 0; i < 256; ++i)
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
{
- for (ChannelInfo *ci = chanlists[i]; ci; ci = ci->next)
- {
- CurChannel = ci;
- FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, ci));
- }
+ CurChannel = it->second;
+ FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, CurChannel));
}
- for (int i = 0; i < 256; ++i)
+ for (botinfo_map::const_iterator it = BotList.begin(); it != BotList.end(); ++it)
{
- for (BotInfo *bi = botlists[i]; bi; bi = bi->next)
- {
- CurBot = bi;
- FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteBotMetadata, bi));
- /* This is for the core bots, bots added by users are already handled by an event */
- query << "INSERT DELAYED INTO `anope_bs_core` (nick, user, host, rname, flags, created, chancount) VALUES(";
- query << mysqlpp::quote << bi->nick << ", " << mysqlpp::quote << bi->user << ", " << mysqlpp::quote << bi->host;
- query << ", " << mysqlpp::quote << bi->real << ", '" << GetBotServFlags(bi) << "', " << bi->created << ", ";
- query << bi->chancount << ") ON DUPLICATE KEY UPDATE nick=VALUES(nick), user=VALUES(user), host=VALUES(host), rname=VALUES(rname), flags=VALUES(flags), created=VALUES(created), chancount=VALUES(created)";
- ExecuteQuery(query);
- }
+ CurBot = it->second;
+ FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteBotMetadata, CurBot));
+
+ /* This is for the core bots, bots added by users are already handled by an event */
+ query << "INSERT DELAYED INTO `anope_bs_core` (nick, user, host, rname, flags, created, chancount) VALUES(";
+ query << mysqlpp::quote << CurBot->nick << ", " << mysqlpp::quote << CurBot->user << ", " << mysqlpp::quote << CurBot->host;
+ query << ", " << mysqlpp::quote << CurBot->real << ", '" << GetBotServFlags(CurBot) << "', " << CurBot->created << ", ";
+ query << CurBot->chancount << ") ON DUPLICATE KEY UPDATE nick=VALUES(nick), user=VALUES(user), host=VALUES(host), rname=VALUES(rname), flags=VALUES(flags), created=VALUES(created), chancount=VALUES(created)";
+ ExecuteQuery(query);
}
FOREACH_MOD(I_OnDatabaseWrite, OnDatabaseWrite(Write));
diff --git a/src/modules/ns_maxemail.c b/src/modules/ns_maxemail.c
index e98dc62d7..2399dba68 100644
--- a/src/modules/ns_maxemail.c
+++ b/src/modules/ns_maxemail.c
@@ -127,20 +127,17 @@ class NSMaxEmail : public Module
int count_email_in_use(const char *email, User * u)
{
- NickCore *nc;
- int i;
int count = 0;
if (!email)
return 0;
- for (i = 0; i < 1024; ++i)
+ for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
{
- for (nc = nclists[i]; nc; nc = nc->next)
- {
- if (!(u->Account() && u->Account() == nc) && nc->email && !stricmp(nc->email, email))
- ++count;
- }
+ NickCore *nc = it->second;
+
+ if (!(u->Account() && u->Account() == nc) && nc->email && !stricmp(nc->email, email))
+ ++count;
}
return count;
diff --git a/src/modules/os_info.c b/src/modules/os_info.c
index b486e32f6..a49fa8a88 100644
--- a/src/modules/os_info.c
+++ b/src/modules/os_info.c
@@ -193,8 +193,8 @@ class OSInfo : public Module
this->SetVersion(VERSION);
this->SetType(SUPPORTED);
- this->AddCommand(NICKSERV, new CommandNSOInfo());
- this->AddCommand(CHANSERV, new CommandCSOInfo());
+ this->AddCommand(NickServ, new CommandNSOInfo());
+ this->AddCommand(ChanServ, new CommandCSOInfo());
const char* langtable_en_us[] = {
/* OINFO_SYNTAX */
@@ -415,27 +415,20 @@ class OSInfo : public Module
~OSInfo()
{
- int i;
- NickCore *nc;
- ChannelInfo *ci;
-
OnSaveDatabase();
- for (i = 0; i < 1024; ++i)
+ for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
{
- /* Remove the nick Cores */
- for (nc = nclists[i]; nc; nc = nc->next)
- {
- nc->Shrink("os_info");
- }
+ NickCore *nc = it->second;
+
+ nc->Shrink("os_info");
}
- for (i = 0; i < 256; ++i)
+ for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
{
- for (ci = chanlists[i]; ci; ci = ci->next)
- {
- ci->Shrink("os_info");
- }
+ ChannelInfo *ci = it->second;
+
+ ci->Shrink("os_info");
}
}
diff --git a/src/nickalias.cpp b/src/nickalias.cpp
index afd40ccd7..95d5bc4e9 100644
--- a/src/nickalias.cpp
+++ b/src/nickalias.cpp
@@ -1,31 +1,24 @@
#include "services.h"
#include "modules.h"
-#define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31))
-
NickRequest::NickRequest(const std::string &nickname)
{
if (nickname.empty())
throw CoreException("Empty nick passed to NickRequest constructor");
- next = prev = NULL;
email = NULL;
requested = lastmail = 0;
this->nick = sstrdup(nickname.c_str());
- insert_requestnick(this); // till this is destroyed / redone in STL
+
+ NickRequestList[this->nick] = this;
}
NickRequest::~NickRequest()
{
FOREACH_MOD(I_OnDelNickRequest, OnDelNickRequest(this));
- if (this->next)
- this->next->prev = this->prev;
- if (this->prev)
- this->prev->next = this->next;
- else
- nrlists[HASH(this->nick)] = this->next;
+ NickRequestList.erase(this->nick);
if (this->nick)
delete [] this->nick;
@@ -44,14 +37,14 @@ NickAlias::NickAlias(const std::string &nickname, NickCore *nickcore)
else if (!nickcore)
throw CoreException("Empty nickcore passed to NickAlias constructor");
- next = prev = NULL;
nick = last_quit = last_realname = last_usermask = NULL;
time_registered = last_seen = 0;
this->nick = sstrdup(nickname.c_str());
this->nc = nickcore;
slist_add(&nc->aliases, this);
- alpha_insert_alias(this);
+
+ NickAliasList[this->nick] = this;
for (std::list<std::pair<std::string, std::string> >::iterator it = Config.Opers.begin(); it != Config.Opers.end(); it++)
{
@@ -110,12 +103,7 @@ NickAlias::~NickAlias()
}
/* Remove us from the aliases list */
- if (this->next)
- this->next->prev = this->prev;
- if (this->prev)
- this->prev->next = this->next;
- else
- nalists[HASH(this->nick)] = this->next;
+ NickAliasList.erase(this->nick);
delete [] this->nick;
if (this->last_usermask)
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index 1b01c3d54..cfca2eb2a 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -1,8 +1,6 @@
#include "services.h"
#include "pseudo.h"
-#define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31))
-
/** Default constructor
* @param display The display nick
*/
@@ -11,7 +9,6 @@ NickCore::NickCore(const std::string &coredisplay)
if (coredisplay.empty())
throw CoreException("Empty display passed to NickCore constructor");
- next = prev = NULL;
display = email = greet = url = NULL;
ot = NULL;
icq = 0;
@@ -20,12 +17,13 @@ NickCore::NickCore(const std::string &coredisplay)
this->display = sstrdup(coredisplay.c_str());
slist_init(&this->aliases);
- insert_core(this); // till hashing is redone..
/* Set default nick core flags */
for (size_t t = NI_BEGIN + 1; t != NI_END; ++t)
if (Config.NSDefFlags.HasFlag(static_cast<NickCoreFlag>(t)))
SetFlag(static_cast<NickCoreFlag>(t));
+
+ NickCoreList[this->display] = this;
}
/** Default destructor
@@ -51,12 +49,7 @@ NickCore::~NickCore()
cs_remove_nick(this);
/* Remove the core from the list */
- if (this->next)
- this->next->prev = this->prev;
- if (this->prev)
- this->prev->next = this->next;
- else
- nclists[HASH(this->display)] = this->next;
+ NickCoreList.erase(this->display);
/* Log .. */
Alog() << Config.s_NickServ << ": deleting nickname group " << this->display;
diff --git a/src/nickserv.c b/src/nickserv.c
index fc6627109..9dae3ac8d 100644
--- a/src/nickserv.c
+++ b/src/nickserv.c
@@ -17,11 +17,9 @@
/*************************************************************************/
-#define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31))
-
-NickAlias *nalists[1024];
-NickCore *nclists[1024];
-NickRequest *nrlists[1024];
+nickalias_map NickAliasList;
+nickcore_map NickCoreList;
+nickrequest_map NickRequestList;
static std::map<std::string, NickServCollide *> NickServCollides;
static std::map<std::string, NickServRelease *> NickServReleases;
@@ -93,24 +91,21 @@ void moduleAddNickServCmds()
void get_aliases_stats(long *nrec, long *memuse)
{
long count = 0, mem = 0;
- int i;
- NickAlias *na;
- for (i = 0; i < 1024; i++)
+ for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
{
- for (na = nalists[i]; na; na = na->next)
- {
- count++;
- mem += sizeof(*na);
- if (na->nick)
- mem += strlen(na->nick) + 1;
- if (na->last_usermask)
- mem += strlen(na->last_usermask) + 1;
- if (na->last_realname)
- mem += strlen(na->last_realname) + 1;
- if (na->last_quit)
- mem += strlen(na->last_quit) + 1;
- }
+ NickAlias *na = it->second;
+
+ count++;
+ mem += sizeof(*na);
+ if (na->nick)
+ mem += strlen(na->nick) + 1;
+ if (na->last_usermask)
+ mem += strlen(na->last_usermask) + 1;
+ if (na->last_realname)
+ mem += strlen(na->last_realname) + 1;
+ if (na->last_quit)
+ mem += strlen(na->last_quit) + 1;
}
*nrec = count;
*memuse = mem;
@@ -123,40 +118,38 @@ void get_aliases_stats(long *nrec, long *memuse)
void get_core_stats(long *nrec, long *memuse)
{
long count = 0, mem = 0;
- unsigned i, j;
- NickCore *nc;
+ unsigned j;
- for (i = 0; i < 1024; i++)
+ for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
{
- for (nc = nclists[i]; nc; nc = nc->next)
+ NickCore *nc = it->second;
+
+ count++;
+ mem += sizeof(*nc);
+
+ if (nc->display)
+ mem += strlen(nc->display) + 1;
+ if (!nc->pass.empty())
+ mem += (nc->pass.capacity() + (2 * sizeof(size_t)) + (2 * sizeof(void*)));
+ if (nc->url)
+ mem += strlen(nc->url) + 1;
+ if (nc->email)
+ mem += strlen(nc->email) + 1;
+ if (nc->greet)
+ mem += strlen(nc->greet) + 1;
+
+ mem += sizeof(std::string) * nc->access.size();
+ for (j = 0; j < nc->access.size(); ++j)
+ mem += nc->GetAccess(j).length() + 1;
+
+ mem += nc->memos.memos.size() * sizeof(Memo);
+ for (j = 0; j < nc->memos.memos.size(); j++)
{
- count++;
- mem += sizeof(*nc);
-
- if (nc->display)
- mem += strlen(nc->display) + 1;
- if (!nc->pass.empty())
- mem += (nc->pass.capacity() + (2 * sizeof(size_t)) + (2 * sizeof(void*)));
- if (nc->url)
- mem += strlen(nc->url) + 1;
- if (nc->email)
- mem += strlen(nc->email) + 1;
- if (nc->greet)
- mem += strlen(nc->greet) + 1;
-
- mem += sizeof(std::string) * nc->access.size();
- for (j = 0; j < nc->access.size(); ++j)
- mem += nc->GetAccess(j).length() + 1;
-
- mem += nc->memos.memos.size() * sizeof(Memo);
- for (j = 0; j < nc->memos.memos.size(); j++)
- {
- if (nc->memos.memos[j]->text)
- mem += strlen(nc->memos.memos[j]->text) + 1;
- }
-
- mem += sizeof(void *) * nc->aliases.count;
+ if (nc->memos.memos[j]->text)
+ mem += strlen(nc->memos.memos[j]->text) + 1;
}
+
+ mem += sizeof(void *) * nc->aliases.count;
}
*nrec = count;
*memuse = mem;
@@ -192,11 +185,11 @@ void nickserv(User * u, char *buf)
{
s = "";
}
- ircdproto->SendCTCP(findbot(Config.s_NickServ), u->nick.c_str(), "PING %s", s);
+ ircdproto->SendCTCP(NickServ, u->nick.c_str(), "PING %s", s);
}
else
{
- mod_run_cmd(Config.s_NickServ, u, NICKSERV, cmd);
+ mod_run_cmd(NickServ, u, cmd);
}
}
@@ -293,138 +286,111 @@ int validate_user(User * u)
void expire_nicks()
{
- int i;
- NickAlias *na, *next;
time_t now = time(NULL);
- char *tmpnick;
- for (i = 0; i < 1024; i++)
+ for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end();)
{
- for (na = nalists[i]; na; na = next)
+ NickAlias *na = it->second;
+ ++it;
+
+ User *u = finduser(na->nick);
+ if (u && (na->nc->HasFlag(NI_SECURE) ? u->IsIdentified() : u->IsRecognized()))
{
- next = na->next;
+ Alog(LOG_DEBUG_2) << "NickServ: updating last seen time for " << na->nick;
+ na->last_seen = now;
+ continue;
+ }
- User *u = finduser(na->nick);
- if (u && (na->nc->HasFlag(NI_SECURE) ? u->IsIdentified() : u->IsRecognized()))
- {
- Alog(LOG_DEBUG_2) << "NickServ: updating last seen time for " << na->nick;
- na->last_seen = now;
+ if (Config.NSExpire && now - na->last_seen >= Config.NSExpire
+ && !na->HasFlag(NS_FORBIDDEN) && !na->HasFlag(NS_NO_EXPIRE)
+ && !na->nc->HasFlag(NI_SUSPENDED))
+ {
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(I_OnPreNickExpire, OnPreNickExpire(na));
+ if (MOD_RESULT == EVENT_STOP)
continue;
- }
-
- if (Config.NSExpire && now - na->last_seen >= Config.NSExpire
- && !na->HasFlag(NS_FORBIDDEN) && !na->HasFlag(NS_NO_EXPIRE)
- && !na->nc->HasFlag(NI_SUSPENDED))
- {
- EventReturn MOD_RESULT;
- FOREACH_RESULT(I_OnPreNickExpire, OnPreNickExpire(na));
- if (MOD_RESULT == EVENT_STOP)
- continue;
- Alog() << "Expiring nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: "
- << (na->nc->email ? na->nc->email : "none") << ")";
- tmpnick = sstrdup(na->nick);
- delete na;
- FOREACH_MOD(I_OnNickExpire, OnNickExpire(tmpnick));
- delete [] tmpnick;
- }
+ Alog() << "Expiring nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: "
+ << (na->nc->email ? na->nc->email : "none") << ")";
+ FOREACH_MOD(I_OnNickExpire, OnNickExpire(na));
+ delete na;
}
}
}
void expire_requests()
{
- int i;
- NickRequest *nr, *next;
time_t now = time(NULL);
- for (i = 0; i < 1024; i++)
+
+ for (nickrequest_map::const_iterator it = NickRequestList.begin(); it != NickRequestList.end(); ++it)
{
- for (nr = nrlists[i]; nr; nr = next)
+ NickRequest *nr = it->second;
+
+ if (Config.NSRExpire && now - nr->requested >= Config.NSRExpire)
{
- next = nr->next;
- if (Config.NSRExpire && now - nr->requested >= Config.NSRExpire)
- {
- Alog() << "Request for nick " << nr->nick << " expiring";
- delete nr;
- }
+ Alog() << "Request for nick " << nr->nick << " expiring";
+ delete nr;
}
}
}
/*************************************************************************/
-/*************************************************************************/
-/* Return the NickRequest structire for the given nick, or NULL */
NickRequest *findrequestnick(const char *nick)
{
- NickRequest *nr;
+ return findrequestnick(ci::string(nick));
+}
- if (!*nick || !nick)
- {
- Alog(LOG_DEBUG) << "findrequestnick() called with NULL values";
- return NULL;
- }
+NickRequest *findrequestnick(const std::string &nick)
+{
+ return findrequestnick(ci::string(nick.c_str()));
+}
- for (nr = nrlists[HASH(nick)]; nr; nr = nr->next)
- {
- if (stricmp(nr->nick, nick) == 0)
- {
- return nr;
- }
- }
+NickRequest *findrequestnick(const ci::string &nick)
+{
+ nickrequest_map::const_iterator it = NickRequestList.find(nick);
+
+ if (it != NickRequestList.end())
+ return it->second;
return NULL;
}
-/* Return the NickAlias structure for the given nick, or NULL if the nick
- * isn't registered. */
-
NickAlias *findnick(const char *nick)
{
- NickAlias *na;
-
- if (!nick || !*nick)
- {
- Alog(LOG_DEBUG) << "findnick() called with NULL values";
- return NULL;
- }
-
- for (na = nalists[HASH(nick)]; na; na = na->next)
- {
- if (stricmp(na->nick, nick) == 0)
- {
- return na;
- }
- }
- return NULL;
+ return findnick(ci::string(nick));
}
NickAlias *findnick(const std::string &nick)
{
- return findnick(nick.c_str());
+ return findnick(ci::string(nick.c_str()));
}
-/*************************************************************************/
+NickAlias *findnick(const ci::string &nick)
+{
+ nickalias_map::const_iterator it = NickAliasList.find(nick);
+
+ if (it != NickAliasList.end())
+ return it->second;
+ return NULL;
+}
-/* Return the NickCore structure for the given nick, or NULL if the core
- * doesn't exist. */
+/*************************************************************************/
NickCore *findcore(const char *nick)
{
- NickCore *nc;
+ return findcore(ci::string(nick));
+}
- if (!nick || !*nick)
- {
- Alog(LOG_DEBUG) << "findcore() called with NULL values";
- return NULL;
- }
+NickCore *findcore(const std::string &nick)
+{
+ return findcore(ci::string(nick.c_str()));
+}
- for (nc = nclists[HASH(nick)]; nc; nc = nc->next)
- {
- if (stricmp(nc->display, nick) == 0)
- {
- return nc;
- }
- }
+NickCore *findcore(const ci::string &nick)
+{
+ nickcore_map::const_iterator it = NickCoreList.find(nick);
+ if (it != NickCoreList.end())
+ return it->second;
return NULL;
}
@@ -497,78 +463,6 @@ bool is_on_access(User *u, NickCore *nc)
/*************************************************************************/
-/* Insert a nick alias alphabetically into the database. */
-
-void alpha_insert_alias(NickAlias * na)
-{
- NickAlias *ptr, *prev;
- char *nick;
- int index;
-
- if (!na)
- {
- Alog(LOG_DEBUG) << "alpha_insert_alias called with NULL values";
- return;
- }
-
- nick = na->nick;
- index = HASH(nick);
-
- for (prev = NULL, ptr = nalists[index];
- ptr && stricmp(ptr->nick, nick) < 0; prev = ptr, ptr = ptr->next);
- na->prev = prev;
- na->next = ptr;
- if (!prev)
- nalists[index] = na;
- else
- prev->next = na;
- if (ptr)
- ptr->prev = na;
-}
-
-/*************************************************************************/
-
-/* Insert a nick core into the database. */
-
-void insert_core(NickCore * nc)
-{
- int index;
-
- if (!nc)
- {
- Alog(LOG_DEBUG) << "insert_core called with NULL values";
- return;
- }
-
- index = HASH(nc->display);
-
- nc->prev = NULL;
- nc->next = nclists[index];
- if (nc->next)
- nc->next->prev = nc;
- nclists[index] = nc;
-}
-
-/*************************************************************************/
-void insert_requestnick(NickRequest * nr)
-{
- int index = HASH(nr->nick);
- if (!nr)
- {
- Alog(LOG_DEBUG) << "insert_requestnick called with NULL values";
- return;
- }
-
-
- nr->prev = NULL;
- nr->next = nrlists[index];
- if (nr->next)
- nr->next->prev = nr;
- nrlists[index] = nr;
-}
-
-/*************************************************************************/
-
/* Sets nc->display to newdisplay. If newdisplay is NULL, it will change
* it to the first alias in the list.
*/
@@ -576,32 +470,17 @@ void insert_requestnick(NickRequest * nr)
void change_core_display(NickCore * nc, const char *newdisplay)
{
- /*
- if (!newdisplay) {
- NickAlias *na;
-
- if (nc->aliases.count <= 0)
- return;
-
- na = static_cast<NickAlias *>(nc->aliases.list[0]);
- newdisplay = na->nick;
- }
- */
/* Log ... */
FOREACH_MOD(I_OnChangeCoreDisplay, OnChangeCoreDisplay(nc, newdisplay));
Alog() << Config.s_NickServ << ": changing " << nc->display << " nickname group display to " << newdisplay;
/* Remove the core from the list */
- if (nc->next)
- nc->next->prev = nc->prev;
- if (nc->prev)
- nc->prev->next = nc->next;
- else
- nclists[HASH(nc->display)] = nc->next;
+ NickCoreList.erase(nc->display);
delete [] nc->display;
nc->display = sstrdup(newdisplay);
- insert_core(nc);
+
+ NickCoreList[nc->display] = nc;
}
void change_core_display(NickCore * nc)
diff --git a/src/operserv.c b/src/operserv.c
index a5d0f0d61..672176050 100644
--- a/src/operserv.c
+++ b/src/operserv.c
@@ -136,9 +136,9 @@ void operserv(User * u, char *buf)
if (!(s = strtok(NULL, ""))) {
s = "";
}
- ircdproto->SendCTCP(findbot(Config.s_OperServ), u->nick.c_str(), "PING %s", s);
+ ircdproto->SendCTCP(OperServ, u->nick.c_str(), "PING %s", s);
} else {
- mod_run_cmd(Config.s_OperServ, u, OPERSERV, cmd);
+ mod_run_cmd(OperServ, u, cmd);
}
}
@@ -373,7 +373,7 @@ void expire_akills()
continue;
if (Config.WallAkillExpire)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "AKILL on %s@%s has expired",
+ ircdproto->SendGlobops(OperServ, "AKILL on %s@%s has expired",
ak->user, ak->host);
slist_delete(&akills, i);
}
@@ -426,9 +426,6 @@ int add_sgline(User * u, const char *mask, const char *by, time_t expires,
{
int deleted = 0, i;
SXLine *entry;
- User *u2, *next;
- char buf[BUFSIZE];
- *buf = '\0';
/* Checks whether there is an SGLINE that already covers
* the one we want to add, and whether there are SGLINEs
@@ -512,17 +509,20 @@ int add_sgline(User * u, const char *mask, const char *by, time_t expires,
ircdproto->SendSGLine(entry);
- if (Config.KillonSGline && !ircd->sglineenforce) {
+ if (Config.KillonSGline && !ircd->sglineenforce)
+ {
+ char buf[BUFSIZE];
snprintf(buf, (BUFSIZE - 1), "G-Lined: %s", entry->reason);
- u2 = firstuser();
- while (u2) {
- next = nextuser();
- if (!is_oper(u2)) {
- if (Anope::Match(u2->realname, entry->mask, false)) {
- kill_user(Config.ServerName, u2->nick, buf);
- }
+
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
+ {
+ User *u2 = it->second;
+ ++it;
+
+ if (!is_oper(u2) && Anope::Match(u2->realname, entry->mask, false))
+ {
+ kill_user(Config.ServerName, u2->nick, buf);
}
- u2 = next;
}
}
return deleted;
@@ -569,7 +569,7 @@ void expire_sglines()
continue;
if (Config.WallSGLineExpire)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "SGLINE on \2%s\2 has expired",
+ ircdproto->SendGlobops(OperServ, "SGLINE on \2%s\2 has expired",
sx->mask);
slist_delete(&sglines, i);
}
@@ -616,10 +616,7 @@ int add_sqline(User * u, const char *mask, const char *by, time_t expires,
const char *reason)
{
int deleted = 0, i;
- User *u2, *next;
SXLine *entry;
- char buf[BUFSIZE];
- *buf = '\0';
/* Checks whether there is an SQLINE that already covers
* the one we want to add, and whether there are SQLINEs
@@ -707,17 +704,20 @@ int add_sqline(User * u, const char *mask, const char *by, time_t expires,
sqline(entry->mask, entry->reason);
- if (Config.KillonSQline) {
+ if (Config.KillonSQline)
+ {
+ char buf[BUFSIZE];
snprintf(buf, (BUFSIZE - 1), "Q-Lined: %s", entry->reason);
- u2 = firstuser();
- while (u2) {
- next = nextuser();
- if (!is_oper(u2)) {
- if (Anope::Match(u2->nick, entry->mask, false)) {
- kill_user(Config.ServerName, u2->nick, buf);
- }
+
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
+ {
+ User *u2 = it->second;
+ ++it;
+
+ if (!is_oper(u2) && Anope::Match(u2->nick, entry->mask, false))
+ {
+ kill_user(Config.ServerName, u2->nick, buf);
}
- u2 = next;
}
}
@@ -797,7 +797,7 @@ void expire_sqlines()
continue;
if (Config.WallSQLineExpire)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "SQLINE on \2%s\2 has expired",
+ ircdproto->SendGlobops(OperServ, "SQLINE on \2%s\2 has expired",
sx->mask);
slist_delete(&sqlines, i);
@@ -974,7 +974,7 @@ void expire_szlines()
continue;
if (Config.WallSZLineExpire)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "SZLINE on \2%s\2 has expired",
+ ircdproto->SendGlobops(OperServ, "SZLINE on \2%s\2 has expired",
sx->mask);
slist_delete(&szlines, i);
}
diff --git a/src/process.c b/src/process.c
index ca9e2c069..7a015c64b 100644
--- a/src/process.c
+++ b/src/process.c
@@ -12,7 +12,6 @@
*/
#include "services.h"
-#include "messages.h"
#include "modules.h"
/*************************************************************************/
@@ -283,14 +282,12 @@ int split_buf(char *buf, const char ***argv, int colon_special)
void process(const std::string &buffer)
{
int retVal = 0;
- Message *current = NULL;
char source[64];
char cmd[64];
char buf[512]; /* Longest legal IRC command line */
char *s;
int ac; /* Parameters for the command */
const char **av;
- Message *m;
/* zero out the buffers before we do much else */
*buf = '\0';
@@ -346,19 +343,21 @@ void process(const std::string &buffer)
}
/* Do something with the message. */
- m = find_message(cmd);
- if (m) {
- if (m->func) {
- retVal = m->func(source, ac, av);
- if (retVal == MOD_CONT) {
- current = m->next;
- while (current && current->func && retVal == MOD_CONT) {
- retVal = current->func(source, ac, av);
- current = current->next;
- }
- }
+ std::vector<Message *> messages = FindMessage(cmd);
+
+ if (!messages.empty())
+ {
+ retVal = MOD_CONT;
+
+ for (std::vector<Message *>::iterator it = messages.begin(); retVal == MOD_CONT && it != messages.end(); ++it)
+ {
+ Message *m = *it;
+
+ if (m->func)
+ retVal = m->func(source, ac, av);
}
- } else
+ }
+ else
Alog(LOG_DEBUG) << "unknown message from server (" << buffer << ")";
/* Free argument list we created */
diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c
index 0e2706dba..744fc9608 100644
--- a/src/protocol/bahamut.c
+++ b/src/protocol/bahamut.c
@@ -265,7 +265,7 @@ class BahamutIRCdProto : public IRCDProto
/* nc_change was = 1, and there is no na->status */
void SendUnregisteredNick(User *u)
{
- BotInfo *bi = findbot(Config.s_NickServ);
+ BotInfo *bi = NickServ;
u->RemoveMode(bi, UMODE_REGISTERED);
ircdproto->SendMode(bi, u, "+d 1");
}
@@ -299,7 +299,7 @@ class BahamutIRCdProto : public IRCDProto
u->Account()->Shrink("authenticationtoken");
u->Account()->Extend("authenticationtoken", new ExtensibleItemPointerArray<char>(sstrdup(svidbuf)));
- BotInfo *bi = findbot(Config.s_NickServ);
+ BotInfo *bi = NickServ;
u->SetMode(bi, UMODE_REGISTERED);
ircdproto->SendMode(bi, u, "+d %s", svidbuf);
}
@@ -734,36 +734,34 @@ bool ChannelModeFlood::IsValid(const std::string &value)
return false;
}
-void moduleAddIRCDMsgs() {
- Message *m;
-
- /* now add the commands */
- m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
- m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
- m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m);
- m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m);
- m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m);
- m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m);
- m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m);
- m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m);
- m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m);
- m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m);
- m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m);
- m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m);
- m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m);
- m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m);
- m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m);
- m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m);
- m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m);
- m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m);
- m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m);
- m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m);
- m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m);
- m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m);
- m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m);
- m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m);
- m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m);
- m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m);
+void moduleAddIRCDMsgs()
+{
+ Anope::AddMessage("436", anope_event_436);
+ Anope::AddMessage("AWAY", anope_event_away);
+ Anope::AddMessage("JOIN", anope_event_join);
+ Anope::AddMessage("KICK", anope_event_kick);
+ Anope::AddMessage("KILL", anope_event_kill);
+ Anope::AddMessage("MODE", anope_event_mode);
+ Anope::AddMessage("MOTD", anope_event_motd);
+ Anope::AddMessage("NICK", anope_event_nick);
+ Anope::AddMessage("PART", anope_event_part);
+ Anope::AddMessage("PING", anope_event_ping);
+ Anope::AddMessage("PRIVMSG", anope_event_privmsg);
+ Anope::AddMessage("QUIT", anope_event_quit);
+ Anope::AddMessage("SERVER", anope_event_server);
+ Anope::AddMessage("SQUIT", anope_event_squit);
+ Anope::AddMessage("TOPIC", anope_event_topic);
+ Anope::AddMessage("WHOIS", anope_event_whois);
+ Anope::AddMessage("SVSMODE", anope_event_mode);
+ Anope::AddMessage("CAPAB", anope_event_capab);
+ Anope::AddMessage("CS", anope_event_cs);
+ Anope::AddMessage("HS", anope_event_hs);
+ Anope::AddMessage("MS", anope_event_ms);
+ Anope::AddMessage("NS", anope_event_ns);
+ Anope::AddMessage("OS", anope_event_os);
+ Anope::AddMessage("SJOIN", anope_event_sjoin);
+ Anope::AddMessage("ERROR", anope_event_error);
+ Anope::AddMessage("BURST", anope_event_burst);
}
static void AddModes()
diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c
index beaa73c97..70a344fc3 100644
--- a/src/protocol/inspircd11.c
+++ b/src/protocol/inspircd11.c
@@ -97,7 +97,7 @@ void inspircd_cmd_chghost(const char *nick, const char *vhost)
send_cmd(Config.s_OperServ, "CHGHOST %s %s", nick, vhost);
}
else
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGHOST not loaded!");
+ ircdproto->SendGlobops(OperServ, "CHGHOST not loaded!");
}
int anope_event_idle(const char *source, int ac, const char **av)
@@ -264,7 +264,7 @@ class InspIRCdProto : public IRCDProto
}
send_cmd(Config.s_OperServ, "CHGIDENT %s %s", nick, vIdent);
} else {
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGIDENT not loaded!");
+ ircdproto->SendGlobops(OperServ, "CHGIDENT not loaded!");
}
}
@@ -295,7 +295,7 @@ class InspIRCdProto : public IRCDProto
/* SVSMODE +- */
void SendUnregisteredNick(User *u)
{
- u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ u->RemoveMode(NickServ, UMODE_REGISTERED);
}
void SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param)
@@ -1080,13 +1080,13 @@ int anope_event_capab(const char *source, int ac, const char **av)
return MOD_STOP;
}
if (!has_svsholdmod) {
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "SVSHOLD missing, Usage disabled until module is loaded.");
+ ircdproto->SendGlobops(OperServ, "SVSHOLD missing, Usage disabled until module is loaded.");
}
if (!has_chghostmod) {
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGHOST missing, Usage disabled until module is loaded.");
+ ircdproto->SendGlobops(OperServ, "CHGHOST missing, Usage disabled until module is loaded.");
}
if (!has_chgidentmod) {
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGIDENT missing, Usage disabled until module is loaded.");
+ ircdproto->SendGlobops(OperServ, "CHGIDENT missing, Usage disabled until module is loaded.");
}
ircd->svshold = has_svsholdmod;
}
@@ -1102,40 +1102,39 @@ int anope_event_endburst(const char *source, int ac, const char **av)
}
-void moduleAddIRCDMsgs() {
- Message *m;
-
- m = createMessage("ENDBURST", anope_event_endburst); addCoreMessage(IRCD, m);
- m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
- m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
- m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m);
- m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m);
- m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m);
- m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m);
- m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m);
- m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m);
- m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m);
- m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m);
- m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m);
- m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m);
- m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m);
- m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m);
- m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m);
- m = createMessage("RSQUIT", anope_event_rsquit); addCoreMessage(IRCD,m);
- m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m);
- m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m);
- m = createMessage("SVSMODE", anope_event_mode) ;addCoreMessage(IRCD,m);
- m = createMessage("FHOST", anope_event_chghost); addCoreMessage(IRCD,m);
- m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m);
- m = createMessage("FNAME", anope_event_chgname); addCoreMessage(IRCD,m);
- m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m);
- m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m);
- m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m);
- m = createMessage("FJOIN", anope_event_fjoin); addCoreMessage(IRCD,m);
- m = createMessage("FMODE", anope_event_fmode); addCoreMessage(IRCD,m);
- m = createMessage("FTOPIC", anope_event_ftopic); addCoreMessage(IRCD,m);
- m = createMessage("OPERTYPE", anope_event_opertype); addCoreMessage(IRCD,m);
- m = createMessage("IDLE", anope_event_idle); addCoreMessage(IRCD,m);
+void moduleAddIRCDMsgs()
+{
+ Anope::AddMessage("ENDBURST", anope_event_endburst);
+ Anope::AddMessage("436", anope_event_436);
+ Anope::AddMessage("AWAY", anope_event_away);
+ Anope::AddMessage("JOIN", anope_event_join);
+ Anope::AddMessage("KICK", anope_event_kick);
+ Anope::AddMessage("KILL", anope_event_kill);
+ Anope::AddMessage("MODE", anope_event_mode);
+ Anope::AddMessage("MOTD", anope_event_motd);
+ Anope::AddMessage("NICK", anope_event_nick);
+ Anope::AddMessage("CAPAB",anope_event_capab);
+ Anope::AddMessage("PART", anope_event_part);
+ Anope::AddMessage("PING", anope_event_ping);
+ Anope::AddMessage("PRIVMSG", anope_event_privmsg);
+ Anope::AddMessage("QUIT", anope_event_quit);
+ Anope::AddMessage("SERVER", anope_event_server);
+ Anope::AddMessage("SQUIT", anope_event_squit);
+ Anope::AddMessage("RSQUIT", anope_event_rsquit);
+ Anope::AddMessage("TOPIC", anope_event_topic);
+ Anope::AddMessage("WHOIS", anope_event_whois);
+ Anope::AddMessage("SVSMODE", anope_event_mode);
+ Anope::AddMessage("FHOST", anope_event_chghost);
+ Anope::AddMessage("CHGIDENT", anope_event_chgident);
+ Anope::AddMessage("FNAME", anope_event_chgname);
+ Anope::AddMessage("SETHOST", anope_event_sethost);
+ Anope::AddMessage("SETIDENT", anope_event_setident);
+ Anope::AddMessage("SETNAME", anope_event_setname);
+ Anope::AddMessage("FJOIN", anope_event_fjoin);
+ Anope::AddMessage("FMODE", anope_event_fmode);
+ Anope::AddMessage("FTOPIC", anope_event_ftopic);
+ Anope::AddMessage("OPERTYPE", anope_event_opertype);
+ Anope::AddMessage("IDLE", anope_event_idle);
}
bool ChannelModeFlood::IsValid(const std::string &value)
diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp
index 5e20edb6f..dd416d032 100644
--- a/src/protocol/inspircd12.cpp
+++ b/src/protocol/inspircd12.cpp
@@ -94,11 +94,11 @@ void inspircd_cmd_chghost(const char *nick, const char *vhost)
{
if (has_chghostmod != 1)
{
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGHOST not loaded!");
+ ircdproto->SendGlobops(OperServ, "CHGHOST not loaded!");
return;
}
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi->uid, "CHGHOST %s %s", nick, vhost);
}
@@ -125,7 +125,7 @@ class InspIRCdProto : public IRCDProto
{
void SendAkillDel(Akill *ak)
{
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi->uid, "GLINE %s@%s", ak->user, ak->host);
}
@@ -153,7 +153,7 @@ class InspIRCdProto : public IRCDProto
time_t timeleft = ak->expires - time(NULL);
if (timeleft > 172800 || !ak->expires)
timeleft = 172800;
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi->uid, "ADDLINE G %s@%s %s %ld %ld :%s", ak->user, ak->host, ak->by, static_cast<long>(time(NULL)), static_cast<long>(timeleft), ak->reason);
}
@@ -264,11 +264,11 @@ class InspIRCdProto : public IRCDProto
{
if (has_chgidentmod == 0)
{
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGIDENT not loaded!");
+ ircdproto->SendGlobops(OperServ, "CHGIDENT not loaded!");
}
else
{
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi->uid, "CHGIDENT %s %s", nick, vIdent);
}
}
@@ -276,14 +276,14 @@ class InspIRCdProto : public IRCDProto
/* SVSHOLD - set */
void SendSVSHold(const char *nick)
{
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi->uid, "SVSHOLD %s %u :%s", nick, static_cast<unsigned>(Config.NSReleaseTimeout), "Being held for registered user");
}
/* SVSHOLD - release */
void SendSVSHoldDel(const char *nick)
{
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi->uid, "SVSHOLD %s", nick);
}
@@ -302,7 +302,7 @@ class InspIRCdProto : public IRCDProto
/* SVSMODE -r */
void SendUnregisteredNick(User *u)
{
- u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ u->RemoveMode(NickServ, UMODE_REGISTERED);
}
void SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param)
@@ -362,7 +362,7 @@ class InspIRCdProto : public IRCDProto
if (!u->Account())
return;
- u->SetMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ u->SetMode(NickServ, UMODE_REGISTERED);
}
} ircd_proto;
@@ -850,7 +850,7 @@ int anope_event_uid(const char *source, int ac, const char **av)
{
validate_user(user);
if (user->HasMode(UMODE_REGISTERED))
- user->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ user->RemoveMode(NickServ, UMODE_REGISTERED);
}
user = NULL;
@@ -1284,13 +1284,13 @@ int anope_event_capab(const char *source, int ac, const char **av)
return MOD_STOP;
}
if (!has_svsholdmod) {
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "SVSHOLD missing, Usage disabled until module is loaded.");
+ ircdproto->SendGlobops(OperServ, "SVSHOLD missing, Usage disabled until module is loaded.");
}
if (!has_chghostmod) {
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGHOST missing, Usage disabled until module is loaded.");
+ ircdproto->SendGlobops(OperServ, "CHGHOST missing, Usage disabled until module is loaded.");
}
if (!has_chgidentmod) {
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGIDENT missing, Usage disabled until module is loaded.");
+ ircdproto->SendGlobops(OperServ, "CHGIDENT missing, Usage disabled until module is loaded.");
}
ircd->svshold = has_svsholdmod;
}
@@ -1319,7 +1319,7 @@ int anope_event_endburst(const char *source, int ac, const char **av)
{
validate_user(u);
if (u->HasMode(UMODE_REGISTERED))
- u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ u->RemoveMode(NickServ, UMODE_REGISTERED);
}
Alog() << "Processed ENDBURST for " << s->GetName();
@@ -1328,43 +1328,42 @@ int anope_event_endburst(const char *source, int ac, const char **av)
return MOD_CONT;
}
-void moduleAddIRCDMsgs() {
- Message *m;
-
- m = createMessage("ENDBURST", anope_event_endburst); addCoreMessage(IRCD, m);
- m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
- m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
- m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m);
- m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m);
- m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m);
- m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m);
- m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m);
- m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m);
- m = createMessage("UID", anope_event_uid); addCoreMessage(IRCD,m);
- m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m);
- m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m);
- m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m);
- m = createMessage("TIME", anope_event_time); addCoreMessage(IRCD,m);
- m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m);
- m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m);
- m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m);
- m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m);
- m = createMessage("RSQUIT", anope_event_rsquit); addCoreMessage(IRCD,m);
- m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m);
- m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m);
- m = createMessage("SVSMODE", anope_event_mode) ;addCoreMessage(IRCD,m);
- m = createMessage("FHOST", anope_event_chghost); addCoreMessage(IRCD,m);
- m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m);
- m = createMessage("FNAME", anope_event_chgname); addCoreMessage(IRCD,m);
- m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m);
- m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m);
- m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m);
- m = createMessage("FJOIN", anope_event_fjoin); addCoreMessage(IRCD,m);
- m = createMessage("FMODE", anope_event_fmode); addCoreMessage(IRCD,m);
- m = createMessage("FTOPIC", anope_event_ftopic); addCoreMessage(IRCD,m);
- m = createMessage("OPERTYPE", anope_event_opertype); addCoreMessage(IRCD,m);
- m = createMessage("IDLE", anope_event_idle); addCoreMessage(IRCD,m);
- m = createMessage("METADATA", anope_event_metadata); addCoreMessage(IRCD,m);
+void moduleAddIRCDMsgs()
+{
+ Anope::AddMessage("ENDBURST", anope_event_endburst);
+ Anope::AddMessage("436", anope_event_436);
+ Anope::AddMessage("AWAY", anope_event_away);
+ Anope::AddMessage("JOIN", anope_event_join);
+ Anope::AddMessage("KICK", anope_event_kick);
+ Anope::AddMessage("KILL", anope_event_kill);
+ Anope::AddMessage("MODE", anope_event_mode);
+ Anope::AddMessage("MOTD", anope_event_motd);
+ Anope::AddMessage("NICK", anope_event_nick);
+ Anope::AddMessage("UID", anope_event_uid);
+ Anope::AddMessage("CAPAB", anope_event_capab);
+ Anope::AddMessage("PART", anope_event_part);
+ Anope::AddMessage("PING", anope_event_ping);
+ Anope::AddMessage("TIME", anope_event_time);
+ Anope::AddMessage("PRIVMSG", anope_event_privmsg);
+ Anope::AddMessage("QUIT", anope_event_quit);
+ Anope::AddMessage("SERVER", anope_event_server);
+ Anope::AddMessage("SQUIT", anope_event_squit);
+ Anope::AddMessage("RSQUIT", anope_event_rsquit);
+ Anope::AddMessage("TOPIC", anope_event_topic);
+ Anope::AddMessage("WHOIS", anope_event_whois);
+ Anope::AddMessage("SVSMODE", anope_event_mode);
+ Anope::AddMessage("FHOST", anope_event_chghost);
+ Anope::AddMessage("CHGIDENT", anope_event_chgident);
+ Anope::AddMessage("FNAME", anope_event_chgname);
+ Anope::AddMessage("SETHOST", anope_event_sethost);
+ Anope::AddMessage("SETIDENT", anope_event_setident);
+ Anope::AddMessage("SETNAME", anope_event_setname);
+ Anope::AddMessage("FJOIN", anope_event_fjoin);
+ Anope::AddMessage("FMODE", anope_event_fmode);
+ Anope::AddMessage("FTOPIC", anope_event_ftopic);
+ Anope::AddMessage("OPERTYPE", anope_event_opertype);
+ Anope::AddMessage("IDLE", anope_event_idle);
+ Anope::AddMessage("METADATA", anope_event_metadata);
}
bool ChannelModeFlood::IsValid(const std::string &value)
diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c
index 39d01585e..4b4b732cd 100644
--- a/src/protocol/ratbox.c
+++ b/src/protocol/ratbox.c
@@ -145,19 +145,19 @@ class RatboxProto : public IRCDTS6Proto
void SendSGLineDel(SXLine *sx)
{
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi ? bi->uid : Config.s_OperServ, "UNXLINE * %s", sx->mask);
}
void SendSGLine(SXLine *sx)
{
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi ? bi->uid : Config.s_OperServ, "XLINE * %s 0 :%s", sx->mask, sx->reason);
}
void SendAkillDel(Akill *ak)
{
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi ? bi->uid : Config.s_OperServ, "UNKLINE * %s %s", ak->user, ak->host);
}
@@ -175,7 +175,7 @@ class RatboxProto : public IRCDTS6Proto
void SendAkill(Akill *ak)
{
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi ? bi->uid : Config.s_OperServ, "KLINE * %ld %s %s :%s", static_cast<long>(ak->expires - time(NULL)), ak->user, ak->host, ak->reason);
}
@@ -811,33 +811,31 @@ int anope_event_error(const char *source, int ac, const char **av)
void moduleAddIRCDMsgs()
{
- Message *m;
-
- m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
- m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
- m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m);
- m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m);
- m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m);
- m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m);
- m = createMessage("TMODE", anope_event_tmode); addCoreMessage(IRCD,m);
- m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m);
- m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m);
- m = createMessage("BMASK", anope_event_bmask); addCoreMessage(IRCD,m);
- m = createMessage("UID", anope_event_nick); addCoreMessage(IRCD,m);
- m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m);
- m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m);
- m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m);
- m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m);
- m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m);
- m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m);
- m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m);
- m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m);
- m = createMessage("TB", anope_event_tburst); addCoreMessage(IRCD,m);
- m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m);
- m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m);
- m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m);
- m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m);
- m = createMessage("SID", anope_event_sid); addCoreMessage(IRCD,m);
+ Anope::AddMessage("436", anope_event_436);
+ Anope::AddMessage("AWAY", anope_event_away);
+ Anope::AddMessage("JOIN", anope_event_join);
+ Anope::AddMessage("KICK", anope_event_kick);
+ Anope::AddMessage("KILL", anope_event_kill);
+ Anope::AddMessage("MODE", anope_event_mode);
+ Anope::AddMessage("TMODE", anope_event_tmode);
+ Anope::AddMessage("MOTD", anope_event_motd);
+ Anope::AddMessage("NICK", anope_event_nick);
+ Anope::AddMessage("BMASK", anope_event_bmask);
+ Anope::AddMessage("UID", anope_event_nick);
+ Anope::AddMessage("PART", anope_event_part);
+ Anope::AddMessage("PASS", anope_event_pass);
+ Anope::AddMessage("PING", anope_event_ping);
+ Anope::AddMessage("PRIVMSG", anope_event_privmsg);
+ Anope::AddMessage("QUIT", anope_event_quit);
+ Anope::AddMessage("SERVER", anope_event_server);
+ Anope::AddMessage("SQUIT", anope_event_squit);
+ Anope::AddMessage("TOPIC", anope_event_topic);
+ Anope::AddMessage("TB", anope_event_tburst);
+ Anope::AddMessage("WHOIS", anope_event_whois);
+ Anope::AddMessage("CAPAB", anope_event_capab);
+ Anope::AddMessage("SJOIN", anope_event_sjoin);
+ Anope::AddMessage("ERROR", anope_event_error);
+ Anope::AddMessage("SID", anope_event_sid);
}
static void AddModes()
diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c
index 432044c51..d63d2183a 100644
--- a/src/protocol/unreal32.c
+++ b/src/protocol/unreal32.c
@@ -145,7 +145,7 @@ class UnrealIRCdProto : public IRCDProto
void SendVhostDel(User *u)
{
- BotInfo *bi = findbot(Config.s_HostServ);
+ BotInfo *bi = HostServ;
u->RemoveMode(bi, UMODE_CLOAK);
u->RemoveMode(bi, UMODE_VHOST);
ModeManager::ProcessModes();
@@ -418,14 +418,14 @@ class UnrealIRCdProto : public IRCDProto
u->Account()->Shrink("authenticationtoken");
u->Account()->Extend("authenticationtoken", new ExtensibleItemPointerArray<char>(sstrdup(svidbuf)));
- BotInfo *bi = findbot(Config.s_NickServ);
+ BotInfo *bi = NickServ;
u->SetMode(bi, UMODE_REGISTERED);
ircdproto->SendMode(bi, u, "+d %s", svidbuf);
}
void SendUnregisteredNick(User *u)
{
- BotInfo *bi = findbot(Config.s_NickServ);
+ BotInfo *bi = NickServ;
u->RemoveMode(bi, UMODE_REGISTERED);
ircdproto->SendMode(bi, u, "+d 1");
}
@@ -1185,75 +1185,74 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
return MOD_CONT;
}
-void moduleAddIRCDMsgs() {
- Message *m;
-
- m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
- m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
- m = createMessage("6", anope_event_away); addCoreMessage(IRCD,m);
- m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m);
- m = createMessage("C", anope_event_join); addCoreMessage(IRCD,m);
- m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m);
- m = createMessage("H", anope_event_kick); addCoreMessage(IRCD,m);
- m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m);
- m = createMessage(".", anope_event_kill); addCoreMessage(IRCD,m);
- m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m);
- m = createMessage("G", anope_event_gmode); addCoreMessage(IRCD,m);
- m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m);
- m = createMessage("F", anope_event_motd); addCoreMessage(IRCD,m);
- m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m);
- m = createMessage("&", anope_event_nick); addCoreMessage(IRCD,m);
- m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m);
- m = createMessage("D", anope_event_part); addCoreMessage(IRCD,m);
- m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m);
- m = createMessage("8", anope_event_ping); addCoreMessage(IRCD,m);
- m = createMessage("PONG", anope_event_pong); addCoreMessage(IRCD,m);
- m = createMessage("9", anope_event_pong); addCoreMessage(IRCD,m);
- m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m);
- m = createMessage("!", anope_event_privmsg); addCoreMessage(IRCD,m);
- m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m);
- m = createMessage(",", anope_event_quit); addCoreMessage(IRCD,m);
- m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m);
- m = createMessage("'", anope_event_server); addCoreMessage(IRCD,m);
- m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m);
- m = createMessage("-", anope_event_squit); addCoreMessage(IRCD,m);
- m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m);
- m = createMessage(")", anope_event_topic); addCoreMessage(IRCD,m);
- m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m);
- m = createMessage("n", anope_event_mode); addCoreMessage(IRCD,m);
- m = createMessage("SVS2MODE", anope_event_mode); addCoreMessage(IRCD,m);
- m = createMessage("v", anope_event_mode); addCoreMessage(IRCD,m);
- m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m);
- m = createMessage("#", anope_event_whois); addCoreMessage(IRCD,m);
- m = createMessage("PROTOCTL", anope_event_capab); addCoreMessage(IRCD,m);
- m = createMessage("_", anope_event_capab); addCoreMessage(IRCD,m);
- m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m);
- m = createMessage("AL", anope_event_chghost); addCoreMessage(IRCD,m);
- m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m);
- m = createMessage("AZ", anope_event_chgident); addCoreMessage(IRCD,m);
- m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m);
- m = createMessage("BK", anope_event_chgname); addCoreMessage(IRCD,m);
- m = createMessage("NETINFO", anope_event_netinfo); addCoreMessage(IRCD,m);
- m = createMessage("AO", anope_event_netinfo); addCoreMessage(IRCD,m);
- m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m);
- m = createMessage("AA", anope_event_sethost); addCoreMessage(IRCD,m);
- m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m);
- m = createMessage("AD", anope_event_setident); addCoreMessage(IRCD,m);
- m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m);
- m = createMessage("AE", anope_event_setname); addCoreMessage(IRCD,m);
- m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m);
- m = createMessage("5", anope_event_error); addCoreMessage(IRCD,m);
- m = createMessage("UMODE2", anope_event_umode2); addCoreMessage(IRCD,m);
- m = createMessage("|", anope_event_umode2); addCoreMessage(IRCD,m);
- m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m);
- m = createMessage("~", anope_event_sjoin); addCoreMessage(IRCD,m);
- m = createMessage("SDESC", anope_event_sdesc); addCoreMessage(IRCD,m);
- m = createMessage("AG", anope_event_sdesc); addCoreMessage(IRCD,m);
+void moduleAddIRCDMsgs()
+{
+ Anope::AddMessage("436", anope_event_436);
+ Anope::AddMessage("AWAY", anope_event_away);
+ Anope::AddMessage("6", anope_event_away);
+ Anope::AddMessage("JOIN", anope_event_join);
+ Anope::AddMessage("C", anope_event_join);
+ Anope::AddMessage("KICK", anope_event_kick);
+ Anope::AddMessage("H", anope_event_kick);
+ Anope::AddMessage("KILL", anope_event_kill);
+ Anope::AddMessage(".", anope_event_kill);
+ Anope::AddMessage("MODE", anope_event_mode);
+ Anope::AddMessage("G", anope_event_gmode);
+ Anope::AddMessage("MOTD", anope_event_motd);
+ Anope::AddMessage("F", anope_event_motd);
+ Anope::AddMessage("NICK", anope_event_nick);
+ Anope::AddMessage("&", anope_event_nick);
+ Anope::AddMessage("PART", anope_event_part);
+ Anope::AddMessage("D", anope_event_part);
+ Anope::AddMessage("PING", anope_event_ping);
+ Anope::AddMessage("8", anope_event_ping);
+ Anope::AddMessage("PONG", anope_event_pong);
+ Anope::AddMessage("9", anope_event_pong);
+ Anope::AddMessage("PRIVMSG", anope_event_privmsg);
+ Anope::AddMessage("!", anope_event_privmsg);
+ Anope::AddMessage("QUIT", anope_event_quit);
+ Anope::AddMessage(",", anope_event_quit);
+ Anope::AddMessage("SERVER", anope_event_server);
+ Anope::AddMessage("'", anope_event_server);
+ Anope::AddMessage("SQUIT", anope_event_squit);
+ Anope::AddMessage("-", anope_event_squit);
+ Anope::AddMessage("TOPIC", anope_event_topic);
+ Anope::AddMessage(")", anope_event_topic);
+ Anope::AddMessage("SVSMODE", anope_event_mode);
+ Anope::AddMessage("n", anope_event_mode);
+ Anope::AddMessage("SVS2MODE", anope_event_mode);
+ Anope::AddMessage("v", anope_event_mode);
+ Anope::AddMessage("WHOIS", anope_event_whois);
+ Anope::AddMessage("#", anope_event_whois);
+ Anope::AddMessage("PROTOCTL", anope_event_capab);
+ Anope::AddMessage("_", anope_event_capab);
+ Anope::AddMessage("CHGHOST", anope_event_chghost);
+ Anope::AddMessage("AL", anope_event_chghost);
+ Anope::AddMessage("CHGIDENT", anope_event_chgident);
+ Anope::AddMessage("AZ", anope_event_chgident);
+ Anope::AddMessage("CHGNAME", anope_event_chgname);
+ Anope::AddMessage("BK", anope_event_chgname);
+ Anope::AddMessage("NETINFO", anope_event_netinfo);
+ Anope::AddMessage("AO", anope_event_netinfo);
+ Anope::AddMessage("SETHOST", anope_event_sethost);
+ Anope::AddMessage("AA", anope_event_sethost);
+ Anope::AddMessage("SETIDENT", anope_event_setident);
+ Anope::AddMessage("AD", anope_event_setident);
+ Anope::AddMessage("SETNAME", anope_event_setname);
+ Anope::AddMessage("AE", anope_event_setname);
+ Anope::AddMessage("ERROR", anope_event_error);
+ Anope::AddMessage("5", anope_event_error);
+ Anope::AddMessage("UMODE2", anope_event_umode2);
+ Anope::AddMessage("|", anope_event_umode2);
+ Anope::AddMessage("SJOIN", anope_event_sjoin);
+ Anope::AddMessage("~", anope_event_sjoin);
+ Anope::AddMessage("SDESC", anope_event_sdesc);
+ Anope::AddMessage("AG", anope_event_sdesc);
/* The non token version of these is in messages.c */
- m = createMessage("2", m_stats); addCoreMessage(IRCD,m);
- m = createMessage(">", m_time); addCoreMessage(IRCD,m);
- m = createMessage("+", m_version); addCoreMessage(IRCD,m);
+ Anope::AddMessage("2", m_stats);
+ Anope::AddMessage(">", m_time);
+ Anope::AddMessage("+", m_version);
}
/* Borrowed part of this check from UnrealIRCd */
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 39feed45a..1da77d912 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -23,7 +23,6 @@ ChannelInfo::ChannelInfo(const std::string &chname)
if (chname.empty())
throw CoreException("Empty channel passed to ChannelInfo constructor");
- next = prev = NULL;
founder = successor = NULL;
desc = url = email = last_topic = forbidby = forbidreason = NULL;
last_topic_time = 0;
@@ -61,7 +60,8 @@ ChannelInfo::ChannelInfo(const std::string &chname)
this->ttb[i] = 0;
reset_levels(this);
- alpha_insert_chan(this);
+
+ RegisteredChannelList[this->name.c_str()] = this;
}
/** Default destructor, cleans up the channel complete and removes it from the internal list
@@ -84,12 +84,8 @@ ChannelInfo::~ChannelInfo()
this->c->ci = NULL;
}
- if (this->next)
- this->next->prev = this->prev;
- if (this->prev)
- this->prev->next = this->next;
- else
- chanlists[static_cast<unsigned char>(tolower(this->name[1]))] = this->next;
+ RegisteredChannelList.erase(this->name.c_str());
+
if (this->desc)
delete [] this->desc;
if (this->url)
@@ -654,7 +650,7 @@ bool ChannelInfo::CheckKick(User *user)
}
/* Join ChanServ */
- ircdproto->SendJoin(findbot(Config.s_ChanServ), this->name.c_str(), this->c->creation_time);
+ ircdproto->SendJoin(ChanServ, this->name.c_str(), this->c->creation_time);
/* Set a timer for this channel to part ChanServ later */
new ChanServTimer(this->c);
diff --git a/src/servers.cpp b/src/servers.cpp
index 77876372e..f058274d4 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -80,7 +80,7 @@ Server::Server(Server *uplink, const std::string &name, unsigned int hops, const
if (LogChan && ircd->join2msg)
{
/* XXX might desync */
- ircdproto->SendJoin(findbot(Config.s_GlobalNoticer), Config.LogChannel, time(NULL));
+ ircdproto->SendJoin(Global, Config.LogChannel, time(NULL));
}
}
}
@@ -93,12 +93,12 @@ Server::~Server()
if (Capab.HasFlag(CAPAB_NOQUIT) || Capab.HasFlag(CAPAB_QS))
{
- User *nextu;
time_t t = time(NULL);
- for (User *u = firstuser(); u; u = nextu)
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
{
- nextu = nextuser();
+ User *u = it->second;
+ ++it;
if (u->server == this)
{
@@ -402,7 +402,7 @@ void do_squit(const char *source, int ac, const char **av)
if (s->HasFlag(SERVER_JUPED))
{
snprintf(buf, BUFSIZE, "Received SQUIT for juped server %s", s->GetName().c_str());
- ircdproto->SendGlobops(findbot(Config.s_OperServ), buf);
+ ircdproto->SendGlobops(OperServ, buf);
}
snprintf(buf, sizeof(buf), "%s %s", s->GetName().c_str(), s->GetUplink()->GetName().c_str());
diff --git a/src/sessions.c b/src/sessions.c
index 0891bec93..cfd81bc7b 100644
--- a/src/sessions.c
+++ b/src/sessions.c
@@ -50,14 +50,7 @@
/*************************************************************************/
-/* I'm sure there is a better way to hash the list of hosts for which we are
- * storing session information. This should be sufficient for the mean time.
- * -TheShadow */
-
-#define HASH(host) (((host)[0]&31)<<5 | ((host)[1]&31))
-
-Session *sessionlist[1024];
-int32 nsessions = 0;
+session_map SessionList;
Exception *exceptions = NULL;
int16 nexceptions = 0;
@@ -68,19 +61,17 @@ int16 nexceptions = 0;
void get_session_stats(long *nrec, long *memuse)
{
- Session *session;
- long mem;
- int i;
+ long mem = sizeof(Session) * SessionList.size();
- mem = sizeof(Session) * nsessions;
- for (i = 0; i < 1024; i++) {
- for (session = sessionlist[i]; session; session = session->next) {
- mem += strlen(session->host) + 1;
- }
+ for (session_map::const_iterator it = SessionList.begin(); it != SessionList.end(); ++it)
+ {
+ Session *session = it->second;
+
+ mem += strlen(session->host) + 1;
}
- *nrec = nsessions;
*memuse = mem;
+ *nrec = SessionList.size();
}
void get_exception_stats(long *nrec, long *memuse)
@@ -101,23 +92,12 @@ void get_exception_stats(long *nrec, long *memuse)
/********************* Internal Session Functions ************************/
/*************************************************************************/
-Session *findsession(const char *host)
+Session *findsession(const std::string &host)
{
- Session *session;
- int i;
-
- if (!host) {
- return NULL;
- }
-
- for (i = 0; i < 1024; i++) {
- for (session = sessionlist[i]; session; session = session->next) {
- if (stricmp(host, session->host) == 0) {
- return session;
- }
- }
- }
+ session_map::const_iterator it = SessionList.find(host);
+ if (it != SessionList.end())
+ return it->second;
return NULL;
}
@@ -128,7 +108,7 @@ Session *findsession(const char *host)
int add_session(const char *nick, const char *host, char *hostip)
{
- Session *session, **list;
+ Session *session;
Exception *exception;
int sessionlimit = 0;
@@ -141,9 +121,9 @@ int add_session(const char *nick, const char *host, char *hostip)
if (sessionlimit != 0 && session->count >= sessionlimit) {
if (Config.SessionLimitExceeded)
- ircdproto->SendMessage(findbot(Config.s_OperServ), nick, Config.SessionLimitExceeded, host);
+ ircdproto->SendMessage(OperServ, nick, Config.SessionLimitExceeded, host);
if (Config.SessionLimitDetailsLoc)
- ircdproto->SendMessage(findbot(Config.s_OperServ), nick, "%s", Config.SessionLimitDetailsLoc);
+ ircdproto->SendMessage(OperServ, nick, "%s", Config.SessionLimitDetailsLoc);
/* Previously on IRCds that send a QUIT (InspIRCD) when a user is killed, the session for a host was
* decremented in do_quit, which caused problems and fixed here
@@ -161,7 +141,7 @@ int add_session(const char *nick, const char *host, char *hostip)
snprintf(akillmask, sizeof(akillmask), "*@%s", host);
add_akill(NULL, akillmask, Config.s_OperServ,
time(NULL) + Config.SessionAutoKillExpiry, "Session limit exceeded");
- ircdproto->SendGlobops(findbot(Config.s_OperServ),
+ ircdproto->SendGlobops(OperServ,
"Added a temporary AKILL for \2%s\2 due to excessive connections", akillmask);
}
return 0;
@@ -171,25 +151,18 @@ int add_session(const char *nick, const char *host, char *hostip)
}
}
- nsessions++;
session = new Session;
session->host = sstrdup(host);
- list = &sessionlist[HASH(session->host)];
- session->prev = NULL;
- session->next = *list;
- if (*list)
- (*list)->prev = session;
- *list = session;
session->count = 1;
session->hits = 0;
+ SessionList[session->host] = session;
+
return 1;
}
void del_session(const char *host)
{
- Session *session;
-
if (!Config.LimitSessions) {
Alog(LOG_DEBUG) << "del_session called when LimitSessions is disabled";
return;
@@ -202,12 +175,12 @@ void del_session(const char *host)
Alog(LOG_DEBUG_2) << "del_session() called";
- session = findsession(host);
+ Session *session = findsession(host);
if (!session) {
if (debug)
{
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "WARNING: Tried to delete non-existant session: \2%s", host);
+ ircdproto->SendGlobops(OperServ, "WARNING: Tried to delete non-existant session: \2%s", host);
Alog(LOG_DEBUG) << "session: Tried to delete non-existant session: " << host;
}
return;
@@ -218,20 +191,13 @@ void del_session(const char *host)
return;
}
- if (session->prev)
- session->prev->next = session->next;
- else
- sessionlist[HASH(session->host)] = session->next;
- if (session->next)
- session->next->prev = session->prev;
+ SessionList.erase(session->host);
Alog(LOG_DEBUG_2) << "del_session(): free session structure";
delete [] session->host;
delete session;
- nsessions--;
-
Alog(LOG_DEBUG_2) << "del_session() done";
}
@@ -249,7 +215,7 @@ void expire_exceptions()
if (exceptions[i].expires == 0 || exceptions[i].expires > now)
continue;
if (Config.WallExceptionExpire)
- ircdproto->SendGlobops(findbot(Config.s_OperServ),
+ ircdproto->SendGlobops(OperServ,
"Session limit exception for %s has expired.",
exceptions[i].mask);
delete [] exceptions[i].mask;
diff --git a/src/users.c b/src/users.c
index 744177e5a..e89d09ad3 100644
--- a/src/users.c
+++ b/src/users.c
@@ -15,10 +15,11 @@
#include "modules.h"
#include "language.h"
-#define HASH(nick) (((nick)[0]&31)<<5 | ((nick)[1]&31))
-User *userlist[1024];
-
-#define HASH2(nick) (((nick)[0]&31)<<5 | ((nick)[1]&31))
+/* Hash maps used for users. Note UserListByUID will not be used on non-TS6 IRCds, and should never
+ * be assumed to have users
+ */
+user_map UserListByNick;
+user_uid_map UserListByUID;
int32 opcnt = 0;
uint32 usercnt = 0, maxusercnt = 0;
@@ -29,16 +30,12 @@ time_t maxusertime;
User::User(const std::string &snick, const std::string &suid)
{
- User **list;
-
if (snick.empty())
throw "what the craq, empty nick passed to constructor";
// XXX: we should also duplicate-check here.
/* we used to do this by calloc, no more. */
- this->next = NULL;
- this->prev = NULL;
host = hostip = vhost = realname = NULL;
server = NULL;
nc = NULL;
@@ -47,13 +44,10 @@ User::User(const std::string &snick, const std::string &suid)
this->nick = snick;
this->uid = suid;
- list = &userlist[HASH(this->nick)];
- this->next = *list;
- if (*list)
- (*list)->prev = this;
-
- *list = this;
+ UserListByNick[snick.c_str()] = this;
+ if (!suid.empty())
+ UserListByUID[suid] = this;
this->nc = NULL;
@@ -72,8 +66,6 @@ User::User(const std::string &snick, const std::string &suid)
void User::SetNewNick(const std::string &newnick)
{
- User **list;
-
/* Sanity check to make sure we don't segfault */
if (newnick.empty())
{
@@ -82,22 +74,11 @@ void User::SetNewNick(const std::string &newnick)
Alog(LOG_DEBUG) << this->nick << " changed nick to " << newnick;
- if (this->prev)
- this->prev->next = this->next;
- else
- userlist[HASH(this->nick)] = this->next;
-
- if (this->next)
- this->next->prev = this->prev;
+ UserListByNick.erase(this->nick.c_str());
this->nick = newnick;
- list = &userlist[HASH(this->nick)];
- this->next = *list;
- this->prev = NULL;
- if (*list)
- (*list)->prev = this;
- *list = this;
+ UserListByNick[this->nick.c_str()] = this;
OnAccess = false;
NickAlias *na = findnick(this->nick);
@@ -247,13 +228,10 @@ User::~User()
{
this->chans.front()->chan->DeleteUser(this);
}
-
- if (this->prev)
- this->prev->next = this->next;
- else
- userlist[HASH(this->nick)] = this->next;
- if (this->next)
- this->next->prev = this->prev;
+
+ UserListByNick.erase(this->nick.c_str());
+ if (!this->uid.empty())
+ UserListByUID.erase(this->uid);
NickAlias *na = findnick(this->nick);
if (na)
@@ -529,58 +507,6 @@ void User::UpdateHost()
}
}
-/*************************************************************************/
-
-/* Return statistics. Pointers are assumed to be valid. */
-
-void get_user_stats(long *nusers, long *memuse)
-{
- long count = 0, mem = 0;
- int i;
- User *user;
-
- for (i = 0; i < 1024; i++) {
- for (user = userlist[i]; user; user = user->next) {
- count++;
- mem += sizeof(*user);
- if (user->host)
- mem += strlen(user->host) + 1;
- if (ircd->vhost) {
- if (user->vhost)
- mem += strlen(user->vhost) + 1;
- }
- if (user->realname)
- mem += strlen(user->realname) + 1;
- mem += user->server->GetName().length() + 1;
- mem += (sizeof(ChannelContainer) * user->chans.size());
- }
- }
- *nusers = count;
- *memuse = mem;
-}
-
-/*************************************************************************/
-
-/* Find a user by nick. Return NULL if user could not be found. */
-
-User *finduser(const std::string &nick)
-{
- User *user;
-
- Alog(LOG_DEBUG_3) << "finduser("<< nick << ")";
-
- if (isdigit(nick[0]) && ircd->ts6)
- return find_byuid(nick);
-
- ci::string ci_nick(nick.c_str());
-
- user = userlist[HASH(nick)];
- while (user && ci_nick != user->nick)
- user = user->next;
- Alog(LOG_DEBUG_3) << "finduser(" << nick << ") -> " << static_cast<void *>(user);
- return user;
-}
-
/** Check if the user has a mode
* @param Name Mode name
* @return true or false
@@ -768,80 +694,78 @@ bool User::IsProtected() const
/*************************************************************************/
-/* Iterate over all users in the user list. Return NULL at end of list. */
+void get_user_stats(long *nusers, long *memuse)
+{
+ long count = 0, mem = 0;
+
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ {
+ User *user = it->second;
-static User *current;
-static int next_index;
+ count++;
+ mem += sizeof(*user);
+ if (user->host)
+ mem += strlen(user->host) + 1;
+ if (ircd->vhost)
+ {
+ if (user->vhost)
+ mem += strlen(user->vhost) + 1;
+ }
+ if (user->realname)
+ mem += strlen(user->realname) + 1;
+ mem += user->server->GetName().length() + 1;
+ mem += (sizeof(ChannelContainer) * user->chans.size());
+ }
+ *nusers = count;
+ *memuse = mem;
+}
-User *firstuser()
+User *finduser(const char *nick)
{
- next_index = 0;
- current = NULL;
- while (next_index < 1024 && current == NULL)
- current = userlist[next_index++];
- Alog(LOG_DEBUG) << "firstuser() returning " << (current ? current->nick : "NULL (end of list)");
- return current;
+ return finduser(ci::string(nick));
}
-User *nextuser()
+User *finduser(const std::string &nick)
{
- if (current)
- current = current->next;
- if (!current && next_index < 1024) {
- while (next_index < 1024 && current == NULL)
- current = userlist[next_index++];
- }
- Alog(LOG_DEBUG) << "nextuser() returning " << (current ? current->nick : "NULL (end of list)");
- return current;
+ return finduser(ci::string(nick.c_str()));
}
-User *find_byuid(const std::string &uid)
+User *finduser(const ci::string &nick)
{
- User *u, *next;
+ Alog(LOG_DEBUG_3) << "finduser("<< nick << ")";
- u = first_uid();
- while (u) {
- next = next_uid();
- if (u->GetUID() == uid) {
- return u;
- }
- u = next;
- }
+ if (isdigit(nick[0]) && ircd->ts6)
+ return find_byuid(nick);
+
+ user_map::const_iterator it = UserListByNick.find(nick.c_str());
+
+ if (it != UserListByNick.end())
+ return it->second;
return NULL;
}
-static User *current_uid;
-static int next_index_uid;
+User *find_byuid(const char *uid)
+{
+ return find_byuid(std::string(uid));
+}
-User *first_uid()
+User *find_byuid(const ci::string &uid)
{
- next_index_uid = 0;
- current_uid = NULL;
- while (next_index_uid < 1024 && current_uid == NULL) {
- current_uid = userlist[next_index_uid++];
- }
- Alog(LOG_DEBUG_2) << "first_uid() returning "
- << (current_uid ? current_uid->nick : "NULL (end of list)") << " "
- << (current_uid ? current_uid->GetUID() : "");
- return current_uid;
+ return find_byuid(std::string(uid.c_str()));
}
-User *next_uid()
+User *find_byuid(const std::string &uid)
{
- if (current_uid)
- current_uid = current_uid->next;
- if (!current_uid && next_index_uid < 1024) {
- while (next_index_uid < 1024 && current_uid == NULL)
- current_uid = userlist[next_index_uid++];
- }
- Alog(LOG_DEBUG_2) << "next_uid() returning "
- << (current_uid ? current_uid->nick : "NULL (end of list)") << " "
- << (current_uid ? current_uid->GetUID() : "");
- return current_uid;
+ Alog(LOG_DEBUG_3) << "finduser_byuid(" << uid << ")";
+
+ user_uid_map::iterator it = UserListByUID.find(uid);
+
+ if (it != UserListByUID.end())
+ return it->second;
+ return NULL;
}
/*************************************************************************/
-/*************************************************************************/
/* Handle a server NICK command. */
@@ -1306,14 +1230,14 @@ void UserSetInternalModes(User *user, int ac, const char **av)
{
++opcnt;
if (Config.WallOper)
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "\2%s\2 is now an IRC operator.", user->nick.c_str());
+ ircdproto->SendGlobops(OperServ, "\2%s\2 is now an IRC operator.", user->nick.c_str());
}
else
--opcnt;
break;
case UMODE_REGISTERED:
if (add && !user->IsIdentified())
- user->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ user->RemoveMode(NickServ, UMODE_REGISTERED);
break;
case UMODE_CLOAK:
case UMODE_VHOST: