From 3f5f84c92c1a424843b430c60a50efa600ae1236 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 5 May 2013 21:18:47 -0400 Subject: [PATCH] The const char* specialization of this no longer works --- include/config.h | 1 - modules/commands/bs_set.cpp | 2 +- modules/commands/cs_list.cpp | 2 +- modules/commands/ns_register.cpp | 4 ++-- modules/commands/ns_resetpass.cpp | 4 ++-- modules/commands/ns_set.cpp | 4 ++-- modules/pseudoclients/memoserv.cpp | 4 ++-- src/config.cpp | 11 +++-------- src/init.cpp | 4 ++-- src/messages.cpp | 4 ++-- 10 files changed, 17 insertions(+), 23 deletions(-) diff --git a/include/config.h b/include/config.h index 194b7fe74..82edecca6 100644 --- a/include/config.h +++ b/include/config.h @@ -66,7 +66,6 @@ namespace Configuration template<> CoreExport const Anope::string Block::Get(const Anope::string &tag, const Anope::string& def) const; template<> CoreExport time_t Block::Get(const Anope::string &tag, const Anope::string &def) const; - template<> CoreExport const char* Block::Get(const Anope::string &tag, const Anope::string &def) const; template<> CoreExport bool Block::Get(const Anope::string &tag, const Anope::string &def) const; /** Represents a configuration file diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp index 20a53faf3..95500ac94 100644 --- a/modules/commands/bs_set.cpp +++ b/modules/commands/bs_set.cpp @@ -315,7 +315,7 @@ class CommandBSSetFantasy : public Command "Note that users wanting to use fantaisist\n" "commands MUST have enough access for both\n" "the FANTASIA and the command they are executing."), - Config->GetModule("botserv")->Get("fantasycharacter", "!")); + Config->GetModule("botserv")->Get("fantasycharacter", "!").c_str()); return true; } }; diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index 9718b73a1..13492c007 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -155,7 +155,7 @@ class CommandCSList : public Command { 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")); + "Enclose your pattern in // if this is desired."), Config->GetBlock("options")->Get("regexengine").c_str()); } return true; diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index 6da7d4db1..da2f6de59 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -373,8 +373,8 @@ static bool SendRegmail(User *u, const NickAlias *na, const BotInfo *bi) else codebuf = *code; - Anope::string subject = Language::Translate(na->nc, Config->GetBlock("mail")->Get("registration_subject")), - message = Language::Translate(na->nc, Config->GetBlock("mail")->Get("registration_message")); + Anope::string subject = Language::Translate(na->nc, Config->GetBlock("mail")->Get("registration_subject").c_str()), + message = Language::Translate(na->nc, Config->GetBlock("mail")->Get("registration_message").c_str()); subject = subject.replace_all_cs("%n", na->nick); subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get("networkname")); diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp index 62fa0905f..bf1e8dacf 100644 --- a/modules/commands/ns_resetpass.cpp +++ b/modules/commands/ns_resetpass.cpp @@ -139,8 +139,8 @@ static bool SendResetEmail(User *u, const NickAlias *na, const BotInfo *bi) for (idx = 0; idx < 20; ++idx) passcode += chars[1 + static_cast((static_cast(max - min)) * static_cast(rand()) / 65536.0) + min]; - Anope::string subject = Language::Translate(na->nc, Config->GetBlock("mail")->Get("reset_subject")), - message = Language::Translate(na->nc, Config->GetBlock("mail")->Get("reset_message")); + Anope::string subject = Language::Translate(na->nc, Config->GetBlock("mail")->Get("reset_subject").c_str()), + message = Language::Translate(na->nc, Config->GetBlock("mail")->Get("reset_message").c_str()); subject = subject.replace_all_cs("%n", na->nick); subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get("networkname")); diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index f0bff477e..93024b437 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -464,8 +464,8 @@ class CommandNSSetEmail : public Command u->Account()->Extend("ns_set_email_passcode", new ExtensibleItemClass(code)); - Anope::string subject = Config->GetBlock("mail")->Get("emailchange_subject"), - message = Config->GetBlock("mail")->Get("emailchange_message"); + Anope::string subject = Config->GetBlock("mail")->Get("emailchange_subject"), + message = Config->GetBlock("mail")->Get("emailchange_message"); subject = subject.replace_all_cs("%e", u->Account()->email); subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get("networkname")); diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp index 13a34137c..1988961cd 100644 --- a/modules/pseudoclients/memoserv.cpp +++ b/modules/pseudoclients/memoserv.cpp @@ -15,8 +15,8 @@ static bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m) { - Anope::string subject = Language::Translate(nc, Config->GetBlock("mail")->Get("memo_subject")), - message = Language::Translate(Config->GetBlock("mail")->Get("memo_message")); + Anope::string subject = Language::Translate(nc, Config->GetBlock("mail")->Get("memo_subject").c_str()), + message = Language::Translate(Config->GetBlock("mail")->Get("memo_message").c_str()); subject = subject.replace_all_cs("%n", nc->display); subject = subject.replace_all_cs("%s", m->sender); diff --git a/src/config.cpp b/src/config.cpp index eac2be8c6..17d15a0d9 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -94,11 +94,6 @@ template<> time_t Block::Get(const Anope::string &tag, const Anope::string &def) return Anope::DoTime(Get(tag, def)); } -template<> const char* Block::Get(const Anope::string &tag, const Anope::string &def) const -{ - return this->Get(tag, def).c_str(); -} - template<> bool Block::Get(const Anope::string &tag, const Anope::string &def) const { const Anope::string &str = Get(tag, def); @@ -507,7 +502,7 @@ Conf::Conf() : Block("") { try { - Anope::casemap = std::locale(options->Get("casemap")); + Anope::casemap = std::locale(options->Get("casemap").c_str()); } catch (const std::runtime_error &) { @@ -524,7 +519,7 @@ Conf::Conf() : Block("") if (!options->Get("user").empty()) { errno = 0; - struct passwd *u = getpwnam(options->Get("user")); + struct passwd *u = getpwnam(options->Get("user").c_str()); if (u == NULL) Log() << "Unable to setuid to " << options->Get("user") << ": " << Anope::LastError(); else if (setuid(u->pw_uid) == -1) @@ -535,7 +530,7 @@ Conf::Conf() : Block("") if (!options->Get("group").empty()) { errno = 0; - struct group *g = getgrnam(options->Get("group")); + struct group *g = getgrnam(options->Get("group").c_str()); if (g == NULL) Log() << "Unable to setgid to " << options->Get("group") << ": " << Anope::LastError(); else if (setuid(g->gr_gid) == -1) diff --git a/src/init.cpp b/src/init.cpp index faa57c18b..205fb2501 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -197,14 +197,14 @@ static void InitSignals() static void remove_pidfile() { - remove(Config->GetBlock("serverinfo")->Get("pid")); + remove(Config->GetBlock("serverinfo")->Get("pid").c_str()); } /* Create our PID file and write the PID to it. */ static void write_pidfile() { - FILE *pidfile = fopen(Config->GetBlock("serverinfo")->Get("pid"), "w"); + FILE *pidfile = fopen(Config->GetBlock("serverinfo")->Get("pid").c_str(), "w"); if (pidfile) { #ifdef _WIN32 diff --git a/src/messages.cpp b/src/messages.cpp index 9bbfb42c0..ed601a206 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -225,7 +225,7 @@ void MOTD::Run(MessageSource &source, const std::vector ¶ms) if (s != Me) return; - FILE *f = fopen(Config->GetBlock("serverinfo")->Get("motd"), "r"); + FILE *f = fopen(Config->GetBlock("serverinfo")->Get("motd").c_str(), "r"); if (f) { IRCD->SendNumeric(375, source.GetSource(), ":- %s Message of the Day", s->GetName().c_str()); @@ -454,7 +454,7 @@ void Whois::Run(MessageSource &source, const std::vector ¶ms) IRCD->SendNumeric(311, source.GetSource(), "%s %s %s * :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->realname.c_str()); if (bi) IRCD->SendNumeric(307, source.GetSource(), "%s :is a registered nick", bi->nick.c_str()); - IRCD->SendNumeric(312, source.GetSource(), "%s %s :%s", u->nick.c_str(), Me->GetName().c_str(), Config->GetBlock("serverinfo")->Get("description")); + IRCD->SendNumeric(312, source.GetSource(), "%s %s :%s", u->nick.c_str(), Me->GetName().c_str(), Config->GetBlock("serverinfo")->Get("description").c_str()); if (bi) IRCD->SendNumeric(317, source.GetSource(), "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), static_cast(Anope::CurTime - bi->lastmsg), static_cast(bi->signon)); IRCD->SendNumeric(318, source.GetSource(), "%s :End of /WHOIS list.", params[0].c_str());