From ae38212c1ce829c783edf971081c90137abb49a0 Mon Sep 17 00:00:00 2001 From: Naram Qashat Date: Sun, 25 Jul 2010 21:58:20 -0400 Subject: Epic commit to replace most of the strings in Anope with a single Anope::string class, plus some other little fixes here and there. If you follow 1.9.x development and are testing things, THIS is one of those things that NEEDS testing. --- modules/extra/cs_appendtopic.cpp | 48 ++++---- modules/extra/cs_enforce.cpp | 49 ++++---- modules/extra/cs_set_misc.cpp | 74 +++++------ modules/extra/cs_tban.cpp | 68 +++++------ modules/extra/hs_request.cpp | 204 +++++++++++++------------------ modules/extra/m_helpchan.cpp | 10 +- modules/extra/m_ssl.cpp | 16 +-- modules/extra/mysql/db_mysql.h | 6 +- modules/extra/mysql/db_mysql_execute.cpp | 2 +- modules/extra/mysql/db_mysql_read.cpp | 20 +-- modules/extra/mysql/db_mysql_write.cpp | 18 +-- modules/extra/ns_maxemail.cpp | 32 ++--- modules/extra/ns_set_misc.cpp | 83 ++++++------- 13 files changed, 282 insertions(+), 348 deletions(-) (limited to 'modules/extra') diff --git a/modules/extra/cs_appendtopic.cpp b/modules/extra/cs_appendtopic.cpp index 03f20ba6c..8d376e661 100644 --- a/modules/extra/cs_appendtopic.cpp +++ b/modules/extra/cs_appendtopic.cpp @@ -38,7 +38,7 @@ */ /* ---------------------------------------------------------------------- */ -/* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */ +/* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */ /* ---------------------------------------------------------------------- */ enum @@ -58,11 +58,11 @@ class CommandCSAppendTopic : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(User *u, const std::vector ¶ms) { - const char *chan = params[0].c_str(); - const char *newtopic = params[1].c_str(); - char topic[1024]; + Anope::string chan = params[0]; + Anope::string newtopic = params[1]; + Anope::string topic; Channel *c = findchan(chan); ChannelInfo *ci; @@ -70,26 +70,24 @@ class CommandCSAppendTopic : public Command ci = c->ci; if (!c) - notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan.c_str()); else if (!check_access(u, ci, CA_TOPIC)) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else { - if (ci->last_topic) + if (!ci->last_topic.empty()) { - snprintf(topic, sizeof(topic), "%s %s", ci->last_topic, newtopic); - delete [] ci->last_topic; + topic = ci->last_topic + " " + newtopic; + ci->last_topic.clear(); } else - strscpy(topic, newtopic, sizeof(topic)); + topic = newtopic; - ci->last_topic = *topic ? sstrdup(topic) : NULL; + ci->last_topic = topic; ci->last_topic_setter = u->nick; ci->last_topic_time = time(NULL); - if (c->topic) - delete [] c->topic; - c->topic = *topic ? sstrdup(topic) : NULL; + c->topic = topic; c->topic_setter = u->nick; if (ircd->topictsbackward) c->topic_time = c->topic_time - 1; @@ -101,16 +99,16 @@ class CommandCSAppendTopic : public Command if (ircd->join2set && whosends(ci) == ChanServ) { ChanServ->Join(c); - ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ); // XXX + ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ.c_str()); // XXX } - ircdproto->SendTopic(whosends(ci), c, u->nick.c_str(), topic); + ircdproto->SendTopic(whosends(ci), c, u->nick, topic); if (ircd->join2set && whosends(ci) == ChanServ) ChanServ->Part(c); } return MOD_CONT; } - bool OnHelp(User *u, const ci::string &subcommand) + bool OnHelp(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_ChanServ, u, LNG_APPENDTOPIC_SYNTAX); u->SendMessage(Config.s_ChanServ, " "); @@ -119,7 +117,7 @@ class CommandCSAppendTopic : public Command return true; } - void OnSyntaxError(User *u, const ci::string &subcommand) + void OnSyntaxError(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_ChanServ, u, LNG_APPENDTOPIC_SYNTAX); } @@ -133,7 +131,7 @@ class CommandCSAppendTopic : public Command class CSAppendTopic : public Module { public: - CSAppendTopic(const std::string &modname, const std::string &creator) : Module(modname, creator) + CSAppendTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) { me = this; @@ -143,7 +141,7 @@ class CSAppendTopic : public Module this->AddCommand(ChanServ, new CommandCSAppendTopic()); /* English (US) */ - const char* langtable_en_us[] = { + const char *langtable_en_us[] = { /* LNG_CHAN_HELP */ " APPENDTOPIC Add text to a channels topic", /* LNG_CHAN_HELP_APPENDTOPIC */ @@ -155,7 +153,7 @@ class CSAppendTopic : public Module }; /* Dutch (NL) */ - const char* langtable_nl[] = { + const char *langtable_nl[] = { /* LNG_CHAN_HELP */ " APPENDTOPIC Voeg tekst aan een kanaal onderwerp toe", /* LNG_CHAN_HELP_APPENDTOPIC */ @@ -168,7 +166,7 @@ class CSAppendTopic : public Module }; /* German (DE) */ - const char* langtable_de[] = { + const char *langtable_de[] = { /* LNG_CHAN_HELP */ " APPENDTOPIC Fьgt einen Text zu einem Channel-Topic hinzu.", /* LNG_CHAN_HELP_APPENDTOPIC */ @@ -180,7 +178,7 @@ class CSAppendTopic : public Module }; /* Portuguese (PT) */ - const char* langtable_pt[] = { + const char *langtable_pt[] = { /* LNG_CHAN_HELP */ " APPENDTOPIC Adiciona texto ao tуpico de um canal", /* LNG_CHAN_HELP_APPENDTOPIC */ @@ -192,7 +190,7 @@ class CSAppendTopic : public Module }; /* Russian (RU) */ - const char* langtable_ru[] = { + const char *langtable_ru[] = { /* LNG_CHAN_HELP */ " APPENDTOPIC Добавляет текст к топику канала", /* LNG_CHAN_HELP_APPENDTOPIC */ @@ -204,7 +202,7 @@ class CSAppendTopic : public Module }; /* Italian (IT) */ - const char* langtable_it[] = { + const char *langtable_it[] = { /* LNG_CHAN_HELP */ " APPENDTOPIC Aggiunge del testo al topic di un canale", /* LNG_CHAN_HELP_APPENDTOPIC */ diff --git a/modules/extra/cs_enforce.cpp b/modules/extra/cs_enforce.cpp index c4cfbecc9..a32d5a8f5 100644 --- a/modules/extra/cs_enforce.cpp +++ b/modules/extra/cs_enforce.cpp @@ -88,7 +88,7 @@ class CommandCSEnforce : public Command { ChannelInfo *ci; int16 old_nojoin_level; - char mask[BUFSIZE]; + Anope::string mask; const char *reason; if (!(ci = c->ci)) @@ -106,7 +106,7 @@ class CommandCSEnforce : public Command if (check_access(uc->user, ci, CA_NOJOIN)) { - get_idealban(ci, uc->user, mask, sizeof(mask)); + get_idealban(ci, uc->user, mask); reason = getstring(uc->user, CHAN_NOT_ALLOWED_TO_JOIN); c->SetMode(NULL, CMODE_BAN, mask); c->Kick(NULL, uc->user, "%s", reason); @@ -119,8 +119,7 @@ class CommandCSEnforce : public Command void DoCModeR(Channel *c) { ChannelInfo *ci; - char mask[BUFSIZE]; - const char *reason; + Anope::string mask; if (!(ci = c->ci)) return; @@ -133,11 +132,11 @@ class CommandCSEnforce : public Command if (!uc->user->IsIdentified()) { - get_idealban(ci, uc->user, mask, sizeof(mask)); - reason = getstring(uc->user, CHAN_NOT_ALLOWED_TO_JOIN); + get_idealban(ci, uc->user, mask); + Anope::string reason = getstring(uc->user, CHAN_NOT_ALLOWED_TO_JOIN); if (!c->HasMode(CMODE_REGISTERED)) c->SetMode(NULL, CMODE_BAN, mask); - c->Kick(NULL, uc->user, "%s", reason); + c->Kick(NULL, uc->user, "%s", reason.c_str()); } } } @@ -146,10 +145,10 @@ class CommandCSEnforce : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(User *u, const std::vector ¶ms) { - const char *chan = params[0].c_str(); - ci::string what = params.size() > 1 ? params[1] : ""; + Anope::string chan = params[0]; + Anope::string what = params.size() > 1 ? params[1] : ""; Channel *c = findchan(chan); ChannelInfo *ci; @@ -157,32 +156,32 @@ class CommandCSEnforce : public Command ci = c->ci; if (!c) - notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan.c_str()); else if (!check_access(u, ci, CA_AKICK)) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); else { - if (what.empty() || what == "SET") + if (what.empty() || what.equals_ci("SET")) { this->DoSet(c); me->NoticeLang(Config.s_ChanServ, u, LNG_CHAN_RESPONSE, !what.empty() ? what.c_str() : "SET"); } - else if (what == "MODES") + else if (what.equals_ci("MODES")) { this->DoModes(c); me->NoticeLang(Config.s_ChanServ, u, LNG_CHAN_RESPONSE, what.c_str()); } - else if (what == "SECUREOPS") + else if (what.equals_ci("SECUREOPS")) { this->DoSecureOps(c); me->NoticeLang(Config.s_ChanServ, u, LNG_CHAN_RESPONSE, what.c_str()); } - else if (what == "RESTRICTED") + else if (what.equals_ci("RESTRICTED")) { this->DoRestricted(c); me->NoticeLang(Config.s_ChanServ, u, LNG_CHAN_RESPONSE, what.c_str()); } - else if (what == "+R") + else if (what.equals_ci("+R")) { this->DoCModeR(c); me->NoticeLang(Config.s_ChanServ, u, LNG_CHAN_RESPONSE, what.c_str()); @@ -194,7 +193,7 @@ class CommandCSEnforce : public Command return MOD_CONT; } - bool OnHelp(User *u, const ci::string &subcommand) + bool OnHelp(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_ChanServ, u, LNG_ENFORCE_SYNTAX); u->SendMessage(Config.s_ChanServ, " "); @@ -208,7 +207,7 @@ class CommandCSEnforce : public Command return true; } - void OnSyntaxError(User *u, const ci::string &subcommand) + void OnSyntaxError(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_ChanServ, u, LNG_ENFORCE_SYNTAX); } @@ -222,7 +221,7 @@ class CommandCSEnforce : public Command class CSEnforce : public Module { public: - CSEnforce(const std::string &modname, const std::string &creator) : Module(modname, creator) + CSEnforce(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) { me = this; @@ -232,7 +231,7 @@ class CSEnforce : public Module this->AddCommand(ChanServ, new CommandCSEnforce()); /* English (US) */ - const char* langtable_en_us[] = { + const char *langtable_en_us[] = { /* LNG_CHAN_HELP */ " ENFORCE Enforce various channel modes and set options", /* LNG_ENFORCE_SYNTAX */ @@ -266,7 +265,7 @@ class CSEnforce : public Module }; /* Dutch (NL) */ - const char* langtable_nl[] = { + const char *langtable_nl[] = { /* LNG_CHAN_HELP */ " ENFORCE Forceer enkele kanaalmodes en set-opties", /* LNG_ENFORCE_SYNTAX */ @@ -302,7 +301,7 @@ class CSEnforce : public Module }; /* German (DE) */ - const char* langtable_de[] = { + const char *langtable_de[] = { /* LNG_CHAN_HELP */ " ENFORCE Erzwingt verschieden Modes und SET Optionen", /* LNG_ENFORCE_SYNTAX */ @@ -335,7 +334,7 @@ class CSEnforce : public Module }; /* Portuguese (PT) */ - const char* langtable_pt[] = { + const char *langtable_pt[] = { /* LNG_CHAN_HELP */ " ENFORCE Verifica o cumprimento de vбrios modos de canal e opзхes ajustadas", /* LNG_ENFORCE_SYNTAX */ @@ -368,7 +367,7 @@ class CSEnforce : public Module }; /* Russian (RU) */ - const char* langtable_ru[] = { + const char *langtable_ru[] = { /* LNG_CHAN_HELP */ " ENFORCE Перепроверка и установка различных режимов и опций канала", /* LNG_ENFORCE_SYNTAX */ @@ -400,7 +399,7 @@ class CSEnforce : public Module }; /* Italian (IT) */ - const char* langtable_it[] = { + const char *langtable_it[] = { /* LNG_CHAN_HELP */ " ENFORCE Forza diversi modi di canale ed opzioni SET", /* LNG_ENFORCE_SYNTAX */ diff --git a/modules/extra/cs_set_misc.cpp b/modules/extra/cs_set_misc.cpp index 453e242a3..7cffe6866 100644 --- a/modules/extra/cs_set_misc.cpp +++ b/modules/extra/cs_set_misc.cpp @@ -1,5 +1,4 @@ /* - * * (C) 2003-2010 Anope Team * Contact us at team@anope.org * @@ -15,32 +14,30 @@ class CommandCSSetMisc : public Command { - std::string Desc; + Anope::string Desc; public: - CommandCSSetMisc(const ci::string &cname, const std::string &desc, const ci::string &cpermission = "") : Command(cname, 1, 2, cpermission), Desc(desc) + CommandCSSetMisc(const Anope::string &cname, const Anope::string &desc, const Anope::string &cpermission = "") : Command(cname, 1, 2, cpermission), Desc(desc) { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(User *u, const std::vector ¶ms) { ChannelInfo *ci = cs_findchan(params[0]); assert(ci); - ci->Shrink("chanserv:" + std::string(this->name.c_str())); + ci->Shrink("chanserv:" + this->name); if (params.size() > 1) { - ci->Extend("chanserv:" + std::string(this->name.c_str()), new ExtensibleItemRegular(params[1])); + ci->Extend("chanserv:" + this->name, new ExtensibleItemRegular(params[1])); notice_lang(Config.s_ChanServ, u, CHAN_SETTING_CHANGED, this->name.c_str(), ci->name.c_str(), params[1].c_str()); } else - { notice_lang(Config.s_ChanServ, u, CHAN_SETTING_UNSET, this->name.c_str(), ci->name.c_str()); - } return MOD_CONT; } - void OnSyntaxError(User *u, const ci::string &) + void OnSyntaxError(User *u, const Anope::string &) { syntax_error(Config.s_ChanServ, u, "SET", CHAN_SET_SYNTAX); } @@ -54,11 +51,11 @@ class CommandCSSetMisc : public Command class CommandCSSASetMisc : public CommandCSSetMisc { public: - CommandCSSASetMisc(const ci::string &cname, const std::string &desc) : CommandCSSetMisc(cname, desc, "chanserv/saset/" + cname) + CommandCSSASetMisc(const Anope::string &cname, const Anope::string &desc) : CommandCSSetMisc(cname, desc, "chanserv/saset/" + cname) { } - void OnSyntaxError(User *u, const ci::string &) + void OnSyntaxError(User *u, const Anope::string &) { syntax_error(Config.s_ChanServ, u, "SASET", CHAN_SASET_SYNTAX); } @@ -68,14 +65,14 @@ class CSSetMisc : public Module { struct CommandInfo { - std::string Name; - std::string Desc; + Anope::string Name; + Anope::string Desc; bool ShowHidden; - CommandInfo(const std::string &name, const std::string &desc, bool showhidden) : Name(name), Desc(desc), ShowHidden(showhidden) { } + CommandInfo(const Anope::string &name, const Anope::string &desc, bool showhidden) : Name(name), Desc(desc), ShowHidden(showhidden) { } }; - std::map Commands; + std::map Commands; void RemoveAll() { @@ -88,12 +85,12 @@ class CSSetMisc : public Module if (!set && !saset) return; - for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) + for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) { if (set) - set->DelSubcommand(it->first.c_str()); + set->DelSubcommand(it->first); if (saset) - saset->DelSubcommand(it->first.c_str()); + saset->DelSubcommand(it->first); delete it->second; } @@ -101,7 +98,7 @@ class CSSetMisc : public Module } public: - CSSetMisc(const std::string &modname, const std::string &creator) : Module(modname, creator) + CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); this->SetType(CORE); @@ -128,12 +125,12 @@ class CSSetMisc : public Module ConfigReader config; - for (int i = 0; true; ++i) + for (int i = 0, num = config.Enumerate("cs_set_misc"); i < num; ++i) { - std::string cname = config.ReadValue("cs_set_misc", "name", "", i); + Anope::string cname = config.ReadValue("cs_set_misc", "name", "", i); if (cname.empty()) - break; - std::string desc = config.ReadValue("cs_set_misc", "desc", "", i); + continue; + Anope::string desc = config.ReadValue("cs_set_misc", "desc", "", i); bool showhidden = config.ReadFlag("cs_set_misc", "operonly", "no", i); CommandInfo *info = new CommandInfo(cname, desc, showhidden); @@ -145,49 +142,40 @@ class CSSetMisc : public Module } if (set) - set->AddSubcommand(new CommandCSSetMisc(cname.c_str(), desc)); + set->AddSubcommand(new CommandCSSetMisc(cname, desc)); if (saset) - saset->AddSubcommand(new CommandCSSASetMisc(cname.c_str(), desc)); + saset->AddSubcommand(new CommandCSSASetMisc(cname, desc)); } } void OnChanInfo(User *u, ChannelInfo *ci, bool ShowHidden) { - for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) + for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) { if (!ShowHidden && it->second->ShowHidden) continue; - ci::string value; + Anope::string value; if (ci->GetExtRegular("chanserv:" + it->first, value)) - { u->SendMessage(Config.s_ChanServ, " %s: %s", it->first.c_str(), value.c_str()); - } } } - void OnDatabaseWriteMetadata(void (*WriteMetadata)(const std::string &, const std::string &), ChannelInfo *ci) + void OnDatabaseWriteMetadata(void (*WriteMetadata)(const Anope::string &, const Anope::string &), ChannelInfo *ci) { - for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) + for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) { - ci::string value; - + Anope::string value; if (ci->GetExtRegular("chanserv:" + it->first, value)) - { - WriteMetadata(it->first, ":" + std::string(value.c_str())); - } + WriteMetadata(it->first, ":" + value); } } - EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const std::string &key, const std::vector ¶ms) + EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, const std::vector ¶ms) { - for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) - { + for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) if (key == it->first) - { - ci->Extend("chanserv:" + it->first, new ExtensibleItemRegular(params[0].c_str())); - } - } + ci->Extend("chanserv:" + it->first, new ExtensibleItemRegular(params[0])); return EVENT_CONTINUE; } diff --git a/modules/extra/cs_tban.cpp b/modules/extra/cs_tban.cpp index 844606222..55ab8d1cb 100644 --- a/modules/extra/cs_tban.cpp +++ b/modules/extra/cs_tban.cpp @@ -19,9 +19,9 @@ #define AUTHOR "Rob" -void mySendResponse(User *u, const char *channel, char *mask, const char *time); +void mySendResponse(User *u, const Anope::string &channel, const Anope::string &mask, const Anope::string &time); -void addBan(Channel *c, time_t timeout, char *banmask); +void addBan(Channel *c, time_t timeout, const Anope::string &banmask); int canBanUser(Channel *c, User *u, User *u2); void mAddLanguages(); @@ -44,24 +44,24 @@ class CommandCSTBan : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(User *u, const std::vector ¶ms) { - char mask[BUFSIZE]; + Anope::string mask; Channel *c; User *u2 = NULL; - const char *chan = params[0].c_str(); - const char *nick = params[1].c_str(); - const char *time = params[2].c_str(); + Anope::string chan = params[0]; + Anope::string nick = params[1]; + Anope::string time = params[2]; if (!(c = findchan(chan))) - notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan.c_str()); else if (!(u2 = finduser(nick))) - notice_lang(Config.s_ChanServ, u, NICK_X_NOT_IN_USE, nick); + notice_lang(Config.s_ChanServ, u, NICK_X_NOT_IN_USE, nick.c_str()); else if (canBanUser(c, u, u2)) { - get_idealban(c->ci, u2, mask, sizeof(mask)); + get_idealban(c->ci, u2, mask); addBan(c, dotime(time), mask); mySendResponse(u, chan, mask, time); } @@ -69,7 +69,7 @@ class CommandCSTBan : public Command return MOD_CONT; } - bool OnHelp(User *u, const ci::string &subcommand) + bool OnHelp(User *u, const Anope::string &subcommand) { this->OnSyntaxError(u, ""); u->SendMessage(Config.s_ChanServ, " "); @@ -78,7 +78,7 @@ class CommandCSTBan : public Command return true; } - void OnSyntaxError(User *u, const ci::string &subcommand) + void OnSyntaxError(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_ChanServ, u, TBAN_SYNTAX); } @@ -92,7 +92,7 @@ class CommandCSTBan : public Command class CSTBan : public Module { public: - CSTBan(const std::string &modname, const std::string &creator) : Module(modname, creator) + CSTBan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) { me = this; @@ -101,7 +101,7 @@ class CSTBan : public Module this->SetAuthor(AUTHOR); this->SetType(SUPPORTED); - const char* langtable_en_us[] = { + const char *langtable_en_us[] = { " TBAN Bans the user for a given length of time", "Syntax: TBAN channel nick time", "Bans the given user from a channel for a specified length of\n" @@ -109,7 +109,7 @@ class CSTBan : public Module "%s banned from %s, will auto-expire in %s" }; - const char* langtable_nl[] = { + const char *langtable_nl[] = { " TBAN Verban een gebruiker voor een bepaalde tijd", "Syntax: TBAN kanaal nick tijd", "Verbant de gegeven gebruiken van het gegeven kanaal voor de\n" @@ -118,7 +118,7 @@ class CSTBan : public Module "%s verbannen van %s, zal verlopen in %s" }; - const char* langtable_de[] = { + const char *langtable_de[] = { " TBAN Bant ein User fьr eine bestimmte Zeit aus ein Channel", "Syntax: TBAN Channel Nickname Zeit", "Bant ein User fьr eine bestimmte Zeit aus ein Channel\n" @@ -126,7 +126,7 @@ class CSTBan : public Module "%s gebannt von %s, wird auto-auslaufen in %s" }; - const char* langtable_pt[] = { + const char *langtable_pt[] = { " TBAN Bane o usuбrio por um determinado perнodo de tempo", "Sintaxe: TBAN canal nick tempo", "Bane de um canal o usuбrio especificado por um determinado perнodo de\n" @@ -134,7 +134,7 @@ class CSTBan : public Module "%s foi banido do %s, irб auto-expirar em %s" }; - const char* langtable_ru[] = { + const char *langtable_ru[] = { " TBAN Банит пользователя на указанный промежуток времени", "Синтаксис: TBAN #канал ник время", "Банит пользователя на указанный промежуток времени в секундах\n" @@ -143,7 +143,7 @@ class CSTBan : public Module "Установленный бан %s на канале %s истечет через %s секунд" }; - const char* langtable_it[] = { + const char *langtable_it[] = { " TBAN Banna l'utente per un periodo di tempo specificato", "Sintassi: TBAN canale nick tempo", "Banna l'utente specificato da un canale per un periodo di tempo\n" @@ -160,37 +160,37 @@ class CSTBan : public Module } }; -void mySendResponse(User *u, const char *channel, char *mask, const char *time) +void mySendResponse(User *u, const Anope::string &channel, const Anope::string &mask, const Anope::string &time) { - me->NoticeLang(Config.s_ChanServ, u, TBAN_RESPONSE, mask, channel, time); + me->NoticeLang(Config.s_ChanServ, u, TBAN_RESPONSE, mask.c_str(), channel.c_str(), time.c_str()); } class TempBan : public CallBack { - private: - std::string chan; - std::string mask; + private: + Anope::string chan; + Anope::string mask; - public: - TempBan(time_t seconds, const std::string &channel, const std::string &banmask) : CallBack(me, seconds), chan(channel), mask(banmask) { } + public: + TempBan(time_t seconds, const Anope::string &channel, const Anope::string &banmask) : CallBack(me, seconds), chan(channel), mask(banmask) { } - void Tick(time_t ctime) - { - Channel *c; + void Tick(time_t ctime) + { + Channel *c; - if ((c = findchan(chan)) && c->ci) - c->RemoveMode(NULL, CMODE_BAN, mask); - } + if ((c = findchan(chan)) && c->ci) + c->RemoveMode(NULL, CMODE_BAN, mask); + } }; -void addBan(Channel *c, time_t timeout, char *banmask) +void addBan(Channel *c, time_t timeout, Anope::string &banmask) { c->SetMode(NULL, CMODE_BAN, banmask); new TempBan(timeout, c->name, banmask); } -int canBanUser(Channel * c, User * u, User * u2) +int canBanUser(Channel *c, User *u, User *u2) { ChannelInfo *ci = c->ci; int ok = 0; diff --git a/modules/extra/hs_request.cpp b/modules/extra/hs_request.cpp index 7ca2bc9ca..82ec2daf5 100644 --- a/modules/extra/hs_request.cpp +++ b/modules/extra/hs_request.cpp @@ -51,22 +51,23 @@ enum LNG_NUM_STRINGS }; -void my_add_host_request(char *nick, char *vIdent, char *vhost, char *creator, time_t tmp_time); -int my_isvalidchar(const char c); -void my_memo_lang(User *u, const char *name, int z, int number, ...); -void req_send_memos(User *u, char *vIdent, char *vHost); +void my_add_host_request(const Anope::string &nick, const Anope::string &vIdent, const Anope::string &vhost, const Anope::string &creator, time_t tmp_time); +int my_isvalidchar(char c); +void my_memo_lang(User *u, const Anope::string &name, int z, int number, ...); +void req_send_memos(User *u, const Anope::string &vIdent, const Anope::string &vHost); void my_load_config(); void my_add_languages(); struct HostRequest { - std::string ident; - std::string host; + Anope::string ident; + Anope::string host; time_t time; }; -std::map Requests; +typedef std::map RequestMap; +RequestMap Requests; static Module *me; @@ -77,79 +78,52 @@ class CommandHSRequest : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(User *u, const std::vector ¶ms) { - const char *nick; - const char *rawhostmask = params[0].c_str(); - char *hostmask = new char[Config.HostLen]; + Anope::string nick = u->nick; + Anope::string rawhostmask = params[0]; + Anope::string hostmask; NickAlias *na; - char *s; - char *vIdent = NULL; time_t now = time(NULL); - nick = u->nick.c_str(); - - vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */ - if (vIdent) + Anope::string vIdent = myStrGetToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */ + if (!vIdent.empty()) { rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */ - if (!rawhostmask) + if (rawhostmask.empty()) { me->NoticeLang(Config.s_HostServ, u, LNG_REQUEST_SYNTAX); - delete [] vIdent; - delete [] hostmask; return MOD_CONT; } - if (strlen(vIdent) > Config.UserLen) + if (vIdent.length() > Config.UserLen) { notice_lang(Config.s_HostServ, u, HOST_SET_IDENTTOOLONG, Config.UserLen); - delete [] vIdent; - delete [] rawhostmask; - delete [] hostmask; return MOD_CONT; } else - for (s = vIdent; *s; ++s) + for (Anope::string::iterator s = vIdent.begin(), s_end = vIdent.end(); s != s_end; ++s) if (!my_isvalidchar(*s)) { notice_lang(Config.s_HostServ, u, HOST_SET_IDENT_ERROR); - delete [] vIdent; - delete [] rawhostmask; - delete [] hostmask; return MOD_CONT; } if (!ircd->vident) { notice_lang(Config.s_HostServ, u, HOST_NO_VIDENT); - delete [] vIdent; - delete [] rawhostmask; - delete [] hostmask; return MOD_CONT; } } - if (strlen(rawhostmask) < Config.HostLen) - snprintf(hostmask, Config.HostLen, "%s", rawhostmask); + if (rawhostmask.length() < Config.HostLen) + hostmask = rawhostmask; else { notice_lang(Config.s_HostServ, u, HOST_SET_TOOLONG, Config.HostLen); - if (vIdent) - { - delete [] vIdent; - delete [] rawhostmask; - } - delete [] hostmask; return MOD_CONT; } if (!isValidHost(hostmask, 3)) { notice_lang(Config.s_HostServ, u, HOST_SET_ERROR); - if (vIdent) - { - delete [] vIdent; - delete [] rawhostmask; - } - delete [] hostmask; return MOD_CONT; } @@ -159,34 +133,21 @@ class CommandHSRequest : public Command { me->NoticeLang(Config.s_HostServ, u, LNG_REQUEST_WAIT, Config.MSSendDelay); u->lastmemosend = now; - if (vIdent) - { - delete [] vIdent; - delete [] rawhostmask; - } - delete [] hostmask; return MOD_CONT; } - my_add_host_request(const_cast(nick), vIdent, hostmask, const_cast(u->nick.c_str()), now); + my_add_host_request(nick, vIdent, hostmask, u->nick, now); me->NoticeLang(Config.s_HostServ, u, LNG_REQUESTED); req_send_memos(u, vIdent, hostmask); Alog() << "New vHost Requested by " << nick; } else - notice_lang(Config.s_HostServ, u, HOST_NOREG, nick); - - if (vIdent) - { - delete [] vIdent; - delete [] rawhostmask; - } - delete [] hostmask; + notice_lang(Config.s_HostServ, u, HOST_NOREG, nick.c_str()); return MOD_CONT; } - bool OnHelp(User *u, const ci::string &subcommand) + bool OnHelp(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_HostServ, u, LNG_REQUEST_SYNTAX); u->SendMessage(Config.s_HostServ, " "); @@ -195,7 +156,7 @@ class CommandHSRequest : public Command return true; } - void OnSyntaxError(User *u, const ci::string &subcommand) + void OnSyntaxError(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_HostServ, u, LNG_REQUEST_SYNTAX); } @@ -213,14 +174,14 @@ class CommandHSActivate : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(User *u, const std::vector ¶ms) { - const char *nick = params[0].c_str(); + Anope::string nick = params[0]; NickAlias *na; if ((na = findnick(nick))) { - std::map::iterator it = Requests.find(na->nick); + RequestMap::iterator it = Requests.find(na->nick); if (it != Requests.end()) { na->hostinfo.SetVhost(it->second->ident, it->second->host, u->nick, it->second->time); @@ -230,19 +191,19 @@ class CommandHSActivate : public Command if (HSRequestMemoUser) my_memo_lang(u, na->nick, 2, LNG_ACTIVATE_MEMO); - me->NoticeLang(Config.s_HostServ, u, LNG_ACTIVATED, nick); + me->NoticeLang(Config.s_HostServ, u, LNG_ACTIVATED, nick.c_str()); Alog() << "Host Request for " << nick << " activated by " << u->nick; } else - me->NoticeLang(Config.s_HostServ, u, LNG_NO_REQUEST, nick); + me->NoticeLang(Config.s_HostServ, u, LNG_NO_REQUEST, nick.c_str()); } else - notice_lang(Config.s_HostServ, u, NICK_X_NOT_REGISTERED, nick); + notice_lang(Config.s_HostServ, u, NICK_X_NOT_REGISTERED, nick.c_str()); return MOD_CONT; } - bool OnHelp(User *u, const ci::string &subcommand) + bool OnHelp(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_HostServ, u, LNG_ACTIVATE_SYNTAX); u->SendMessage(Config.s_HostServ, " "); @@ -253,7 +214,7 @@ class CommandHSActivate : public Command return true; } - void OnSyntaxError(User *u, const ci::string &subcommand) + void OnSyntaxError(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_HostServ, u, LNG_ACTIVATE_SYNTAX); } @@ -271,12 +232,12 @@ class CommandHSReject : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(User *u, const std::vector ¶ms) { - const char *nick = params[0].c_str(); - const char *reason = params.size() > 1 ? params[1].c_str() : NULL; + Anope::string nick = params[0]; + Anope::string reason = params.size() > 1 ? params[1] : ""; - std::map::iterator it = Requests.find(nick); + RequestMap::iterator it = Requests.find(nick); if (it != Requests.end()) { delete it->second; @@ -284,22 +245,22 @@ class CommandHSReject : public Command if (HSRequestMemoUser) { - if (reason) - my_memo_lang(u, nick, 2, LNG_REJECT_MEMO_REASON, reason); + if (!reason.empty()) + my_memo_lang(u, nick, 2, LNG_REJECT_MEMO_REASON, reason.c_str()); else my_memo_lang(u, nick, 2, LNG_REJECT_MEMO); } - me->NoticeLang(Config.s_HostServ, u, LNG_REJECTED, nick); - Alog() << "Host Request for " << nick << " rejected by " << u->nick << " (" << (reason ? reason : "") << ")"; + me->NoticeLang(Config.s_HostServ, u, LNG_REJECTED, nick.c_str()); + Alog() << "Host Request for " << nick << " rejected by " << u->nick << " (" << (!reason.empty() ? reason : "") << ")"; } else - me->NoticeLang(Config.s_HostServ, u, LNG_NO_REQUEST, nick); + me->NoticeLang(Config.s_HostServ, u, LNG_NO_REQUEST, nick.c_str()); return MOD_CONT; } - bool OnHelp(User *u, const ci::string &subcommand) + bool OnHelp(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_HostServ, u, LNG_REJECT_SYNTAX); u->SendMessage(Config.s_HostServ, " "); @@ -310,7 +271,7 @@ class CommandHSReject : public Command return true; } - void OnSyntaxError(User *u, const ci::string &subcommand) + void OnSyntaxError(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_HostServ, u, LNG_REJECT_SYNTAX); } @@ -327,7 +288,7 @@ class HSListBase : public Command unsigned display_counter = 0; tm *tm; - for (std::map::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end; ++it) + for (RequestMap::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end; ++it) { HostRequest *hr = it->second; if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < Config.NSListMax) @@ -347,11 +308,11 @@ class HSListBase : public Command return MOD_CONT; } public: - HSListBase(const ci::string &cmd, int min, int max) : Command(cmd, min, max, "hostserv/set") + HSListBase(const Anope::string &cmd, int min, int max) : Command(cmd, min, max, "hostserv/set") { } - void OnSyntaxError(User *u, const ci::string &subcommand) + void OnSyntaxError(User *u, const Anope::string &subcommand) { // no-op } @@ -364,12 +325,12 @@ class CommandHSWaiting : public HSListBase { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(User *u, const std::vector ¶ms) { return this->DoList(u); } - bool OnHelp(User *u, const ci::string &subcommand) + bool OnHelp(User *u, const Anope::string &subcommand) { me->NoticeLang(Config.s_HostServ, u, LNG_WAITING_SYNTAX); u->SendMessage(Config.s_HostServ, " "); @@ -382,7 +343,7 @@ class CommandHSWaiting : public HSListBase class HSRequest : public Module { public: - HSRequest(const std::string &modname, const std::string &creator) : Module(modname, creator) + HSRequest(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) { me = this; @@ -396,7 +357,7 @@ class HSRequest : public Module my_load_config(); - const char* langtable_en_us[] = { + const char *langtable_en_us[] = { /* LNG_REQUEST_SYNTAX */ "Syntax: \002REQUEST \037vhost\037\002", /* LNG_REQUESTED */ @@ -446,7 +407,7 @@ class HSRequest : public Module "the same as performing a LIST +req ." }; - const char* langtable_nl[] = { + const char *langtable_nl[] = { /* LNG_REQUEST_SYNTAX */ "Gebruik: \002REQUEST \037vhost\037\002", /* LNG_REQUESTED */ @@ -496,7 +457,7 @@ class HSRequest : public Module "hetzelfde als LIST +req ." }; - const char* langtable_pt[] = { + const char *langtable_pt[] = { /* LNG_REQUEST_SYNTAX */ "Sintaxe: \002REQUEST \037vhost\037\002", /* LNG_REQUESTED */ @@ -546,7 +507,7 @@ class HSRequest : public Module "o mesmo que fazer um LIST +req" }; - const char* langtable_ru[] = { + const char *langtable_ru[] = { /* LNG_REQUEST_SYNTAX */ "Синтаксис: \002REQUEST \037vHost\037\002", /* LNG_REQUESTED */ @@ -596,7 +557,7 @@ class HSRequest : public Module "ожидающих обработки. Аналогичная команда: LIST +req ." }; - const char* langtable_it[] = { + const char *langtable_it[] = { /* LNG_REQUEST_SYNTAX */ "Sintassi: \002REQUEST \037vhost\037\002", /* LNG_REQUESTED */ @@ -666,32 +627,32 @@ class HSRequest : public Module } } - EventReturn OnPreCommand(User *u, const std::string &service, const ci::string &command, const std::vector ¶ms) + EventReturn OnPreCommand(User *u, BotInfo *service, const Anope::string &command, const std::vector ¶ms) { - if (Config.s_HostServ && service == Config.s_HostServ) + if (!Config.s_HostServ.empty() && service == findbot(Config.s_HostServ)) { - if (command == "LIST") + if (command.equals_ci("LIST")) { - ci::string key = params.size() ? params[0] : ""; + Anope::string key = params.size() ? params[0] : ""; - if (!key.empty() && key == "+req") + if (!key.empty() && key.equals_ci("+req")) { - std::vector emptyParams; + std::vector emptyParams; Command *c = FindCommand(HostServ, "WAITING"); c->Execute(u, emptyParams); return EVENT_STOP; } } } - else if (service == Config.s_NickServ) + else if (service == findbot(Config.s_NickServ)) { - if (command == "DROP") + if (command.equals_ci("DROP")) { NickAlias *na = findnick(u->nick); if (na) { - std::map::iterator it = Requests.find(na->nick); + RequestMap::iterator it = Requests.find(na->nick); if (it != Requests.end()) { @@ -705,12 +666,12 @@ class HSRequest : public Module return EVENT_CONTINUE; } - EventReturn OnDatabaseRead(const std::vector ¶ms) + EventReturn OnDatabaseRead(const std::vector ¶ms) { - if (params[0] == "HS_REQUEST" && params.size() >= 5) + if (params[0].equals_ci("HS_REQUEST") && params.size() >= 5) { - char *vident = params[2] == "(null)" ? NULL : const_cast(params[2].c_str()); - my_add_host_request(const_cast(params[1].c_str()), vident, const_cast(params[3].c_str()), const_cast(params[1].c_str()), strtol(params[4].c_str(), NULL, 10)); + Anope::string vident = params[2].equals_ci("(null)") ? "" : params[2]; + my_add_host_request(params[1], vident, params[3], params[1], params[4].is_number_only() ? convertTo(params[4]) : 0); return EVENT_STOP; } @@ -718,9 +679,9 @@ class HSRequest : public Module return EVENT_CONTINUE; } - void OnDatabaseWrite(void (*Write)(const std::string &)) + void OnDatabaseWrite(void (*Write)(const Anope::string &)) { - for (std::map::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end; ++it) + for (RequestMap::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end; ++it) { HostRequest *hr = it->second; std::stringstream buf; @@ -730,7 +691,7 @@ class HSRequest : public Module } }; -void my_memo_lang(User *u, const char *name, int z, int number, ...) +void my_memo_lang(User *u, const Anope::string &name, int z, int number, ...) { va_list va; char buffer[4096], outbuf[4096]; @@ -753,7 +714,7 @@ void my_memo_lang(User *u, const char *name, int z, int number, ...) { fmt = me->lang[lang].argv[number]; - buf = sstrdup(fmt); + buf = strdup(fmt); s = buf; while (*s) { @@ -774,22 +735,21 @@ void my_memo_lang(User *u, const char *name, int z, int number, ...) Alog() << me->name << ": INVALID language string call, language: [" << lang << "], String [" << number << "]"; } -void req_send_memos(User *u, char *vIdent, char *vHost) +void req_send_memos(User *u, const Anope::string &vIdent, const Anope::string &vHost) { - int z = 2; - char host[BUFSIZE]; - std::list >::iterator it, it_end; + Anope::string host; + std::list >::iterator it, it_end; - if (vIdent) - snprintf(host, sizeof(host), "%s@%s", vIdent, vHost); + if (!vIdent.empty()) + host = vIdent + "@" + vHost; else - snprintf(host, sizeof(host), "%s", vHost); + host = vHost; if (HSRequestMemoOper == 1) for (it = Config.Opers.begin(), it_end = Config.Opers.end(); it != it_end; ++it) { - ci::string nick = it->first; - my_memo_lang(u, nick.c_str(), z, LNG_REQUEST_MEMO, host); + Anope::string nick = it->first; + my_memo_lang(u, nick, 2, LNG_REQUEST_MEMO, host.c_str()); } if (HSRequestMemoSetters == 1) { @@ -799,13 +759,13 @@ void req_send_memos(User *u, char *vIdent, char *vHost) } } -void my_add_host_request(char *nick, char *vIdent, char *vhost, char *creator, time_t tmp_time) +void my_add_host_request(const Anope::string &nick, const Anope::string &vIdent, const Anope::string &vhost, const Anope::string &creator, time_t tmp_time) { HostRequest *hr = new HostRequest; - hr->ident = vIdent ? vIdent : ""; + hr->ident = vIdent; hr->host = vhost; hr->time = tmp_time; - std::map::iterator it = Requests.find(nick); + RequestMap::iterator it = Requests.find(nick); if (it != Requests.end()) { delete it->second; @@ -814,7 +774,7 @@ void my_add_host_request(char *nick, char *vIdent, char *vhost, char *creator, t Requests.insert(std::make_pair(nick, hr)); } -int my_isvalidchar(const char c) +int my_isvalidchar(char c) { if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-') return 1; diff --git a/modules/extra/m_helpchan.cpp b/modules/extra/m_helpchan.cpp index c63703f33..6d95cceca 100644 --- a/modules/extra/m_helpchan.cpp +++ b/modules/extra/m_helpchan.cpp @@ -9,10 +9,10 @@ class HelpChannel : public Module { - ci::string HelpChan; + Anope::string HelpChan; public: - HelpChannel(const std::string &modname, const std::string &creator) : Module(modname, creator) + HelpChannel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); this->SetType(SUPPORTED); @@ -23,9 +23,9 @@ class HelpChannel : public Module OnReload(true); } - EventReturn OnChannelModeSet(Channel *c, ChannelModeName Name, const std::string ¶m) + EventReturn OnChannelModeSet(Channel *c, ChannelModeName Name, const Anope::string ¶m) { - if (Name == CMODE_OP && c && c->ci && c->name == this->HelpChan) + if (Name == CMODE_OP && c && c->ci && c->name.equals_ci(this->HelpChan)) { User *u = finduser(param); @@ -40,7 +40,7 @@ class HelpChannel : public Module { ConfigReader config; - this->HelpChan = config.ReadValue("m_helpchan", "helpchannel", "", 0).c_str(); + this->HelpChan = config.ReadValue("m_helpchan", "helpchannel", "", 0); } }; diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp index 599e76e8f..386dd0d5f 100644 --- a/modules/extra/m_ssl.cpp +++ b/modules/extra/m_ssl.cpp @@ -24,12 +24,12 @@ class SSLSocket : public ClientSocket return SSL_read(sslsock, buf, sz); } - const int SendInternal(const std::string &buf) const + const int SendInternal(const Anope::string &buf) const { - return SSL_write(sslsock, buf.c_str(), buf.size()); + return SSL_write(sslsock, buf.c_str(), buf.length()); } public: - SSLSocket(const std::string &nTargetHost, int nPort, const std::string &nBindHost = "", bool nIPv6 = false) : ClientSocket(nTargetHost, nPort, nBindHost, nIPv6) + SSLSocket(const Anope::string &nTargetHost, int nPort, const Anope::string &nBindHost = "", bool nIPv6 = false) : ClientSocket(nTargetHost, nPort, nBindHost, nIPv6) { this->SetBlocking(); @@ -39,7 +39,7 @@ class SSLSocket : public ClientSocket throw CoreException("Unable to initialize SSL socket"); SSL_set_connect_state(sslsock); - SSL_set_fd(sslsock, sock); + SSL_set_fd(sslsock, Sock); SSL_connect(sslsock); UplinkSock = this; @@ -55,7 +55,7 @@ class SSLSocket : public ClientSocket UplinkSock = NULL; } - bool Read(const std::string &buf) + bool Read(const Anope::string &buf) { process(buf); return true; @@ -65,7 +65,7 @@ class SSLSocket : public ClientSocket class SSLModule : public Module { public: - SSLModule(const std::string &modname, const std::string &creator) : Module(modname, creator) + SSLModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) { SSL_load_error_strings(); SSLeay_add_ssl_algorithms(); @@ -128,10 +128,10 @@ class SSLModule : public Module { try { - new SSLSocket(u->host, u->port, Config.LocalHost ? Config.LocalHost : "", u->ipv6); + new SSLSocket(u->host, u->port, Config.LocalHost, u->ipv6); Alog() << "Connected to Server " << Number << " (" << u->host << ":" << u->port << ")"; } - catch (SocketException& ex) + catch (const SocketException &ex) { Alog() << "Unable to connect with SSL to server" << Number << " (" << u->host << ":" << u->port << "), " << ex.GetReason(); } diff --git a/modules/extra/mysql/db_mysql.h b/modules/extra/mysql/db_mysql.h index 32a2469c9..fcad2f24c 100644 --- a/modules/extra/mysql/db_mysql.h +++ b/modules/extra/mysql/db_mysql.h @@ -176,7 +176,7 @@ class DBMySQL : public Module unsigned int Port; unsigned int Delay; - DBMySQL(const std::string &modname, const std::string &creator) : Module(modname, creator) + DBMySQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) { me = this; @@ -184,7 +184,7 @@ class DBMySQL : public Module this->SetType(DATABASE); if (!LoadConfig()) - throw ModuleException("Couldn't load config"); + throw ModuleException(Anope::string("Couldn't load config")); Con = new mysqlpp::Connection(false); Ne = new mysqlpp::NoExceptions(Con); @@ -193,7 +193,7 @@ class DBMySQL : public Module std::string Error = "MySQL: Error connecting to SQL server: "; Error += Con->error(); delete Con; - throw ModuleException(Error.c_str()); + throw ModuleException(Anope::string(Error)); } mysqlpp::Query query(Con); diff --git a/modules/extra/mysql/db_mysql_execute.cpp b/modules/extra/mysql/db_mysql_execute.cpp index 2cc6ab6df..079e88147 100644 --- a/modules/extra/mysql/db_mysql_execute.cpp +++ b/modules/extra/mysql/db_mysql_execute.cpp @@ -145,7 +145,7 @@ class DBMySQLExecute : public DBMySQL { SQLTimer *_SQLTimer; public: - DBMySQLExecute(const std::string &modname, const std::string &creator) : DBMySQL(modname, creator) + DBMySQLExecute(const Anope::string &modname, const Anope::string &creator) : DBMySQL(modname, creator) { _SQLTimer = new SQLTimer(); } diff --git a/modules/extra/mysql/db_mysql_read.cpp b/modules/extra/mysql/db_mysql_read.cpp index 3ffc82366..ff608b700 100644 --- a/modules/extra/mysql/db_mysql_read.cpp +++ b/modules/extra/mysql/db_mysql_read.cpp @@ -237,37 +237,37 @@ static void LoadDatabase() ci->bantype = atoi(qres[i]["bantype"].c_str()); if (qres[i]["mlock_on"].size()) { - std::vector modes; + std::vector modes; std::string buf; spacesepstream sep(SQLAssign(qres[i]["mlock_on"])); while (sep.GetToken(buf)) - modes.push_back(buf); + modes.push_back(Anope::string(buf)); - ci->Extend("db_mlock_modes_on", new ExtensibleItemRegular >(modes)); + ci->Extend("db_mlock_modes_on", new ExtensibleItemRegular >(modes)); } if (qres[i]["mlock_off"].size()) { - std::vector modes; + std::vector modes; std::string buf; spacesepstream sep(SQLAssign(qres[i]["mlock_off"])); while (sep.GetToken(buf)) - modes.push_back(buf); + modes.push_back(Anope::string(buf)); - ci->Extend("db_mlock_modes_off", new ExtensibleItemRegular >(modes)); + ci->Extend("db_mlock_modes_off", new ExtensibleItemRegular >(modes)); } if (qres[i]["mlock_params"].size()) { - std::vector > mlp; + std::vector > mlp; std::string buf, buf2; spacesepstream sep(SQLAssign(qres[i]["mlock_params"])); while (sep.GetToken(buf) && sep.GetToken(buf2)) - mlp.push_back(std::make_pair(buf, buf2)); + mlp.push_back(std::make_pair(Anope::string(buf), Anope::string(buf2))); - ci->Extend("db_mlp", new ExtensibleItemRegular > >(mlp)); + ci->Extend("db_mlp", new ExtensibleItemRegular > >(mlp)); } if (qres[i]["entry_message"].size()) ci->entry_message = sstrdup(qres[i]["entry_message"].c_str()); @@ -594,7 +594,7 @@ static void LoadDatabase() class DBMySQLRead : public DBMySQL { public: - DBMySQLRead(const std::string &modname, const std::string &creator) : DBMySQL(modname, creator) + DBMySQLRead(const Anope::string &modname, const Anope::string &creator) : DBMySQL(modname, creator) { Implementation i[] = { I_OnLoadDatabase }; ModuleManager::Attach(i, this, 1); diff --git a/modules/extra/mysql/db_mysql_write.cpp b/modules/extra/mysql/db_mysql_write.cpp index c5c002a7e..2d44450c1 100644 --- a/modules/extra/mysql/db_mysql_write.cpp +++ b/modules/extra/mysql/db_mysql_write.cpp @@ -161,7 +161,7 @@ void WriteMetadata(const std::string &key, const std::string &data) void WriteNickMetadata(const std::string &key, const std::string &data) { if (!CurNick) - throw CoreException("WriteNickMetadata without a nick to write"); + throw CoreException(Anope::string("WriteNickMetadata without a nick to write")); mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_ns_alias_metadata` (nick, name, value) VALUES(" << mysqlpp::quote << CurNick->nick << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")"; @@ -171,7 +171,7 @@ void WriteNickMetadata(const std::string &key, const std::string &data) void WriteCoreMetadata(const std::string &key, const std::string &data) { if (!CurCore) - throw CoreException("WritCoreMetadata without a core to write"); + throw CoreException(Anope::string("WritCoreMetadata without a core to write")); mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_ns_core_metadata` (nick, name, value) VALUES(" << mysqlpp::quote << CurCore->display << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")"; @@ -181,7 +181,7 @@ void WriteCoreMetadata(const std::string &key, const std::string &data) void WriteChannelMetadata(const std::string &key, const std::string &data) { if (!CurChannel) - throw CoreException("WriteChannelMetadata without a channel to write"); + throw CoreException(Anope::string("WriteChannelMetadata without a channel to write")); mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_cs_info_metadata` (channel, name, value) VALUES(" << mysqlpp::quote << CurChannel->name << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")"; @@ -191,7 +191,7 @@ void WriteChannelMetadata(const std::string &key, const std::string &data) void WriteBotMetadata(const std::string &key, const std::string &data) { if (!CurBot) - throw CoreException("WriteBotMetadata without a bot to write"); + throw CoreException(Anope::string("WriteBotMetadata without a bot to write")); mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_bs_info_metadata` (botname, name, value) VALUES(" << mysqlpp::quote << CurBot->nick << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")"; @@ -336,7 +336,7 @@ class CommandSyncSQL : public Command return MOD_CONT; } - bool OnHelp(User *u, const ci::string &subcommand) + bool OnHelp(User *u, const Anope::string &subcommand) { notice_help(Config.s_OperServ, u, OPER_HELP_SYNC); return true; @@ -351,7 +351,7 @@ class CommandSyncSQL : public Command class DBMySQLWrite : public DBMySQL { public: - DBMySQLWrite(const std::string &modname, const std::string &creator) : DBMySQL(modname, creator) + DBMySQLWrite(const Anope::string &modname, const Anope::string &creator) : DBMySQL(modname, creator) { me = this; @@ -612,14 +612,14 @@ class DBMySQLWrite : public DBMySQL } } - void OnNickAddAccess(NickCore *nc, const std::string &entry) + void OnNickAddAccess(NickCore *nc, const Anope::string &entry) { mysqlpp::Query query(me->Con); query << "INSERT DELAYED INTO `anope_ns_access` (display, access) VALUES(" << mysqlpp::quote << nc->display << ", " << mysqlpp::quote << entry << ")"; ExecuteQuery(query); } - void OnNickEraseAccess(NickCore *nc, const std::string &entry) + void OnNickEraseAccess(NickCore *nc, const Anope::string &entry) { mysqlpp::Query query(me->Con); query << "DELETE FROM `anope_ns_access` WHERE `display` = " << mysqlpp::quote << nc->display << " AND `access` = " << mysqlpp::quote << entry; @@ -703,7 +703,7 @@ class DBMySQLWrite : public DBMySQL ExecuteQuery(query); } - void OnChangeCoreDisplay(NickCore *nc, const std::string &newdisplay) + void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) { mysqlpp::Query query(me->Con); query << "UPDATE `anope_ns_core` SET `display` = " << mysqlpp::quote << newdisplay << " WHERE `display` = " << mysqlpp::quote << nc->display; diff --git a/modules/extra/ns_maxemail.cpp b/modules/extra/ns_maxemail.cpp index 89ffd90da..bcddc18f5 100644 --- a/modules/extra/ns_maxemail.cpp +++ b/modules/extra/ns_maxemail.cpp @@ -1,5 +1,5 @@ /* ns_maxemail.c - Limit the amount of times an email address - * can be used for a NickServ account. + * can be used for a NickServ account. * * (C) 2003-2010 Anope Team * Contact us at team@anope.org @@ -19,7 +19,7 @@ void my_load_config(); void my_add_languages(); -bool check_email_limit_reached(const char *email, User * u); +bool check_email_limit_reached(const Anope::string &email, User *u); int NSEmailMax = 0; @@ -35,7 +35,7 @@ static Module *me; class NSMaxEmail : public Module { public: - NSMaxEmail(const std::string &modname, const std::string &creator) : Module(modname, creator) + NSMaxEmail(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) { me = this; @@ -102,21 +102,21 @@ class NSMaxEmail : public Module my_load_config(); } - EventReturn OnPreCommand(User *u, const std::string &service, const ci::string &command, const std::vector ¶ms) + EventReturn OnPreCommand(User *u, BotInfo *service, const Anope::string &command, const std::vector ¶ms) { - if (service == Config.s_NickServ) + if (service == findbot(Config.s_NickServ)) { - if (command == "REGISTER") + if (command.equals_ci("REGISTER")) { - if (check_email_limit_reached(params.size() > 1 ? params[1].c_str() : NULL, u)) + if (check_email_limit_reached(params.size() > 1 ? params[1] : "", u)) return EVENT_STOP; } - else if (command == "SET") + else if (command.equals_ci("SET")) { - ci::string set = params[0]; - const char *email = params.size() > 1 ? params[1].c_str() : NULL; + Anope::string set = params[0]; + Anope::string email = params.size() > 1 ? params[1] : ""; - if (set == "email" && check_email_limit_reached(email, u)) + if (set.equals_ci("email") && check_email_limit_reached(email, u)) return EVENT_STOP; } } @@ -125,27 +125,27 @@ class NSMaxEmail : public Module } }; -int count_email_in_use(const char *email, User * u) +int count_email_in_use(const Anope::string &email, User *u) { int count = 0; - if (!email) + if (email.empty()) return 0; for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it) { NickCore *nc = it->second; - if (!(u->Account() && u->Account() == nc) && nc->email && !stricmp(nc->email, email)) + if (!(u->Account() && u->Account() == nc) && !nc->email.empty() && nc->email.equals_ci(email)) ++count; } return count; } -bool check_email_limit_reached(const char *email, User * u) +bool check_email_limit_reached(const Anope::string &email, User *u) { - if (NSEmailMax < 1 || !email) + if (NSEmailMax < 1 || email.empty()) return false; if (count_email_in_use(email, u) < NSEmailMax) diff --git a/modules/extra/ns_set_misc.cpp b/modules/extra/ns_set_misc.cpp index 00d7d2adf..9e0f23eb0 100644 --- a/modules/extra/ns_set_misc.cpp +++ b/modules/extra/ns_set_misc.cpp @@ -16,41 +16,39 @@ class CommandNSSetMisc : public Command { private: - std::string Desc; + Anope::string Desc; protected: - CommandReturn RealExecute(User *u, const std::vector ¶ms) + CommandReturn RealExecute(User *u, const std::vector ¶ms) { NickCore *nc = findcore(params[0]); assert(nc); - nc->Shrink("nickserv:" + std::string(this->name.c_str())); + nc->Shrink("nickserv:" + this->name); if (params.size() > 1) { - nc->Extend("nickserv:" + std::string(this->name.c_str()), new ExtensibleItemRegular(params[1])); - notice_lang(Config.s_NickServ, u, CHAN_SETTING_CHANGED, this->name.c_str(), nc->display, params[1].c_str()); + nc->Extend("nickserv:" + this->name, new ExtensibleItemRegular(params[1])); + notice_lang(Config.s_NickServ, u, CHAN_SETTING_CHANGED, this->name.c_str(), nc->display.c_str(), params[1].c_str()); } else - { - notice_lang(Config.s_NickServ, u, CHAN_SETTING_UNSET, this->name.c_str(), nc->display); - } + notice_lang(Config.s_NickServ, u, CHAN_SETTING_UNSET, this->name.c_str(), nc->display.c_str()); return MOD_CONT; } public: - CommandNSSetMisc(const ci::string &cname, const std::string &desc, const ci::string &cpermission = "") : Command(cname, 0, 1, cpermission), Desc(desc) + CommandNSSetMisc(const Anope::string &cname, const Anope::string &desc, const Anope::string &cpermission = "") : Command(cname, 0, 1, cpermission), Desc(desc) { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(User *u, const std::vector ¶ms) { - std::vector realparams = params; + std::vector realparams = params; realparams.insert(realparams.begin(), u->Account()->display); return RealExecute(u, realparams); } - void OnSyntaxError(User *u, const ci::string &) + void OnSyntaxError(User *u, const Anope::string &) { syntax_error(Config.s_NickServ, u, "SET", NICK_SET_SYNTAX); } @@ -64,18 +62,18 @@ class CommandNSSetMisc : public Command class CommandNSSASetMisc : public CommandNSSetMisc { public: - CommandNSSASetMisc(const ci::string &cname, const std::string &desc) : CommandNSSetMisc(cname, desc, "nickserv/saset/" + cname) + CommandNSSASetMisc(const Anope::string &cname, const Anope::string &desc) : CommandNSSetMisc(cname, desc, "nickserv/saset/" + cname) { this->MinParams = 1; this->MaxParams = 2; } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(User *u, const std::vector ¶ms) { return RealExecute(u, params); } - void OnSyntaxError(User *u, const ci::string &) + void OnSyntaxError(User *u, const Anope::string &) { syntax_error(Config.s_NickServ, u, "SASET", NICK_SASET_SYNTAX); } @@ -85,14 +83,14 @@ class NSSetMisc : public Module { struct CommandInfo { - std::string Name; - std::string Desc; + Anope::string Name; + Anope::string Desc; bool ShowHidden; - CommandInfo(const std::string &name, const std::string &desc, bool showhidden) : Name(name), Desc(desc), ShowHidden(showhidden) { } + CommandInfo(const Anope::string &name, const Anope::string &desc, bool showhidden) : Name(name), Desc(desc), ShowHidden(showhidden) { } }; - std::map Commands; + std::map Commands; void RemoveAll() { @@ -105,12 +103,12 @@ class NSSetMisc : public Module if (!set && !saset) return; - for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) + for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) { if (set) - set->DelSubcommand(it->first.c_str()); + set->DelSubcommand(it->first); if (saset) - saset->DelSubcommand(it->first.c_str()); + saset->DelSubcommand(it->first); delete it->second; } @@ -118,7 +116,7 @@ class NSSetMisc : public Module } public: - NSSetMisc(const std::string &modname, const std::string &creator) : Module(modname, creator) + NSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) { this->SetAuthor("Anope"); this->SetType(CORE); @@ -145,12 +143,12 @@ class NSSetMisc : public Module ConfigReader config; - for (int i = 0; true; ++i) + for (int i = 0, num = config.Enumerate("ns_set_misc"); i < num; ++i) { - std::string cname = config.ReadValue("ns_set_misc", "name", "", i); + Anope::string cname = config.ReadValue("ns_set_misc", "name", "", i); if (cname.empty()) - break; - std::string desc = config.ReadValue("ns_set_misc", "desc", "", i); + continue; + Anope::string desc = config.ReadValue("ns_set_misc", "desc", "", i); bool showhidden = config.ReadFlag("ns_set_misc", "operonly", "no", i); CommandInfo *info = new CommandInfo(cname, desc, showhidden); @@ -162,49 +160,40 @@ class NSSetMisc : public Module } if (set) - set->AddSubcommand(new CommandNSSetMisc(cname.c_str(), desc)); + set->AddSubcommand(new CommandNSSetMisc(cname, desc)); if (saset) - saset->AddSubcommand(new CommandNSSASetMisc(cname.c_str(), desc)); + saset->AddSubcommand(new CommandNSSASetMisc(cname, desc)); } } void OnNickInfo(User *u, NickAlias *na, bool ShowHidden) { - for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) + for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) { if (!ShowHidden && it->second->ShowHidden) continue; - ci::string value; + Anope::string value; if (na->nc->GetExtRegular("nickserv:" + it->first, value)) - { u->SendMessage(Config.s_NickServ, " %s: %s", it->first.c_str(), value.c_str()); - } } } - void OnDatabaseWriteMetadata(void (*WriteMetadata)(const std::string &, const std::string &), NickCore *nc) + void OnDatabaseWriteMetadata(void (*WriteMetadata)(const Anope::string &, const Anope::string &), NickCore *nc) { - for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) + for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) { - ci::string value; - + Anope::string value; if (nc->GetExtRegular("nickserv:" + it->first, value)) - { - WriteMetadata(it->first, ":" + std::string(value.c_str())); - } + WriteMetadata(it->first, ":" + value); } } - EventReturn OnDatabaseReadMetadata(NickCore *nc, const std::string &key, const std::vector ¶ms) + EventReturn OnDatabaseReadMetadata(NickCore *nc, const Anope::string &key, const std::vector ¶ms) { - for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) - { + for (std::map::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) if (key == it->first) - { - nc->Extend("nickserv:" + it->first, new ExtensibleItemRegular(params[0].c_str())); - }