diff options
author | Sadie Powell <sadie@witchery.services> | 2024-02-22 17:45:04 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-02-22 17:47:14 +0000 |
commit | 283137841f35478d59aea6d3023a54c23d13734a (patch) | |
tree | 2a9ebdd5b07fa814761129732304175de1875eab | |
parent | 3290ebd36ada5c3f698a124163191187b494c912 (diff) |
Refactor the InspIRCd module static variables and method.
-rw-r--r-- | modules/protocol/inspircd.cpp | 49 |
1 files changed, 34 insertions, 15 deletions
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<SASLUser> 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<SASLUser> 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 |