From 090e7863df54f91ab206141ef5ef9395afcbd752 Mon Sep 17 00:00:00 2001 From: w00t Date: Wed, 30 Nov 2005 08:28:14 +0000 Subject: Stylistic changes. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2029 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_alias.cpp | 211 ++++++++++++++++++++++++------------------------ 1 file changed, 105 insertions(+), 106 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 9bb2a9df2..837750da8 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -1,15 +1,15 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ * * Inspire is copyright (C) 2002-2004 ChatSpike-Dev. - * E-mail: - * - * - * + * E-mail: + * + * + * * Written by Craig Edwards, Craig McLure, and others. * This program is free but copyrighted software; see - * the file COPYING for details. + *the file COPYING for details. * * --------------------------------------------------- */ @@ -21,143 +21,142 @@ using namespace std; #include "modules.h" #include -/* $ModDesc: Changes the ident of connecting bottler clients to 'bottler' */ +/* $ModDesc: Provides aliases of commands. */ class Alias { - public: - std::string text; - std::string replace_with; - std::string requires; - bool uline; + public: + std::string text; + std::string replace_with; + std::string requires; + bool uline; }; class ModuleAlias : public Module { - private: - - Server *Srv; - ConfigReader *MyConf; - std::vector Aliases; - public: - - virtual void ReadAliases() - { - Aliases.clear(); - - for (int i = 0; i < MyConf->Enumerate("alias"); i++) + private: + Server *Srv; + ConfigReader *MyConf; + std::vector Aliases; + public: + /* XXX - small issue, why is this marked public when it's not (really) intended for external use */ + virtual void ReadAliases() { - Alias a; - a.text = MyConf->ReadValue("alias", "text", i); - a.replace_with = MyConf->ReadValue("alias", "replace", i); - a.requires = MyConf->ReadValue("alias", "requires", i); + Aliases.clear(); + + for (int i = 0; i < MyConf->Enumerate("alias"); i++) + { + Alias a; + a.text = MyConf->ReadValue("alias", "text", i); + a.replace_with = MyConf->ReadValue("alias", "replace", i); + a.requires = MyConf->ReadValue("alias", "requires", i); - a.uline = ((MyConf->ReadValue("alias", "uline", i) == "yes") || - (MyConf->ReadValue("alias", "uline", i) == "1") || - (MyConf->ReadValue("alias", "uline", i) == "true")); - - Aliases.push_back(a); - } + a.uline = ((MyConf->ReadValue("alias", "uline", i) == "yes") || + (MyConf->ReadValue("alias", "uline", i) == "1") || + (MyConf->ReadValue("alias", "uline", i) == "true")); + + Aliases.push_back(a); + } - } + } - ModuleAlias() - { - Srv = new Server; - MyConf = new ConfigReader; + ModuleAlias() + { + Srv = new Server; + MyConf = new ConfigReader; - ReadAliases(); - } + ReadAliases(); + } - virtual ~ModuleAlias() - { - delete Srv; - delete MyConf; - } + virtual ~ModuleAlias() + { + delete Srv; + delete MyConf; + } - virtual Version GetVersion() - { - return Version(1,0,0,1,VF_VENDOR); - } + virtual Version GetVersion() + { + return Version(1,0,0,1,VF_VENDOR); + } - virtual void OnServerRaw(std::string &raw, bool inbound, userrec* user) - { - if (inbound) + virtual void OnServerRaw(std::string &raw, bool inbound, userrec* user) { char data[MAXBUF]; - strncpy(data,raw.c_str(),MAXBUF); - char* dptr = data; - - for (unsigned int i = 0; i < Aliases.size(); i++) + char *dptr; + userrec *u = NULL; + + if (inbound) { - if (!strncasecmp(Aliases[i].text.c_str(),data,Aliases[i].text.length())) + strncpy(data, raw.c_str(),MAXBUF); + dptr = data; + + for (unsigned int i = 0; i < Aliases.size(); i++) { - userrec* u = NULL; - - if (Aliases[i].requires != "") + if (!strncasecmp(Aliases[i].text.c_str(),data,Aliases[i].text.length())) { - u = Srv->FindNick(Aliases[i].requires); - } + if (Aliases[i].requires != "") + { + u = Srv->FindNick(Aliases[i].requires); + } - if ((Aliases[i].requires != "") && (!u)) - { - Srv->SendServ(user->fd,"401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is currently unavailable. Please try again later."); - raw = "PONG :"+Srv->GetServerName(); - return; - } - if (Aliases[i].uline) - { - if (!Srv->IsUlined(u->server)) + if ((Aliases[i].requires != "") && (!u)) { - Srv->SendOpers("*** NOTICE -- Service "+Aliases[i].requires+" required by alias "+Aliases[i].text+" is not on a u-lined server, possibly underhanded antics detected!"); - Srv->SendServ(user->fd,"401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is an imposter! Please inform an IRC operator as soon as possible."); + Srv->SendServ(user->fd,"401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is currently unavailable. Please try again later."); raw = "PONG :"+Srv->GetServerName(); return; } - } + if (Aliases[i].uline) + { + if (!Srv->IsUlined(u->server)) + { + Srv->SendOpers("*** NOTICE -- Service "+Aliases[i].requires+" required by alias "+Aliases[i].text+" is not on a u-lined server, possibly underhanded antics detected!"); + Srv->SendServ(user->fd,"401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is an imposter! Please inform an IRC operator as soon as possible."); + raw = "PONG :"+Srv->GetServerName(); + return; + } + } - dptr += Aliases[i].text.length(); - if (strlen(dptr)) - { - raw = Aliases[i].replace_with + std::string(dptr); - } - else - { - raw = Aliases[i].replace_with; + dptr += Aliases[i].text.length(); + if (strlen(dptr)) + { + raw = Aliases[i].replace_with + std::string(dptr); + } + else + { + raw = Aliases[i].replace_with; + } + return; } - return; } } - } - } + } - virtual void OnRehash() - { - delete MyConf; - MyConf = new ConfigReader; + virtual void OnRehash() + { + delete MyConf; + MyConf = new ConfigReader; - ReadAliases(); - } + ReadAliases(); + } }; class ModuleAliasFactory : public ModuleFactory { - public: - ModuleAliasFactory() - { - } - - ~ModuleAliasFactory() - { - } + public: + ModuleAliasFactory() + { + } - virtual Module * CreateModule() - { - return new ModuleAlias; - } + ~ModuleAliasFactory() + { + } + virtual Module * CreateModule() + { + return new ModuleAlias; + } }; -- cgit v1.2.3