diff options
| author | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-07-25 21:58:20 -0400 |
|---|---|---|
| committer | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-07-25 21:58:20 -0400 |
| commit | ae38212c1ce829c783edf971081c90137abb49a0 (patch) | |
| tree | 5c652d9cdc38103dec6fa112d57fca882b4e3e44 /modules/extra | |
| parent | 15d7f0f6fe8bb903275f603f734c13f65f3aa906 (diff) | |
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.
Diffstat (limited to 'modules/extra')
| -rw-r--r-- | modules/extra/cs_appendtopic.cpp | 48 | ||||
| -rw-r--r-- | modules/extra/cs_enforce.cpp | 49 | ||||
| -rw-r--r-- | modules/extra/cs_set_misc.cpp | 74 | ||||
| -rw-r--r-- | modules/extra/cs_tban.cpp | 68 | ||||
| -rw-r--r-- | modules/extra/hs_request.cpp | 204 | ||||
| -rw-r--r-- | modules/extra/m_helpchan.cpp | 10 | ||||
| -rw-r--r-- | modules/extra/m_ssl.cpp | 16 | ||||
| -rw-r--r-- | modules/extra/mysql/db_mysql.h | 6 | ||||
| -rw-r--r-- | modules/extra/mysql/db_mysql_execute.cpp | 2 | ||||
| -rw-r--r-- | modules/extra/mysql/db_mysql_read.cpp | 20 | ||||
| -rw-r--r-- | modules/extra/mysql/db_mysql_write.cpp | 18 | ||||
| -rw-r--r-- | modules/extra/ns_maxemail.cpp | 32 | ||||
| -rw-r--r-- | modules/extra/ns_set_misc.cpp | 83 |
13 files changed, 282 insertions, 348 deletions
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<ci::string> ¶ms) + CommandReturn Execute(User *u, const std::vector<Anope::string> ¶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<ci::string> ¶ms) + CommandReturn Execute(User *u, const std::vector<Anope::string> ¶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<ci::string> ¶ms) + CommandReturn Execute(User *u, const std::vector<Anope::string> ¶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<ci::string>(params[1])); + ci->Extend("chanserv:" + this->name, new ExtensibleItemRegular<Anope::string>(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<std::string, CommandInfo *> Commands; + std::map<Anope::string, CommandInfo *> Commands; void RemoveAll() { @@ -88,12 +85,12 @@ class CSSetMisc : public Module if (!set && !saset) return; - for (std::map<std::string, CommandInfo *>::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) + for (std::map<Anope::string, CommandInfo *>::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<std::string, CommandInfo *>::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) + for (std::map<Anope::string, CommandInfo *>::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<std::string, CommandInfo *>::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) + for (std::map<Anope::string, CommandInfo *>::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<std::string> ¶ms) + EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, const std::vector<Anope::string> ¶ms) { - for (std::map<std::string, CommandInfo *>::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) - { + for (std::map<Anope::string, CommandInfo *>::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<ci::string>(params[0].c_str())); - } - } + ci->Extend("chanserv:" + it->first, new ExtensibleItemRegular<Anope::string>(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<ci::string> ¶ms) + CommandReturn Execute(User *u, const std::vector<Anope::string> ¶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<ci::string, HostRequest *> Requests; +typedef std::map<Anope::string, HostRequest *, hash_compare_ci_string> RequestMap; +RequestMap Requests; static Module *me; @@ -77,79 +78,52 @@ class CommandHSRequest : public Command { } - CommandReturn Execute(User *u, const std::vector<ci::string> ¶ms) + CommandReturn Execute(User *u, const std::vector<Anope::string> ¶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<char *>(nick), vIdent, hostmask, const_cast<char *>(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<ci::string> ¶ms) + CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms) { - const char *nick = params[0].c_str(); + Anope::string nick = params[0]; NickAlias *na; if ((na = findnick(nick))) { - std::map<ci::string, HostRequest *>::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); |
