From 5c29c53f651fb0c513a50c9396e08ba340a6d2bf Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sun, 7 Apr 2013 22:23:25 +0100 Subject: Convert ISUPPORT to use a map instead of a string. --- include/configreader.h | 18 ------------------ include/inspircd.h | 32 ++++++++++++++++++++++++-------- include/modules.h | 6 +++--- 3 files changed, 27 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/configreader.h b/include/configreader.h index 5541a2c42..b137ee544 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -432,16 +432,6 @@ class CoreExport ServerConfig */ ClassVector Classes; - /** The 005 tokens of this server (ISUPPORT) - * populated/repopulated upon loading or unloading - * modules. - */ - std::string data005; - - /** isupport strings - */ - std::vector isupport; - /** STATS characters in this list are available * only to operators. */ @@ -515,14 +505,6 @@ class CoreExport ServerConfig */ const std::string& GetSID(); - /** Update the 005 vector - */ - void Update005(); - - /** Send the 005 numerics (ISUPPORT) to a user - */ - void Send005(User* user); - /** Read the entire configuration into memory * and initialize this class. All other methods * should be used only by the core. diff --git a/include/inspircd.h b/include/inspircd.h index df2ad1095..f61d48529 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -267,6 +267,27 @@ class serverstats } }; +/** This class manages the generation and transmission of ISUPPORT. */ +class CoreExport ISupportManager +{ +private: + /** The generated lines which are sent to clients. */ + std::vector Lines; + +public: + /** (Re)build the ISUPPORT vector. */ + void Build(); + + /** Returns the std::vector of ISUPPORT lines. */ + const std::vector& GetLines() + { + return this->Lines; + } + + /** Send the 005 numerics (ISUPPORT) to a user. */ + void SendTo(LocalUser* user); +}; + DEFINE_HANDLER2(IsNickHandler, bool, const std::string&, size_t); DEFINE_HANDLER2(GenRandomHandler, void, char*, size_t); DEFINE_HANDLER1(IsIdentHandler, bool, const std::string&); @@ -371,10 +392,6 @@ class CoreExport InspIRCd */ User* FindUUID(const char *uid); - /** Build the ISUPPORT string by triggering all modules On005Numeric events - */ - void BuildISupport(); - /** Time this ircd was booted */ time_t startup_time; @@ -472,6 +489,9 @@ class CoreExport InspIRCd */ LocalStringExt OperQuit; + /** Manages the generation and transmission of ISUPPORT. */ + ISupportManager ISupport; + /** Get the current time * Because this only calls time() once every time around the mainloop, * it is much faster than calling time() directly. @@ -828,10 +848,6 @@ class CoreExport InspIRCd */ int Run(); - /** Adds an extban char to the 005 token. - */ - void AddExtBanChar(char c); - char* GetReadBuffer() { return this->ReadBuffer; diff --git a/include/modules.h b/include/modules.h index 3e5ace3f4..58062fddd 100644 --- a/include/modules.h +++ b/include/modules.h @@ -911,9 +911,9 @@ class CoreExport Module : public classbase, public usecountbase /** Called when a 005 numeric is about to be output. * The module should modify the 005 numeric if needed to indicate its features. - * @param output The 005 string to be modified if neccessary. - */ - virtual void On005Numeric(std::string &output); + * @param output The 005 map to be modified if neccessary. + */ + virtual void On005Numeric(std::map& tokens); /** Called when a client is disconnected by KILL. * If a client is killed by a server, e.g. a nickname collision or protocol error, -- cgit v1.2.3