From 283137841f35478d59aea6d3023a54c23d13734a Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 22 Feb 2024 17:45:04 +0000 Subject: Refactor the InspIRCd module static variables and method. --- modules/protocol/inspircd.cpp | 49 ++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'modules/protocol') diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp index cc365892a..d1d5a03b9 100644 --- a/modules/protocol/inspircd.cpp +++ b/modules/protocol/inspircd.cpp @@ -22,28 +22,47 @@ struct SASLUser final time_t created; }; -static std::list saslusers; +namespace +{ + // The maximum length of a channel name. + size_t maxchannel = 0; -static Anope::string rsquit_server, rsquit_id; + // The maximum length of a hostname. + size_t maxhost = 0; -static size_t maxchannel = 0, maxhost = 0, maxnick = 0, maxuser = 0; + // The maximum length of a nickname. + size_t maxnick = 0; -static void ParseModule(const Anope::string &module, Anope::string &modname, Anope::string &moddata) -{ - size_t sep = module.find('='); + // The maximum length of a username. + size_t maxuser = 0; + + // The SID of a server we are waiting to squit. + Anope::string rsquit_id; + + // The hostname of a server we are waiting to squit. + Anope::string rsquit_server; - // Extract and clean up the module name. - modname = module.substr(0, sep); - if (modname.compare(0, 2, "m_", 2) == 0) - modname.erase(0, 2); + // Non-introduced users who have authenticated via SASL. + std::list saslusers; - if (modname.length() > 3 && modname.compare(modname.length() - 3, 3, ".so", 3) == 0) - modname.erase(modname.length() - 3); + // Parses a module name in the format "m_foo.so=bar" to {foo, bar}. + void ParseModule(const Anope::string &module, Anope::string &modname, Anope::string &moddata) + { + size_t sep = module.find('='); + + // Extract and clean up the module name. + modname = module.substr(0, sep); + if (modname.compare(0, 2, "m_", 2) == 0) + modname.erase(0, 2); - // Extract the module link data (if any). - moddata = sep == Anope::string::npos ? "" : module.substr(sep); + if (modname.length() > 3 && modname.compare(modname.length() - 3, 3, ".so", 3) == 0) + modname.erase(modname.length() - 3); - Log(LOG_DEBUG) << "Parsed module: " << "name=" << modname << " data=" << moddata; + // Extract the module link data (if any). + moddata = (sep == Anope::string::npos) ? "" : module.substr(sep); + + Log(LOG_DEBUG) << "Parsed module: " << "name=" << modname << " data=" << moddata; + } } class InspIRCdProto final -- cgit