From f9911dde529adf3dc03f4f14bbd70756ac2f665c Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 2 Mar 2025 14:51:02 +0000 Subject: Return references instead of pointers from the config system. We used to return NULL from these methods but now we return an empty block so this can never actually be null now. --- include/config.h | 8 +- include/modules.h | 2 +- include/modules/sasl.h | 2 +- modules/botserv/botserv.cpp | 30 ++--- modules/botserv/bs_autoassign.cpp | 2 +- modules/botserv/bs_badwords.cpp | 4 +- modules/botserv/bs_kick.cpp | 10 +- modules/botserv/bs_set.cpp | 4 +- modules/chanserv/chanserv.cpp | 32 ++--- modules/chanserv/cs_access.cpp | 20 +-- modules/chanserv/cs_akick.cpp | 8 +- modules/chanserv/cs_ban.cpp | 12 +- modules/chanserv/cs_clone.cpp | 2 +- modules/chanserv/cs_entrymsg.cpp | 2 +- modules/chanserv/cs_fantasy_stats.cpp | 6 +- modules/chanserv/cs_fantasy_top.cpp | 6 +- modules/chanserv/cs_flags.cpp | 16 +-- modules/chanserv/cs_kick.cpp | 4 +- modules/chanserv/cs_list.cpp | 6 +- modules/chanserv/cs_log.cpp | 14 +-- modules/chanserv/cs_mode.cpp | 18 +-- modules/chanserv/cs_register.cpp | 2 +- modules/chanserv/cs_seen.cpp | 6 +- modules/chanserv/cs_set.cpp | 18 +-- modules/chanserv/cs_set_misc.cpp | 14 +-- modules/chanserv/cs_suspend.cpp | 6 +- modules/chanserv/cs_xop.cpp | 24 ++-- modules/chanstats.cpp | 20 +-- modules/database/db_atheme.cpp | 18 +-- modules/database/db_flatfile.cpp | 18 +-- modules/database/db_old.cpp | 2 +- modules/database/db_redis.cpp | 6 +- modules/database/db_sql.cpp | 10 +- modules/database/db_sql_live.cpp | 10 +- modules/dns.cpp | 26 ++-- modules/dnsbl.cpp | 38 +++--- modules/encryption/enc_bcrypt.cpp | 6 +- modules/encryption/enc_sha2.cpp | 4 +- modules/extra/enc_argon2.cpp | 16 +-- modules/extra/ldap.cpp | 22 ++-- modules/extra/mysql.cpp | 28 ++--- modules/extra/sqlite.cpp | 16 +-- modules/extra/ssl_gnutls.cpp | 14 +-- modules/extra/ssl_openssl.cpp | 18 +-- modules/extra/xmlrpc.cpp | 4 +- modules/fantasy.cpp | 4 +- modules/global/gl_queue.cpp | 2 +- modules/global/global.cpp | 12 +- modules/help.cpp | 4 +- modules/helpchan.cpp | 2 +- modules/hostserv/hostserv.cpp | 10 +- modules/hostserv/hs_group.cpp | 8 +- modules/hostserv/hs_list.cpp | 2 +- modules/hostserv/hs_request.cpp | 16 +-- modules/httpd.cpp | 22 ++-- modules/irc2sql/irc2sql.cpp | 16 +-- modules/irc2sql/irc2sql.h | 2 +- modules/ldap_authentication.cpp | 22 ++-- modules/ldap_oper.cpp | 14 +-- modules/memoserv/memoserv.cpp | 18 +-- modules/memoserv/ms_ignore.cpp | 2 +- modules/memoserv/ms_rsend.cpp | 4 +- modules/memoserv/ms_send.cpp | 2 +- modules/memoserv/ms_set.cpp | 4 +- modules/nickserv/nickserv.cpp | 56 ++++----- modules/nickserv/ns_ajoin.cpp | 4 +- modules/nickserv/ns_cert.cpp | 10 +- modules/nickserv/ns_drop.cpp | 4 +- modules/nickserv/ns_group.cpp | 14 +-- modules/nickserv/ns_identify.cpp | 2 +- modules/nickserv/ns_list.cpp | 4 +- modules/nickserv/ns_maxemail.cpp | 6 +- modules/nickserv/ns_recover.cpp | 8 +- modules/nickserv/ns_register.cpp | 48 +++---- modules/nickserv/ns_resetpass.cpp | 10 +- modules/nickserv/ns_set.cpp | 32 ++--- modules/nickserv/ns_set_keepmodes.cpp | 2 +- modules/nickserv/ns_set_kill.cpp | 4 +- modules/nickserv/ns_set_misc.cpp | 12 +- modules/nickserv/ns_suspend.cpp | 8 +- modules/operserv/operserv.cpp | 6 +- modules/operserv/os_akill.cpp | 14 +-- modules/operserv/os_chankill.cpp | 4 +- modules/operserv/os_config.cpp | 14 +-- modules/operserv/os_defcon.cpp | 47 +++---- modules/operserv/os_dns.cpp | 18 +-- modules/operserv/os_forbid.cpp | 8 +- modules/operserv/os_ignore.cpp | 2 +- modules/operserv/os_info.cpp | 2 +- modules/operserv/os_kill.cpp | 2 +- modules/operserv/os_list.cpp | 4 +- modules/operserv/os_logsearch.cpp | 2 +- modules/operserv/os_news.cpp | 16 +-- modules/operserv/os_session.cpp | 22 ++-- modules/operserv/os_set.cpp | 2 +- modules/operserv/os_shutdown.cpp | 18 +-- modules/operserv/os_stats.cpp | 6 +- modules/operserv/os_sxline.cpp | 26 ++-- modules/protocol/hybrid.cpp | 2 +- modules/protocol/inspircd.cpp | 6 +- modules/proxyscan.cpp | 34 ++--- modules/redis.cpp | 16 +-- modules/regex_stdlib.cpp | 6 +- modules/rewrite.cpp | 16 +-- modules/rpc/jsonrpc.cpp | 4 +- modules/sasl.cpp | 8 +- modules/sql_authentication.cpp | 12 +- modules/sql_log.cpp | 6 +- modules/sql_oper.cpp | 8 +- modules/webcpanel/pages/register.cpp | 2 +- modules/webcpanel/webcpanel.cpp | 8 +- src/command.cpp | 2 +- src/config.cpp | 227 +++++++++++++++++----------------- src/init.cpp | 36 +++--- src/language.cpp | 2 +- src/mail.cpp | 26 ++-- src/main.cpp | 4 +- src/messages.cpp | 6 +- src/misc.cpp | 2 +- src/modulemanager.cpp | 2 +- src/protocol.cpp | 18 +-- src/uplink.cpp | 6 +- src/users.cpp | 6 +- src/xline.cpp | 4 +- 124 files changed, 814 insertions(+), 812 deletions(-) diff --git a/include/config.h b/include/config.h index 2f4f1b953..d705fd422 100644 --- a/include/config.h +++ b/include/config.h @@ -41,7 +41,7 @@ namespace Configuration Block(const Anope::string &); const Anope::string &GetName() const; int CountBlock(const Anope::string &name) const; - const Block *GetBlock(const Anope::string &name, int num = 0) const; + const Block &GetBlock(const Anope::string &name, int num = 0) const; Block *GetMutableBlock(const Anope::string &name, int num = 0); template T Get(const Anope::string &tag, const Anope::string &def = "") const @@ -126,12 +126,12 @@ namespace Configuration void LoadConf(File &file); void Post(Conf *old); - Block *GetModule(const Module *); - Block *GetModule(const Anope::string &name); + Block &GetModule(const Module *); + Block &GetModule(const Anope::string &name); BotInfo *GetClient(const Anope::string &name); - const Block *GetCommand(CommandSource &); + const Block &GetCommand(CommandSource &); }; struct Uplink final diff --git a/include/modules.h b/include/modules.h index 12637b1b4..8a7702ac7 100644 --- a/include/modules.h +++ b/include/modules.h @@ -305,7 +305,7 @@ public: * @param conf The config that is being built now and will replace the global Config object * @throws A ConfigException to abort the config (re)loading process. */ - virtual void OnReload(Configuration::Conf *conf) ATTR_NOT_NULL(2) { throw NotImplementedException(); } + virtual void OnReload(Configuration::Conf &conf) { throw NotImplementedException(); } /** Called before a bot is assigned to a channel. * @param sender The user assigning the bot diff --git a/include/modules/sasl.h b/include/modules/sasl.h index d051e2e61..5f8d0e9c3 100644 --- a/include/modules/sasl.h +++ b/include/modules/sasl.h @@ -121,7 +121,7 @@ namespace SASL if (!na || na->nc->HasExt("NS_SUSPENDED") || na->nc->HasExt("UNCONFIRMED")) return OnFail(); - unsigned int maxlogins = Config->GetModule("ns_identify")->Get("maxlogins"); + unsigned int maxlogins = Config->GetModule("ns_identify").Get("maxlogins"); if (maxlogins && na->nc->users.size() >= maxlogins) return OnFail(); diff --git a/modules/botserv/botserv.cpp b/modules/botserv/botserv.cpp index 0646668be..e77ffe46c 100644 --- a/modules/botserv/botserv.cpp +++ b/modules/botserv/botserv.cpp @@ -23,9 +23,9 @@ public: { } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - const Anope::string &bsnick = conf->GetModule(this)->Get("client"); + const Anope::string &bsnick = conf.GetModule(this).Get("client"); BotServ = BotInfo::Find(bsnick, true); } @@ -34,7 +34,7 @@ public: /* Do not allow removing bot modes on our service bots */ if (chan->ci && chan->ci->bi == user) { - const Anope::string &botmodes = Config->GetModule(this)->Get("botmodes"); + const Anope::string &botmodes = Config->GetModule(this).Get("botmodes"); for (auto botmode : botmodes) chan->SetMode(chan->ci->bi, ModeManager::FindChannelModeByChar(botmode), chan->ci->bi->GetUID()); } @@ -42,9 +42,9 @@ public: void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) override { - if (ci->c && ci->c->users.size() >= Config->GetModule(this)->Get("minusers")) + if (ci->c && ci->c->users.size() >= Config->GetModule(this).Get("minusers")) { - ChannelStatus status(Config->GetModule(this)->Get("botmodes")); + ChannelStatus status(Config->GetModule(this).Get("botmodes")); bi->Join(ci->c, &status); } } @@ -55,7 +55,7 @@ public: return; BotInfo *bi = user->server == Me ? dynamic_cast(user) : NULL; - if (bi && Config->GetModule(this)->Get("smartjoin")) + if (bi && Config->GetModule(this).Get("smartjoin")) { if (IRCD->CanClearBans) { @@ -99,9 +99,9 @@ public: * legit users - Rob **/ /* This is before the user has joined the channel, so check usercount + 1 */ - if (c->users.size() + 1 >= Config->GetModule(this)->Get("minusers") && !c->FindUser(c->ci->bi)) + if (c->users.size() + 1 >= Config->GetModule(this).Get("minusers") && !c->FindUser(c->ci->bi)) { - ChannelStatus status(Config->GetModule(this)->Get("botmodes")); + ChannelStatus status(Config->GetModule(this).Get("botmodes")); c->ci->bi->Join(c, &status); } } @@ -124,7 +124,7 @@ public: return; /* This is called prior to removing the user from the channel, so c->users.size() - 1 should be safe */ - if (c->ci && c->ci->bi && u != *c->ci->bi && c->users.size() - 1 <= Config->GetModule(this)->Get("minusers") && c->FindUser(c->ci->bi)) + if (c->ci && c->ci->bi && u != *c->ci->bi && c->users.size() - 1 <= Config->GetModule(this).Get("minusers") && c->FindUser(c->ci->bi)) c->ci->bi->Part(c->ci->c); } @@ -140,7 +140,7 @@ public: "channel, and provide a more convenient way to execute commands. Commands that\n" "require a channel as a parameter will automatically have that parameter\n" "given.\n"), source.service->nick.c_str()); - const Anope::string &fantasycharacters = Config->GetModule("fantasy")->Get("fantasycharacter", "!"); + const Anope::string &fantasycharacters = Config->GetModule("fantasy").Get("fantasycharacter", "!"); if (!fantasycharacters.empty()) source.Reply(_(" \n" "Fantasy commands may be prefixed with one of the following characters: %s\n"), fantasycharacters.c_str()); @@ -170,8 +170,8 @@ public: source.Reply(_(" \n" "Bot will join a channel whenever there is at least\n" - "\002%d\002 user(s) on it."), Config->GetModule(this)->Get("minusers")); - const Anope::string &fantasycharacters = Config->GetModule("fantasy")->Get("fantasycharacter", "!"); + "\002%d\002 user(s) on it."), Config->GetModule(this).Get("minusers")); + const Anope::string &fantasycharacters = Config->GetModule("fantasy").Get("fantasycharacter", "!"); if (!fantasycharacters.empty()) source.Reply(_("Additionally, if fantasy is enabled fantasy commands\n" "can be executed by prefixing the command name with\n" @@ -180,7 +180,7 @@ public: EventReturn OnChannelModeSet(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string ¶m) override { - if (source.GetUser() && !source.GetBot() && Config->GetModule(this)->Get("smartjoin") && mode->name == "BAN" && c->ci && c->ci->bi && c->FindUser(c->ci->bi)) + if (source.GetUser() && !source.GetBot() && Config->GetModule(this).Get("smartjoin") && mode->name == "BAN" && c->ci && c->ci->bi && c->FindUser(c->ci->bi)) { BotInfo *bi = c->ci->bi; @@ -195,7 +195,7 @@ public: void OnCreateChan(ChannelInfo *ci) override { /* Set default bot flags */ - spacesepstream sep(Config->GetModule(this)->Get("defaults", "greet fantasy")); + spacesepstream sep(Config->GetModule(this).Get("defaults", "greet fantasy")); for (Anope::string token; sep.GetToken(token);) ci->Extend("BS_" + token.upper()); } @@ -211,7 +211,7 @@ public: void OnCreateBot(BotInfo *bi) override { if (bi->botmodes.empty()) - bi->botmodes = Config->GetModule(this)->Get("botumodes"); + bi->botmodes = Config->GetModule(this).Get("botumodes"); } }; diff --git a/modules/botserv/bs_autoassign.cpp b/modules/botserv/bs_autoassign.cpp index e988540fe..5292f8642 100644 --- a/modules/botserv/bs_autoassign.cpp +++ b/modules/botserv/bs_autoassign.cpp @@ -19,7 +19,7 @@ public: void OnChanRegistered(ChannelInfo *ci) override { - const Anope::string &bot = Config->GetModule(this)->Get("bot"); + const Anope::string &bot = Config->GetModule(this).Get("bot"); if (bot.empty()) return; diff --git a/modules/botserv/bs_badwords.cpp b/modules/botserv/bs_badwords.cpp index 5301fd042..95f749488 100644 --- a/modules/botserv/bs_badwords.cpp +++ b/modules/botserv/bs_badwords.cpp @@ -286,14 +286,14 @@ private: realword = word.substr(0, pos); } - unsigned badwordsmax = Config->GetModule(this->module)->Get("badwordsmax"); + unsigned badwordsmax = Config->GetModule(this->module).Get("badwordsmax"); if (badwords->GetBadWordCount() >= badwordsmax) { source.Reply(_("Sorry, you can only have %d bad words entries on a channel."), badwordsmax); return; } - bool casesensitive = Config->GetModule(this->module)->Get("casesensitive"); + bool casesensitive = Config->GetModule(this->module).Get("casesensitive"); for (unsigned i = 0, end = badwords->GetBadWordCount(); i < end; ++i) { diff --git a/modules/botserv/bs_kick.cpp b/modules/botserv/bs_kick.cpp index caaa51b01..eba2868a6 100644 --- a/modules/botserv/bs_kick.cpp +++ b/modules/botserv/bs_kick.cpp @@ -515,8 +515,8 @@ public: if (kd->floodsecs < 1) kd->floodsecs = 10; - if (kd->floodsecs > Config->GetModule(me)->Get("keepdata")) - kd->floodsecs = Config->GetModule(me)->Get("keepdata"); + if (kd->floodsecs > Config->GetModule(me).Get("keepdata")) + kd->floodsecs = Config->GetModule(me).Get("keepdata"); kd->flood = true; if (kd->ttb[TTB_FLOOD]) @@ -913,7 +913,7 @@ public: void purge() { - time_t keepdata = Config->GetModule(me)->Get("keepdata"); + time_t keepdata = Config->GetModule(me).Get("keepdata"); for (data_type::iterator it = data_map.begin(), it_end = data_map.end(); it != it_end;) { const Anope::string &user = it->first; @@ -1299,7 +1299,7 @@ public: /* Normalize the buffer */ Anope::string nbuf = Anope::NormalizeBuffer(realbuf); - bool casesensitive = Config->GetModule("botserv")->Get("casesensitive"); + bool casesensitive = Config->GetModule("botserv").Get("casesensitive"); /* Normalize can return an empty string if this only contains control codes etc */ if (badwords && !nbuf.empty()) @@ -1368,7 +1368,7 @@ public: if (mustkick) { check_ban(ci, u, kd, TTB_BADWORDS); - if (Config->GetModule(me)->Get("gentlebadwordreason")) + if (Config->GetModule(me).Get("gentlebadwordreason")) bot_kick(ci, u, _("Watch your language!")); else bot_kick(ci, u, _("Don't use the word \"%s\" on this channel!"), bw->word.c_str()); diff --git a/modules/botserv/bs_set.cpp b/modules/botserv/bs_set.cpp index 1ab00205d..9b536e19a 100644 --- a/modules/botserv/bs_set.cpp +++ b/modules/botserv/bs_set.cpp @@ -33,8 +33,8 @@ public: source.Reply(_("Configures bot options.\n" " \n" "Available options:")); - bool hide_privileged_commands = Config->GetBlock("options")->Get("hideprivilegedcommands"), - hide_registered_commands = Config->GetBlock("options")->Get("hideregisteredcommands"); + bool hide_privileged_commands = Config->GetBlock("options").Get("hideprivilegedcommands"), + hide_registered_commands = Config->GetBlock("options").Get("hideregisteredcommands"); Anope::string this_name = source.command; for (const auto &[c_name, info] : source.service->commands) { diff --git a/modules/chanserv/chanserv.cpp b/modules/chanserv/chanserv.cpp index f4ba4c007..cca234812 100644 --- a/modules/chanserv/chanserv.cpp +++ b/modules/chanserv/chanserv.cpp @@ -14,8 +14,8 @@ inline static Anope::string BotModes() { - return Config->GetModule("botserv")->Get("botmodes", - Config->GetModule("chanserv")->Get("botmodes", "o") + return Config->GetModule("botserv").Get("botmodes", + Config->GetModule("chanserv").Get("botmodes", "o") ); } @@ -52,7 +52,7 @@ public: * @param chan The channel */ ChanServTimer(Reference &cs, ExtensibleItem &i, Module *m, Channel *chan) - : Timer(m, Config->GetModule(m)->Get("inhabit", "1m")) + : Timer(m, Config->GetModule(m).Get("inhabit", "1m")) , ChanServ(cs) , inhabit(i) , c(chan) @@ -103,9 +103,9 @@ public: new ChanServTimer(ChanServ, inhabit, this->owner, c); } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - const Anope::string &channick = conf->GetModule(this)->Get("client"); + const Anope::string &channick = conf.GetModule(this).Get("client"); if (channick.empty()) throw ConfigException(Module::name + ": must be defined"); @@ -116,7 +116,7 @@ public: ChanServ = bi; - spacesepstream(conf->GetModule(this)->Get("defaults", "keeptopic peace securefounder signkick")).GetTokens(defaults); + spacesepstream(conf.GetModule(this).Get("defaults", "keeptopic peace securefounder signkick")).GetTokens(defaults); if (defaults.empty()) { defaults.emplace_back("KEEPTOPIC"); @@ -127,7 +127,7 @@ public: else if (defaults[0].equals_ci("none")) defaults.clear(); - always_lower = conf->GetModule(this)->Get("always_lower_ts"); + always_lower = conf.GetModule(this).Get("always_lower_ts"); } void OnBotDelete(BotInfo *bi) override @@ -138,7 +138,7 @@ public: EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message, const Anope::map &tags) override { - if (bi == ChanServ && Config->GetModule(this)->Get("opersonly") && !u->HasMode("OPER")) + if (bi == ChanServ && Config->GetModule(this).Get("opersonly") && !u->HasMode("OPER")) { u->SendMessage(bi, ACCESS_DENIED); return EVENT_STOP; @@ -151,7 +151,7 @@ public: { std::deque chans; nc->GetChannelReferences(chans); - int max_reg = Config->GetModule(this)->Get("maxregistered"); + int max_reg = Config->GetModule(this).Get("maxregistered"); for (auto *ci : chans) { @@ -247,7 +247,7 @@ public: { ci->c->RemoveMode(ci->WhoSends(), "REGISTERED", "", false); - const Anope::string &require = Config->GetModule(this)->Get("require"); + const Anope::string &require = Config->GetModule(this).Get("require"); if (!require.empty()) ci->c->SetModes(ci->WhoSends(), false, "-%s", require.c_str()); } @@ -272,7 +272,7 @@ public: { if (!params.empty() || source.c || source.service != *ChanServ) return; - time_t chanserv_expire = Config->GetModule(this)->Get("expire", "30d"); + time_t chanserv_expire = Config->GetModule(this).Get("expire", "30d"); if (chanserv_expire >= 86400) source.Reply(_(" \n" "Note that any channel which is not used for %lu days\n" @@ -295,7 +295,7 @@ public: else c->RemoveMode(c->WhoSends(), "REGISTERED", "", false); - const Anope::string &require = Config->GetModule(this)->Get("require"); + const Anope::string &require = Config->GetModule(this).Get("require"); if (!require.empty()) { if (c->ci) @@ -314,8 +314,8 @@ public: EventReturn OnCanSet(User *u, const ChannelMode *cm) override { - if (Config->GetModule(this)->Get("nomlock").find(cm->mchar) != Anope::string::npos - || Config->GetModule(this)->Get("require").find(cm->mchar) != Anope::string::npos) + if (Config->GetModule(this).Get("nomlock").find(cm->mchar) != Anope::string::npos + || Config->GetModule(this).Get("require").find(cm->mchar) != Anope::string::npos) return EVENT_STOP; return EVENT_CONTINUE; } @@ -337,7 +337,7 @@ public: void OnExpireTick() override { - time_t chanserv_expire = Config->GetModule(this)->Get("expire", "30d"); + time_t chanserv_expire = Config->GetModule(this).Get("expire", "30d"); if (!chanserv_expire || Anope::NoExpire || Anope::ReadOnly) return; @@ -467,7 +467,7 @@ public: if (!show_all) return; - time_t chanserv_expire = Config->GetModule(this)->Get("expire", "30d"); + time_t chanserv_expire = Config->GetModule(this).Get("expire", "30d"); if (!ci->HasExt("CS_NO_EXPIRE") && chanserv_expire && !Anope::NoExpire && ci->last_used != Anope::CurTime) info[_("Expires")] = Anope::strftime(ci->last_used + chanserv_expire, source.GetAccount()); } diff --git a/modules/chanserv/cs_access.cpp b/modules/chanserv/cs_access.cpp index dcae83ae7..5f13f56df 100644 --- a/modules/chanserv/cs_access.cpp +++ b/modules/chanserv/cs_access.cpp @@ -134,7 +134,7 @@ class CommandCSAccess final if (IRCD->IsChannelValid(mask)) { - if (Config->GetModule("chanserv")->Get("disallow_channel_access")) + if (Config->GetModule("chanserv").Get("disallow_channel_access")) { source.Reply(_("Channels may not be on access lists.")); return; @@ -158,7 +158,7 @@ class CommandCSAccess final { na = NickAlias::Find(mask); - if (!na && Config->GetModule("chanserv")->Get("disallow_hostmask_access")) + if (!na && Config->GetModule("chanserv").Get("disallow_hostmask_access")) { source.Reply(_("Masks and unregistered users may not be on access lists.")); return; @@ -205,7 +205,7 @@ class CommandCSAccess final } } - unsigned access_max = Config->GetModule("chanserv")->Get("accessmax", "1000"); + unsigned access_max = Config->GetModule("chanserv").Get("accessmax", "1000"); if (access_max && ci->GetDeepAccessCount() >= access_max) { source.Reply(_("Sorry, you can only have %d access entries on a channel, including access entries from other channels."), access_max); @@ -601,7 +601,7 @@ public: "may be a numerical level or the name of a privilege (eg AUTOOP).\n" "When a user joins the channel the access they receive is from the\n" "highest level entry in the access list.")); - if (!Config->GetModule("chanserv")->Get("disallow_channel_access")) + if (!Config->GetModule("chanserv").Get("disallow_channel_access")) source.Reply(_("The given mask may also be a channel, which will use the\n" "access list from the other channel up to the given \037level\037.")); source.Reply(" "); @@ -878,21 +878,21 @@ public: } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { defaultLevels.clear(); - for (int i = 0; i < conf->CountBlock("privilege"); ++i) + for (int i = 0; i < conf.CountBlock("privilege"); ++i) { - Configuration::Block *priv = conf->GetBlock("privilege", i); + Configuration::Block &priv = conf.GetBlock("privilege", i); - const Anope::string &pname = priv->Get("name"); + const Anope::string &pname = priv.Get("name"); Privilege *p = PrivilegeManager::FindPrivilege(pname); if (p == NULL) continue; - const Anope::string &value = priv->Get("level"); + const Anope::string &value = priv.Get("level"); if (value.empty()) continue; else if (value.equals_ci("founder")) @@ -900,7 +900,7 @@ public: else if (value.equals_ci("disabled")) defaultLevels[p->name] = ACCESS_INVALID; else - defaultLevels[p->name] = priv->Get("level"); + defaultLevels[p->name] = priv.Get("level"); } } diff --git a/modules/chanserv/cs_akick.cpp b/modules/chanserv/cs_akick.cpp index 489b18772..ad58a814b 100644 --- a/modules/chanserv/cs_akick.cpp +++ b/modules/chanserv/cs_akick.cpp @@ -46,7 +46,7 @@ class CommandCSAKick final const NickAlias *na = NickAlias::Find(mask); NickCore *nc = NULL; const AutoKick *akick; - unsigned reasonmax = Config->GetModule("chanserv")->Get("reasonmax", "200"); + unsigned reasonmax = Config->GetModule("chanserv").Get("reasonmax", "200"); if (reason.length() > reasonmax) reason = reason.substr(0, reasonmax); @@ -170,9 +170,9 @@ class CommandCSAKick final } } - if (ci->GetAkickCount() >= Config->GetModule(this->owner)->Get("autokickmax")) + if (ci->GetAkickCount() >= Config->GetModule(this->owner).Get("autokickmax")) { - source.Reply(_("Sorry, you can only have %d autokick masks on a channel."), Config->GetModule(this->owner)->Get("autokickmax")); + source.Reply(_("Sorry, you can only have %d autokick masks on a channel."), Config->GetModule(this->owner).Get("autokickmax")); return; } @@ -568,7 +568,7 @@ public: reason = autokick->reason; if (reason.empty()) { - reason = Language::Translate(u, Config->GetModule(this)->Get("autokickreason").c_str()); + reason = Language::Translate(u, Config->GetModule(this).Get("autokickreason").c_str()); reason = reason.replace_all_cs("%n", u->nick) .replace_all_cs("%c", c->name); } diff --git a/modules/chanserv/cs_ban.cpp b/modules/chanserv/cs_ban.cpp index 9f2b691ef..74dc129f4 100644 --- a/modules/chanserv/cs_ban.cpp +++ b/modules/chanserv/cs_ban.cpp @@ -50,8 +50,8 @@ public: void Execute(CommandSource &source, const std::vector ¶ms) override { - Configuration::Block *block = Config->GetCommand(source); - const Anope::string &mode = block->Get("mode", "BAN"); + Configuration::Block &block = Config->GetCommand(source); + const Anope::string &mode = block.Get("mode", "BAN"); ChannelMode *cm = ModeManager::FindChannelModeByName(mode); if (cm == NULL) return; @@ -107,11 +107,11 @@ public: reason += " " + params[3]; } - unsigned reasonmax = Config->GetModule("chanserv")->Get("reasonmax", "200"); + unsigned reasonmax = Config->GetModule("chanserv").Get("reasonmax", "200"); if (reason.length() > reasonmax) reason = reason.substr(0, reasonmax); - Anope::string signkickformat = Config->GetModule("chanserv")->Get("signkickformat", "%m (%n)"); + Anope::string signkickformat = Config->GetModule("chanserv").Get("signkickformat", "%m (%n)"); signkickformat = signkickformat.replace_all_cs("%n", source.GetNick()); User *u = source.GetUser(); @@ -156,7 +156,7 @@ public: if (!c->FindUser(u2)) return; - if (block->Get("kick", "yes")) + if (block.Get("kick", "yes")) { if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !source.AccessFor(ci).HasPriv("SIGNKICK"))) { @@ -209,7 +209,7 @@ public: else if (uc->user->IsProtected()) continue; - if (block->Get("kick", "yes")) + if (block.Get("kick", "yes")) { ++kicked; if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !u_access.HasPriv("SIGNKICK"))) diff --git a/modules/chanserv/cs_clone.cpp b/modules/chanserv/cs_clone.cpp index 6f29a235c..5e4130532 100644 --- a/modules/chanserv/cs_clone.cpp +++ b/modules/chanserv/cs_clone.cpp @@ -24,7 +24,7 @@ class CommandCSClone final static void CopyAccess(CommandSource &source, ChannelInfo *ci, ChannelInfo *target_ci) { std::set masks; - unsigned access_max = Config->GetModule("chanserv")->Get("accessmax", "1000"); + unsigned access_max = Config->GetModule("chanserv").Get("accessmax", "1000"); unsigned count = 0; for (unsigned i = 0; i < target_ci->GetAccessCount(); ++i) diff --git a/modules/chanserv/cs_entrymsg.cpp b/modules/chanserv/cs_entrymsg.cpp index b1546428d..9f76c9d50 100644 --- a/modules/chanserv/cs_entrymsg.cpp +++ b/modules/chanserv/cs_entrymsg.cpp @@ -142,7 +142,7 @@ private: { EntryMessageList *messages = ci->Require("entrymsg"); - if ((*messages)->size() >= Config->GetModule(this->owner)->Get("maxentries")) + if ((*messages)->size() >= Config->GetModule(this->owner).Get("maxentries")) source.Reply(_("The entry message list for \002%s\002 is full."), ci->name.c_str()); else { diff --git a/modules/chanserv/cs_fantasy_stats.cpp b/modules/chanserv/cs_fantasy_stats.cpp index eae70f116..096bb6a31 100644 --- a/modules/chanserv/cs_fantasy_stats.cpp +++ b/modules/chanserv/cs_fantasy_stats.cpp @@ -77,10 +77,10 @@ public: } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - prefix = conf->GetModule("chanstats")->Get("prefix", "anope_"); - this->sql = ServiceReference("SQL::Provider", conf->GetModule("chanstats")->Get("engine")); + prefix = conf.GetModule("chanstats").Get("prefix", "anope_"); + this->sql = ServiceReference("SQL::Provider", conf.GetModule("chanstats").Get("engine")); } SQL::Result RunQuery(const SQL::Query &query) diff --git a/modules/chanserv/cs_fantasy_top.cpp b/modules/chanserv/cs_fantasy_top.cpp index 83cd6bee5..d2ebf277b 100644 --- a/modules/chanserv/cs_fantasy_top.cpp +++ b/modules/chanserv/cs_fantasy_top.cpp @@ -104,10 +104,10 @@ public: } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - prefix = conf->GetModule("chanstats")->Get("prefix", "anope_"); - this->sql = ServiceReference("SQL::Provider", conf->GetModule("chanstats")->Get("engine")); + prefix = conf.GetModule("chanstats").Get("prefix", "anope_"); + this->sql = ServiceReference("SQL::Provider", conf.GetModule("chanstats").Get("engine")); } SQL::Result RunQuery(const SQL::Query &query) diff --git a/modules/chanserv/cs_flags.cpp b/modules/chanserv/cs_flags.cpp index 691319634..876eb67e4 100644 --- a/modules/chanserv/cs_flags.cpp +++ b/modules/chanserv/cs_flags.cpp @@ -93,7 +93,7 @@ class CommandCSFlags final if (IRCD->IsChannelValid(mask)) { - if (Config->GetModule("chanserv")->Get("disallow_channel_access")) + if (Config->GetModule("chanserv").Get("disallow_channel_access")) { source.Reply(_("Channels may not be on access lists.")); return; @@ -116,7 +116,7 @@ class CommandCSFlags final else { na = NickAlias::Find(mask); - if (!na && Config->GetModule("chanserv")->Get("disallow_hostmask_access")) + if (!na && Config->GetModule("chanserv").Get("disallow_hostmask_access")) { source.Reply(_("Masks and unregistered users may not be on access lists.")); return; @@ -179,7 +179,7 @@ class CommandCSFlags final } } - unsigned access_max = Config->GetModule("chanserv")->Get("accessmax", "1000"); + unsigned access_max = Config->GetModule("chanserv").Get("accessmax", "1000"); if (access_max && ci->GetDeepAccessCount() >= access_max) { source.Reply(_("Sorry, you can only have %d access entries on a channel, including access entries from other channels."), access_max); @@ -494,21 +494,21 @@ public: } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { defaultFlags.clear(); - for (int i = 0; i < conf->CountBlock("privilege"); ++i) + for (int i = 0; i < conf.CountBlock("privilege"); ++i) { - Configuration::Block *priv = conf->GetBlock("privilege", i); + Configuration::Block &priv = conf.GetBlock("privilege", i); - const Anope::string &pname = priv->Get("name"); + const Anope::string &pname = priv.Get("name"); Privilege *p = PrivilegeManager::FindPrivilege(pname); if (p == NULL) continue; - const Anope::string &value = priv->Get("flag"); + const Anope::string &value = priv.Get("flag"); if (value.empty()) continue; diff --git a/modules/chanserv/cs_kick.cpp b/modules/chanserv/cs_kick.cpp index dfcd2995c..210a5168c 100644 --- a/modules/chanserv/cs_kick.cpp +++ b/modules/chanserv/cs_kick.cpp @@ -44,11 +44,11 @@ public: return; } - unsigned reasonmax = Config->GetModule("chanserv")->Get("reasonmax", "200"); + unsigned reasonmax = Config->GetModule("chanserv").Get("reasonmax", "200"); if (reason.length() > reasonmax) reason = reason.substr(0, reasonmax); - Anope::string signkickformat = Config->GetModule("chanserv")->Get("signkickformat", "%m (%n)"); + Anope::string signkickformat = Config->GetModule("chanserv").Get("signkickformat", "%m (%n)"); signkickformat = signkickformat.replace_all_cs("%n", source.GetNick()); AccessGroup u_access = source.AccessFor(ci); diff --git a/modules/chanserv/cs_list.cpp b/modules/chanserv/cs_list.cpp index 429b87d4d..e8feabed4 100644 --- a/modules/chanserv/cs_list.cpp +++ b/modules/chanserv/cs_list.cpp @@ -68,7 +68,7 @@ public: } Anope::string spattern = "#" + pattern; - unsigned listmax = Config->GetModule(this->owner)->Get("listmax", "50"); + unsigned listmax = Config->GetModule(this->owner).Get("listmax", "50"); source.Reply(_("List of entries matching \002%s\002:"), pattern.c_str()); @@ -160,11 +160,11 @@ public: " \002LIST #51-100\002\n" " Lists all registered channels within the given range (51-100).")); - if (!Config->GetBlock("options")->Get("regexengine").empty()) + if (!Config->GetBlock("options").Get("regexengine").empty()) { source.Reply(" "); source.Reply(_("Regex matches are also supported using the %s engine.\n" - "Enclose your pattern in // if this is desired."), Config->GetBlock("options")->Get("regexengine").c_str()); + "Enclose your pattern in // if this is desired."), Config->GetBlock("options").Get("regexengine").c_str()); } return true; diff --git a/modules/chanserv/cs_log.cpp b/modules/chanserv/cs_log.cpp index f3a32daed..e91a3f731 100644 --- a/modules/chanserv/cs_log.cpp +++ b/modules/chanserv/cs_log.cpp @@ -308,20 +308,20 @@ public: } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Configuration::Block *block = conf->GetModule(this); + Configuration::Block &block = conf.GetModule(this); defaults.clear(); - for (int i = 0; i < block->CountBlock("default"); ++i) + for (int i = 0; i < block.CountBlock("default"); ++i) { - Configuration::Block *def = block->GetBlock("default", i); + Configuration::Block &def = block.GetBlock("default", i); LogDefault ld; - ld.service = def->Get("service"); - ld.command = def->Get("command"); - ld.method = def->Get("method"); + ld.service = def.Get("service"); + ld.command = def.Get("command"); + ld.method = def.Get("method"); defaults.push_back(ld); } diff --git a/modules/chanserv/cs_mode.cpp b/modules/chanserv/cs_mode.cpp index 47e2b84ad..cc7a526cd 100644 --- a/modules/chanserv/cs_mode.cpp +++ b/modules/chanserv/cs_mode.cpp @@ -336,7 +336,7 @@ class CommandCSMode final continue; } - if (modelocks->GetMLock().size() >= Config->GetModule(this->owner)->Get("max", "50")) + if (modelocks->GetMLock().size() >= Config->GetModule(this->owner).Get("max", "50")) { source.Reply(_("The mode lock list of \002%s\002 is full."), ci->name.c_str()); continue; @@ -946,22 +946,22 @@ public: } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { modes.clear(); - for (int i = 0; i < conf->CountBlock("command"); ++i) + for (int i = 0; i < conf.CountBlock("command"); ++i) { - Configuration::Block *block = conf->GetBlock("command", i); + Configuration::Block &block = conf.GetBlock("command", i); - const Anope::string &cname = block->Get("name"), - &cmd = block->Get("command"); + const Anope::string &cname = block.Get("name"), + &cmd = block.Get("command"); if (cname.empty() || cmd != "chanserv/modes") continue; - const Anope::string &set = block->Get("set"), - &unset = block->Get("unset"); + const Anope::string &set = block.Get("set"), + &unset = block.Get("unset"); if (set.empty() && unset.empty()) continue; @@ -1024,7 +1024,7 @@ public: { ModeLocks *ml = modelocks.Require(ci); Anope::string mlock; - spacesepstream sep(Config->GetModule(this)->Get("mlock", "+nt")); + spacesepstream sep(Config->GetModule(this).Get("mlock", "+nt")); if (sep.GetToken(mlock)) { bool add = true; diff --git a/modules/chanserv/cs_register.cpp b/modules/chanserv/cs_register.cpp index e4e9ad951..97bddf5cd 100644 --- a/modules/chanserv/cs_register.cpp +++ b/modules/chanserv/cs_register.cpp @@ -25,7 +25,7 @@ public: { const Anope::string &chan = params[0]; const Anope::string &chdesc = params.size() > 1 ? params[1] : ""; - unsigned maxregistered = Config->GetModule("chanserv")->Get("maxregistered"); + unsigned maxregistered = Config->GetModule("chanserv").Get("maxregistered"); User *u = source.GetUser(); NickCore *nc = source.nc; diff --git a/modules/chanserv/cs_seen.cpp b/modules/chanserv/cs_seen.cpp index 6197975f5..d8e4e118b 100644 --- a/modules/chanserv/cs_seen.cpp +++ b/modules/chanserv/cs_seen.cpp @@ -382,15 +382,15 @@ public: { } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - simple = conf->GetModule(this)->Get("simple"); + simple = conf.GetModule(this).Get("simple"); } void OnExpireTick() override { size_t previous_size = database.size(); - time_t purgetime = Config->GetModule(this)->Get("purgetime"); + time_t purgetime = Config->GetModule(this).Get("purgetime"); if (!purgetime) purgetime = Anope::DoTime("30d"); for (database_map::iterator it = database.begin(), it_end = database.end(); it != it_end;) diff --git a/modules/chanserv/cs_set.cpp b/modules/chanserv/cs_set.cpp index 7f9e49dd3..7b214a531 100644 --- a/modules/chanserv/cs_set.cpp +++ b/modules/chanserv/cs_set.cpp @@ -36,8 +36,8 @@ public: " \n" "Available options:")); Anope::string this_name = source.command; - bool hide_privileged_commands = Config->GetBlock("options")->Get("hideprivilegedcommands"), - hide_registered_commands = Config->GetBlock("options")->Get("hideregisteredcommands"); + bool hide_privileged_commands = Config->GetBlock("options").Get("hideprivilegedcommands"), + hide_registered_commands = Config->GetBlock("options").Get("hideregisteredcommands"); for (const auto &[c_name, info] : source.service->commands) { if (c_name.find_ci(this_name + " ") == 0) @@ -301,7 +301,7 @@ public: } NickCore *nc = na->nc; - unsigned max_reg = Config->GetModule("chanserv")->Get("maxregistered"); + unsigned max_reg = Config->GetModule("chanserv").Get("maxregistered"); if (max_reg && nc->channelcount >= max_reg && !source.HasPriv("chanserv/no-register-limit")) { source.Reply(_("\002%s\002 has too many channels registered."), na->nick.c_str()); @@ -461,8 +461,8 @@ public: inline static Anope::string BotModes() { - return Config->GetModule("botserv")->Get("botmodes", - Config->GetModule("chanserv")->Get("botmodes", "o") + return Config->GetModule("botserv").Get("botmodes", + Config->GetModule("chanserv").Get("botmodes", "o") ); } @@ -969,7 +969,7 @@ public: "access list (with the highest access, if applicable) will\n" "become the new founder, but if the access list is empty, the\n" "channel will be dropped.")); - unsigned max_reg = Config->GetModule("chanserv")->Get("maxregistered"); + unsigned max_reg = Config->GetModule("chanserv").Get("maxregistered"); if (max_reg) { source.Reply(" "); @@ -1133,14 +1133,14 @@ public: { } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - persist_lower_ts = conf->GetModule(this)->Get("persist_lower_ts"); + persist_lower_ts = conf.GetModule(this).Get("persist_lower_ts"); } void OnCreateChan(ChannelInfo *ci) override { - ci->bantype = Config->GetModule(this)->Get("defbantype", "2"); + ci->bantype = Config->GetModule(this).Get("defbantype", "2"); } void OnChannelSync(Channel *c) override diff --git a/modules/chanserv/cs_set_misc.cpp b/modules/chanserv/cs_set_misc.cpp index 7fef1e022..01a5b90b7 100644 --- a/modules/chanserv/cs_set_misc.cpp +++ b/modules/chanserv/cs_set_misc.cpp @@ -187,27 +187,27 @@ public: delete item; } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { descriptions.clear(); numerics.clear(); - for (int i = 0; i < conf->CountBlock("command"); ++i) + for (int i = 0; i < conf.CountBlock("command"); ++i) { - Configuration::Block *block = conf->GetBlock("command", i); + Configuration::Block &block = conf.GetBlock("command", i); - if (block->Get("command") != "chanserv/set/misc") + if (block.Get("command") != "chanserv/set/misc") continue; - Anope::string cname = block->Get("name"); - Anope::string desc = block->Get("misc_description"); + Anope::string cname = block.Get("name"); + Anope::string desc = block.Get("misc_description"); if (cname.empty() || desc.empty()) continue; descriptions[cname] = desc; - auto numeric = block->Get("misc_numeric"); + auto numeric = block.Get("misc_numeric"); if (numeric >= 1 && numeric <= 999) numerics["cs_set_misc:" + GetAttribute(cname)] = numeric; } diff --git a/modules/chanserv/cs_suspend.cpp b/modules/chanserv/cs_suspend.cpp index 2633bc094..b06fa195a 100644 --- a/modules/chanserv/cs_suspend.cpp +++ b/modules/chanserv/cs_suspend.cpp @@ -67,7 +67,7 @@ public: const Anope::string &chan = params[0]; Anope::string expiry = params[1]; Anope::string reason = params.size() > 2 ? params[2] : ""; - time_t expiry_secs = Config->GetModule(this->owner)->Get("suspendexpire"); + time_t expiry_secs = Config->GetModule(this->owner).Get("suspendexpire"); if (!expiry.empty() && expiry[0] != '+') { @@ -233,9 +233,9 @@ public: { } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Anope::string s = conf->GetModule(this)->Get("show"); + Anope::string s = conf.GetModule(this).Get("show"); commasepstream(s).GetTokens(show); std::transform(show.begin(), show.end(), show.begin(), trim()); } diff --git a/modules/chanserv/cs_xop.cpp b/modules/chanserv/cs_xop.cpp index 55f8eb4bc..3ba3096ae 100644 --- a/modules/chanserv/cs_xop.cpp +++ b/modules/chanserv/cs_xop.cpp @@ -141,7 +141,7 @@ private: if (IRCD->IsChannelValid(mask)) { - if (Config->GetModule("chanserv")->Get("disallow_channel_access")) + if (Config->GetModule("chanserv").Get("disallow_channel_access")) { source.Reply(_("Channels may not be on access lists.")); return; @@ -164,7 +164,7 @@ private: else { na = NickAlias::Find(mask); - if (!na && Config->GetModule("chanserv")->Get("disallow_hostmask_access")) + if (!na && Config->GetModule("chanserv").Get("disallow_hostmask_access")) { source.Reply(_("Masks and unregistered users may not be on access lists.")); return; @@ -212,7 +212,7 @@ private: } } - unsigned access_max = Config->GetModule("chanserv")->Get("accessmax", "1000"); + unsigned access_max = Config->GetModule("chanserv").Get("accessmax", "1000"); if (access_max && ci->GetDeepAccessCount() >= access_max) { source.Reply(_("Sorry, you can only have %d access entries on a channel, including access entries from other channels."), access_max); @@ -618,32 +618,32 @@ public: } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { order.clear(); permissions.clear(); - for (int i = 0; i < conf->CountBlock("privilege"); ++i) + for (int i = 0; i < conf.CountBlock("privilege"); ++i) { - Configuration::Block *block = conf->GetBlock("privilege", i); - const Anope::string &pname = block->Get("name"); + Configuration::Block &block = conf.GetBlock("privilege", i); + const Anope::string &pname = block.Get("name"); Privilege *p = PrivilegeManager::FindPrivilege(pname); if (p == NULL) continue; - const Anope::string &xop = block->Get("xop"); + const Anope::string &xop = block.Get("xop"); if (pname.empty() || xop.empty()) continue; permissions[xop].push_back(pname); } - for (int i = 0; i < conf->CountBlock("command"); ++i) + for (int i = 0; i < conf.CountBlock("command"); ++i) { - Configuration::Block *block = conf->GetBlock("command", i); - const Anope::string &cname = block->Get("name"), - &cserv = block->Get("command"); + Configuration::Block &block = conf.GetBlock("command", i); + const Anope::string &cname = block.Get("name"), + &cserv = block.Get("command"); if (cname.empty() || cserv != "chanserv/xop") continue; diff --git a/modules/chanstats.cpp b/modules/chanstats.cpp index 05c745ff2..65678dcab 100644 --- a/modules/chanstats.cpp +++ b/modules/chanstats.cpp @@ -497,16 +497,16 @@ public: { } - void OnReload(Configuration::Conf *conf) override - { - Configuration::Block *block = conf->GetModule(this); - prefix = block->Get("prefix", "anope_"); - SmileysHappy = block->Get("SmileysHappy"); - SmileysSad = block->Get("SmileysSad"); - SmileysOther = block->Get("SmileysOther"); - NSDefChanstats = block->Get("ns_def_chanstats"); - CSDefChanstats = block->Get("cs_def_chanstats"); - Anope::string engine = block->Get("engine"); + void OnReload(Configuration::Conf &conf) override + { + Configuration::Block &block = conf.GetModule(this); + prefix = block.Get("prefix", "anope_"); + SmileysHappy = block.Get("SmileysHappy"); + SmileysSad = block.Get("SmileysSad"); + SmileysOther = block.Get("SmileysOther"); + NSDefChanstats = block.Get("ns_def_chanstats"); + CSDefChanstats = block.Get("cs_def_chanstats"); + Anope::string engine = block.Get("engine"); this->sql = ServiceReference("SQL::Provider", engine); if (sql) this->CheckTables(); diff --git a/modules/database/db_atheme.cpp b/modules/database/db_atheme.cpp index 2e25b694e..4599a7469 100644 --- a/modules/database/db_atheme.cpp +++ b/modules/database/db_atheme.cpp @@ -500,7 +500,7 @@ private: else { // Generate a new password as we can't use the old one. - auto maxpasslen = Config->GetModule("nickserv")->Get("maxpasslen", "50"); + auto maxpasslen = Config->GetModule("nickserv").Get("maxpasslen", "50"); Anope::Encrypt(Anope::Random(maxpasslen), nc->pass); Log(this) << "Unable to convert the password for " << nc->display << " as Anope does not support the format!"; } @@ -1076,8 +1076,8 @@ private: if (!data->kill) return true; // Don't apply this. - auto kill = Config->GetModule("nickserv")->Get("kill", "60s"); - auto killquick = Config->GetModule("nickserv")->Get("killquick", "20s"); + auto kill = Config->GetModule("nickserv").Get("kill", "60s"); + auto killquick = Config->GetModule("nickserv").Get("killquick", "20s"); auto secs = Anope::Convert(value, kill); if (secs >= kill) nc->Extend("KILLPROTECT"); @@ -1295,7 +1295,7 @@ private: // If an Atheme account was awaiting confirmation but Anope is not // configured to use confirmation then autoconfirm it. - const auto &nsregister = Config->GetModule("ns_register")->Get("registration"); + const auto &nsregister = Config->GetModule("ns_register").Get("registration"); if (nsregister.equals_ci("none")) nc->Shrink("UNCONFIRMED"); @@ -1453,14 +1453,14 @@ public: { } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { flags.clear(); for (int i = 0; i < Config->CountBlock("privilege"); ++i) { - Configuration::Block *priv = Config->GetBlock("privilege", i); - const Anope::string &name = priv->Get("name"); - const Anope::string &value = priv->Get("flag"); + Configuration::Block &priv = Config->GetBlock("privilege", i); + const Anope::string &name = priv.Get("name"); + const Anope::string &value = priv.Get("flag"); if (!name.empty() && !value.empty()) flags[name] = value[0]; } @@ -1468,7 +1468,7 @@ public: EventReturn OnLoadDatabase() override { - const auto dbname = Anope::ExpandData(Config->GetModule(this)->Get("database", "atheme.db")); + const auto dbname = Anope::ExpandData(Config->GetModule(this).Get("database", "atheme.db")); std::ifstream fd(dbname.str()); if (!fd.is_open()) { diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp index 9f2559c9e..4a1e8830d 100644 --- a/modules/database/db_flatfile.cpp +++ b/modules/database/db_flatfile.cpp @@ -109,7 +109,7 @@ class DBFlatFile final last_day = tm->tm_mday; std::set dbs; - dbs.insert(Config->GetModule(this)->Get("database", "anope.db")); + dbs.insert(Config->GetModule(this).Get("database", "anope.db")); for (const auto &type_order : Serialize::Type::GetTypeOrder()) { @@ -135,7 +135,7 @@ class DBFlatFile final Anope::string err = Anope::LastError(); Log(this) << "Unable to back up database " << db << " (" << err << ")!"; - if (!Config->GetModule(this)->Get("nobackupokay")) + if (!Config->GetModule(this).Get("nobackupokay")) { Anope::Quitting = true; Anope::QuitReason = "Unable to back up database " + db + " (" + err + ")"; @@ -146,7 +146,7 @@ class DBFlatFile final backups[db].push_back(newname); - unsigned keepbackups = Config->GetModule(this)->Get("keepbackups"); + unsigned keepbackups = Config->GetModule(this).Get("keepbackups"); if (keepbackups > 0 && backups[db].size() > keepbackups) { unlink(backups[db].front().c_str()); @@ -200,7 +200,7 @@ public: Log(this) << "Error saving databases: " << buf; - if (!Config->GetModule(this)->Get("nobackupokay")) + if (!Config->GetModule(this).Get("nobackupokay")) Anope::Quitting = true; } @@ -208,7 +208,7 @@ public: { std::set tried_dbs; - const auto db_name = Anope::ExpandData(Config->GetModule(this)->Get("database", "anope.db")); + const auto db_name = Anope::ExpandData(Config->GetModule(this).Get("database", "anope.db")); std::fstream fd(db_name.c_str(), std::ios_base::in | std::ios_base::binary); if (!fd.is_open()) @@ -263,7 +263,7 @@ public: int i = -1; #ifndef _WIN32 - if (!Anope::Quitting && Config->GetModule(this)->Get("fork")) + if (!Anope::Quitting && Config->GetModule(this).Get("fork")) { i = fork(); if (i > 0) @@ -290,7 +290,7 @@ public: if (s_type->GetOwner()) db_name = Anope::ExpandData("module_" + s_type->GetOwner()->name + ".db"); else - db_name = Anope::ExpandData(Config->GetModule(this)->Get("database", "anope.db")); + db_name = Anope::ExpandData(Config->GetModule(this).Get("database", "anope.db")); std::fstream *fs = databases[s_type->GetOwner()] = new std::fstream((db_name + ".tmp").c_str(), std::ios_base::out | std::ios_base::trunc | std::ios_base::binary); @@ -319,7 +319,7 @@ public: for (auto &[mod, f] : databases) { - const auto db_name = Anope::ExpandData((mod ? (mod->name + ".db") : Config->GetModule(this)->Get("database", "anope.db"))); + const auto db_name = Anope::ExpandData((mod ? (mod->name + ".db") : Config->GetModule(this).Get("database", "anope.db"))); if (!f->is_open() || !f->good()) { @@ -363,7 +363,7 @@ public: if (stype->GetOwner()) db_name = Anope::ExpandData("module_" + stype->GetOwner()->name + ".db"); else - db_name = Anope::ExpandData(Config->GetModule(this)->Get("database", "anope.db")); + db_name = Anope::ExpandData(Config->GetModule(this).Get("database", "anope.db")); std::fstream fd(db_name.c_str(), std::ios_base::in | std::ios_base::binary); if (!fd.is_open()) diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp index 814740a23..611da4406 100644 --- a/modules/database/db_old.cpp +++ b/modules/database/db_old.cpp @@ -1296,7 +1296,7 @@ public: { - hashm = Config->GetModule(this)->Get("hash"); + hashm = Config->GetModule(this).Get("hash"); if (hashm != "md5" && hashm != "oldmd5" && hashm != "sha1" && hashm != "plain" && hashm != "sha256") throw ModuleException("Invalid hash method"); diff --git a/modules/database/db_redis.cpp b/modules/database/db_redis.cpp index a4826349b..832e22590 100644 --- a/modules/database/db_redis.cpp +++ b/modules/database/db_redis.cpp @@ -171,10 +171,10 @@ public: this->updated_items.clear(); } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Configuration::Block *block = conf->GetModule(this); - this->redis = ServiceReference("Redis::Provider", block->Get("engine", "redis/main")); + Configuration::Block &block = conf.GetModule(this); + this->redis = ServiceReference("Redis::Provider", block.Get("engine", "redis/main")); } EventReturn OnLoadDatabase() override diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp index bfcd59a3d..4b120f3b0 100644 --- a/modules/database/db_sql.cpp +++ b/modules/database/db_sql.cpp @@ -158,12 +158,12 @@ public: this->imported = true; } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Configuration::Block *block = conf->GetModule(this); - this->sql = ServiceReference("SQL::Provider", block->Get("engine")); - this->prefix = block->Get("prefix", "anope_db_"); - this->import = block->Get("import"); + Configuration::Block &block = conf.GetModule(this); + this->sql = ServiceReference("SQL::Provider", block.Get("engine")); + this->prefix = block.Get("prefix", "anope_db_"); + this->import = block.Get("import"); } void OnPostInit() override diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp index e0f3adb08..afd884913 100644 --- a/modules/database/db_sql_live.cpp +++ b/modules/database/db_sql_live.cpp @@ -37,7 +37,7 @@ private: } else { - if (Anope::CurTime - Config->GetBlock("options")->Get("updatetimeout", "2m") > lastwarn) + if (Anope::CurTime - Config->GetBlock("options").Get("updatetimeout", "2m") > lastwarn) { Log() << "Unable to locate SQL reference, going to readonly..."; Anope::ReadOnly = this->ro = true; @@ -138,11 +138,11 @@ public: init = false; } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Configuration::Block *block = conf->GetModule(this); - this->SQL = ServiceReference("SQL::Provider", block->Get("engine")); - this->prefix = block->Get("prefix", "anope_db_"); + Configuration::Block &block = conf.GetModule(this); + this->SQL = ServiceReference("SQL::Provider", block.Get("engine")); + this->prefix = block.Get("prefix", "anope_db_"); } void OnSerializableConstruct(Serializable *obj) override diff --git a/modules/dns.cpp b/modules/dns.cpp index f94854058..372c22d1e 100644 --- a/modules/dns.cpp +++ b/modules/dns.cpp @@ -1045,23 +1045,23 @@ public: } } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Configuration::Block *block = conf->GetModule(this); + Configuration::Block &block = conf.GetModule(this); - nameserver = block->Get("nameserver", "127.0.0.1"); - timeout = block->Get("timeout", "5"); - ip = block->Get("ip", "0.0.0.0"); - port = block->Get("port", "53"); - admin = block->Get("admin", "admin@example.com"); - nameservers = block->Get("nameservers", "ns1.example.com"); - refresh = block->Get("refresh", "3600"); + nameserver = block.Get("nameserver", "127.0.0.1"); + timeout = block.Get("timeout", "5"); + ip = block.Get("ip", "0.0.0.0"); + port = block.Get("port", "53"); + admin = block.Get("admin", "admin@example.com"); + nameservers = block.Get("nameservers", "ns1.example.com"); + refresh = block.Get("refresh", "3600"); - for (int i = 0; i < block->CountBlock("notify"); ++i) + for (int i = 0; i < block.CountBlock("notify"); ++i) { - Configuration::Block *n = block->GetBlock("notify", i); - Anope::string nip = n->Get("ip"); - short nport = n->Get("port"); + Configuration::Block &n = block.GetBlock("notify", i); + Anope::string nip = n.Get("ip"); + short nport = n.Get("port"); notify.emplace_back(nip, nport); } diff --git a/modules/dnsbl.cpp b/modules/dnsbl.cpp index deedd85e2..6db41ba84 100644 --- a/modules/dnsbl.cpp +++ b/modules/dnsbl.cpp @@ -77,7 +77,7 @@ public: reason = reason.replace_all_cs("%h", user->host); reason = reason.replace_all_cs("%i", addr); reason = reason.replace_all_cs("%r", reply ? reply->reason : ""); - reason = reason.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get("networkname")); + reason = reason.replace_all_cs("%N", Config->GetBlock("networkinfo").Get("networkname")); BotInfo *OperServ = Config->GetClient("OperServ"); Log(creator, "dnsbl", OperServ) << user->GetMask() << " (" << addr << ") appears in " << this->blacklist.name; @@ -110,33 +110,33 @@ public: } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Configuration::Block *block = conf->GetModule(this); - this->check_on_connect = block->Get("check_on_connect"); - this->check_on_netburst = block->Get("check_on_netburst"); - this->add_to_akill = block->Get("add_to_akill", "yes"); + Configuration::Block &block = conf.GetModule(this); + this->check_on_connect = block.Get("check_on_connect"); + this->check_on_netburst = block.Get("check_on_netburst"); + this->add_to_akill = block.Get("add_to_akill", "yes"); this->blacklists.clear(); - for (int i = 0; i < block->CountBlock("blacklist"); ++i) + for (int i = 0; i < block.CountBlock("blacklist"); ++i) { - Configuration::Block *bl = block->GetBlock("blacklist", i); + Configuration::Block &bl = block.GetBlock("blacklist", i); Blacklist blacklist; - blacklist.name = bl->Get("name"); + blacklist.name = bl.Get("name"); if (blacklist.name.empty()) continue; - blacklist.bantime = bl->Get("time", "4h"); - blacklist.reason = bl->Get("reason"); + blacklist.bantime = bl.Get("time", "4h"); + blacklist.reason = bl.Get("reason"); - for (int j = 0; j < bl->CountBlock("reply"); ++j) + for (int j = 0; j < bl.CountBlock("reply"); ++j) { - Configuration::Block *reply = bl->GetBlock("reply", j); + Configuration::Block &reply = bl.GetBlock("reply", j); Blacklist::Reply r; - r.code = reply->Get("code"); - r.reason = reply->Get("reason"); - r.allow_account = reply->Get("allow_account"); + r.code = reply.Get("code"); + r.reason = reply.Get("reason"); + r.allow_account = reply.Get("allow_account"); blacklist.replies.push_back(r); } @@ -145,10 +145,10 @@ public: } this->exempts.clear(); - for (int i = 0; i < block->CountBlock("exempt"); ++i) + for (int i = 0; i < block.CountBlock("exempt"); ++i) { - Configuration::Block *bl = block->GetBlock("exempt", i); - this->exempts.insert(bl->Get("ip")); + Configuration::Block &bl = block.GetBlock("exempt", i); + this->exempts.insert(bl.Get("ip")); } } diff --git a/modules/encryption/enc_bcrypt.cpp b/modules/encryption/enc_bcrypt.cpp index 648f95834..1ac37e1fe 100644 --- a/modules/encryption/enc_bcrypt.cpp +++ b/modules/encryption/enc_bcrypt.cpp @@ -165,11 +165,11 @@ public: } } - void OnReload(Configuration::Conf *conf) overri