diff options
Diffstat (limited to 'src/modules')
38 files changed, 629 insertions, 608 deletions
diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp index ade243fb4..267fc71b4 100644 --- a/src/modules/extra/m_filter_pcre.cpp +++ b/src/modules/extra/m_filter_pcre.cpp @@ -95,10 +95,10 @@ class ModuleFilterPCRE : public Module delete Conf; } - void Implements(char* List) - { - List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnRehash] = 1; - } + void Implements(char* List) + { + List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnRehash] = 1; + } // format of a config entry is <keyword pattern="^regexp$" reason="Some reason here" action="kill/block"> @@ -170,22 +170,22 @@ class ModuleFilterPCRE : public Module } Srv->Log(DEFAULT,std::string("m_filter_pcre: read configuration from ")+filterfile); - filters.clear(); - for (int index = 0; index < MyConf->Enumerate("keyword"); index++) - { - std::string pattern = MyConf->ReadValue("keyword","pattern",index); - re = pcre_compile(pattern.c_str(),0,&error,&erroffset,NULL); - if (!re) - { - log(DEFAULT,"Error in regular expression: %s at offset %d: %s\n", pattern.c_str(), erroffset, error); - log(DEFAULT,"Regular expression %s not loaded.", pattern.c_str()); - } - else - { - filters.push_back(re); - log(DEFAULT,"Regular expression %s loaded.", pattern.c_str()); - } - } + filters.clear(); + for (int index = 0; index < MyConf->Enumerate("keyword"); index++) + { + std::string pattern = MyConf->ReadValue("keyword","pattern",index); + re = pcre_compile(pattern.c_str(),0,&error,&erroffset,NULL); + if (!re) + { + log(DEFAULT,"Error in regular expression: %s at offset %d: %s\n", pattern.c_str(), erroffset, error); + log(DEFAULT,"Regular expression %s not loaded.", pattern.c_str()); + } + else + { + filters.push_back(re); + log(DEFAULT,"Regular expression %s loaded.", pattern.c_str()); + } + } } diff --git a/src/modules/extra/m_sql.cpp b/src/modules/extra/m_sql.cpp index 515ce792d..ef3fbf21d 100644 --- a/src/modules/extra/m_sql.cpp +++ b/src/modules/extra/m_sql.cpp @@ -92,15 +92,15 @@ class SQLConnection // the number of effected rows is returned in the return value. unsigned long QueryCount(std::string query) { - int r = mysql_query(&connection, query.c_str()); - if (!r) - { - res = mysql_store_result(&connection); - unsigned long rows = mysql_affected_rows(&connection); - mysql_free_result(res); - return rows; - } - return 0; + int r = mysql_query(&connection, query.c_str()); + if (!r) + { + res = mysql_store_result(&connection); + unsigned long rows = mysql_affected_rows(&connection); + mysql_free_result(res); + return rows; + } + return 0; } // This method fetches a row, if available from the database. You must issue a query diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp index c9a86e9bc..845c3e0d9 100644 --- a/src/modules/extra/m_sqllog.cpp +++ b/src/modules/extra/m_sqllog.cpp @@ -57,8 +57,7 @@ class ModuleSQLLog : public Module return (SQLModule); } - ModuleSQLLog(Server* Me) - : Module::Module(Me) + ModuleSQLLog(Server* Me) : Module::Module(Me) { Srv = Me; ReadConfig(); @@ -67,7 +66,7 @@ class ModuleSQLLog : public Module void Implements(char* List) { List[I_OnRehash] = List[I_OnOper] = List[I_OnGlobalOper] = List[I_OnKill] = 1; - List[I_OnPreCommand] = List[I_OnUserConnect] = List[I_OnGlobalConnect] = 1; + List[I_OnPreCommand] = List[I_OnUserConnect] = List[I_OnGlobalConnect] = 1; List[I_OnUserQuit] = List[I_OnLoadModule] = 1; } @@ -79,40 +78,49 @@ class ModuleSQLLog : public Module long InsertNick(const std::string &nick) { long nid = -1; - SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,actor FROM ircd_log_actors WHERE actor='"+nick+"'"); - Request queryrequest((char*)query, this, SQLModule); - SQLResult* result = (SQLResult*)queryrequest.Send(); - if (result->GetType() == SQL_OK) - { - SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,""); - Request rowquery((char*)rowrequest, this, SQLModule); - SQLResult* rowresult = (SQLResult*)rowquery.Send(); - if (rowresult->GetType() == SQL_ROW) - { - nid = atoi(rowresult->GetField("id").c_str()); - delete rowresult; - } - delete rowrequest; - delete result; - } - query->SetQueryType(SQL_DONE); - query->SetConnID(dbid); - Request donerequest((char*)query, this, SQLModule); - donerequest.Send(); - delete query; + + SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,actor FROM ircd_log_actors WHERE actor='"+nick+"'"); + Request queryrequest((char*)query, this, SQLModule); + SQLResult* result = (SQLResult*)queryrequest.Send(); + + if (result->GetType() == SQL_OK) + { + SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,""); + Request rowquery((char*)rowrequest, this, SQLModule); + SQLResult* rowresult = (SQLResult*)rowquery.Send(); + + if (rowresult->GetType() == SQL_ROW) + { + nid = atoi(rowresult->GetField("id").c_str()); + delete rowresult; + } + + delete rowrequest; + delete result; + } + + query->SetQueryType(SQL_DONE); + query->SetConnID(dbid); + Request donerequest((char*)query, this, SQLModule); + donerequest.Send(); + delete query; + if (nid < 1) { SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_actors VALUES('','"+nick+"')"); Request queryrequest2((char*)query2, this, SQLModule); SQLResult* result2 = (SQLResult*)queryrequest2.Send(); - if (result2->GetType() == SQL_ERROR) - { - Srv->Log(DEFAULT,"SQL log error: " + result2->GetError()); - } + + if (result2->GetType() == SQL_ERROR) + { + Srv->Log(DEFAULT,"SQL log error: " + result2->GetError()); + } + if (result2) delete result; if (query2) delete query2; + nid = InsertNick(nick); } return nid; @@ -121,61 +129,74 @@ class ModuleSQLLog : public Module void InsertEntry(unsigned long category,unsigned long nickid,unsigned long hostid,unsigned long sourceid,unsigned long date) { char querybuffer[MAXBUF]; + snprintf(querybuffer,MAXBUF,"INSERT INTO ircd_log VALUES('',%lu,%lu,%lu,%lu,%lu)",(unsigned long)category,(unsigned long)nickid,(unsigned long)hostid,(unsigned long)sourceid,(unsigned long)date); SQLRequest* query = new SQLRequest(SQL_COUNT,dbid,querybuffer); Request queryrequest((char*)query, this, SQLModule); SQLResult* result = (SQLResult*)queryrequest.Send(); + if (result->GetType() == SQL_ERROR) { Srv->Log(DEFAULT,"SQL log error: " + result->GetError()); } + if (result) delete result; if (query) delete query; + return; } long InsertHost(const std::string &host) { - long hid = -1; - SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,hostname FROM ircd_log_hosts WHERE hostname='"+host+"'"); - Request queryrequest((char*)query, this, SQLModule); - SQLResult* result = (SQLResult*)queryrequest.Send(); - if (result->GetType() == SQL_OK) - { - SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,""); - Request rowquery((char*)rowrequest, this, SQLModule); - SQLResult* rowresult = (SQLResult*)rowquery.Send(); - if (rowresult->GetType() == SQL_ROW) - { - hid = atoi(rowresult->GetField("id").c_str()); - delete rowresult; - } - delete rowrequest; - delete result; - } - query->SetQueryType(SQL_DONE); - query->SetConnID(dbid); - Request donerequest((char*)query, this, SQLModule); - donerequest.Send(); - delete query; - if (hid < 1) - { - SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_hosts VALUES('','"+host+"')"); - Request queryrequest2((char*)query2, this, SQLModule); - SQLResult* result2 = (SQLResult*)queryrequest2.Send(); - if (result2->GetType() == SQL_ERROR) - { - Srv->Log(DEFAULT,"SQL log error: " + result2->GetError()); - } - if (result) - delete result2; + long hid = -1; + + SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,hostname FROM ircd_log_hosts WHERE hostname='"+host+"'"); + Request queryrequest((char*)query, this, SQLModule); + SQLResult* result = (SQLResult*)queryrequest.Send(); + + if (result->GetType() == SQL_OK) + { + SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,""); + Request rowquery((char*)rowrequest, this, SQLModule); + SQLResult* rowresult = (SQLResult*)rowquery.Send(); + + if (rowresult->GetType() == SQL_ROW) + { + hid = atoi(rowresult->GetField("id").c_str()); + delete rowresult; + } + + delete rowrequest; + delete result; + } + + query->SetQueryType(SQL_DONE); + query->SetConnID(dbid); + Request donerequest((char*)query, this, SQLModule); + donerequest.Send(); + delete query; + + if (hid < 1) + { + SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_hosts VALUES('','"+host+"')"); + Request queryrequest2((char*)query2, this, SQLModule); + SQLResult* result2 = (SQLResult*)queryrequest2.Send(); + + if (result2->GetType() == SQL_ERROR) + { + Srv->Log(DEFAULT,"SQL log error: " + result2->GetError()); + } + + if (result) + delete result2; if (query) delete query2; - hid = InsertHost(host); - } - return hid; + hid = InsertHost(host); + } + + return hid; } void AddLogEntry(int category, const std::string &nick, const std::string &host, const std::string &source) diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 109be1e3d..27e6e3f02 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -189,7 +189,7 @@ class ModuleSSLOpenSSL : public Module { log(DEFAULT, "m_ssl_openssl.so: Can't read CA list from ", cafile.c_str()); } - + FILE* dhpfile = fopen(dhfile.c_str(), "r"); DH* ret; diff --git a/src/modules/m_antibottler.cpp b/src/modules/m_antibottler.cpp index 89effc607..58ee0b5d6 100644 --- a/src/modules/m_antibottler.cpp +++ b/src/modules/m_antibottler.cpp @@ -33,10 +33,10 @@ class ModuleAntiBottler : public Module Srv = Me; } - void Implements(char* List) - { - List[I_OnServerRaw] = 1; - } + void Implements(char* List) + { + List[I_OnServerRaw] = 1; + } virtual ~ModuleAntiBottler() diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index 03b4f0f9d..ee1a63424 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -3,7 +3,7 @@ * +------------------------------------+ * * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. - * E-mail: + * E-mail: * <brain@chatspike.net> * <Craig@chatspike.net> * @@ -70,10 +70,10 @@ class ModuleCensor : public Module } - virtual void On005Numeric(std::string &output) - { + virtual void On005Numeric(std::string &output) + { InsertMode(output,"G",4); - } + } virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms) @@ -158,10 +158,10 @@ class ModuleCensor : public Module throw(e); } censors.clear(); - for (int index = 0; index < MyConf->Enumerate("badword"); index++) - { - irc::string pattern = (MyConf->ReadValue("badword","text",index)).c_str(); - irc::string replace = (MyConf->ReadValue("badword","replace",index)).c_str(); + for (int index = 0; index < MyConf->Enumerate("badword"); index++) + { + irc::string pattern = (MyConf->ReadValue("badword","text",index)).c_str(); + irc::string replace = (MyConf->ReadValue("badword","replace",index)).c_str(); censors[pattern] = replace; } delete Conf; diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index 90f564ee1..9e8d36ff8 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -53,10 +53,10 @@ class ModuleChanFilter : public Module List[I_On005Numeric] = List[I_OnUserPart] = List[I_OnRehash] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnExtendedMode] = List[I_OnSendList] = List[I_OnSyncChannel] = 1; } - virtual void On005Numeric(std::string &output) - { + virtual void On005Numeric(std::string &output) + { InsertMode(output,"g",1); - } + } virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partreason) { @@ -80,8 +80,8 @@ class ModuleChanFilter : public Module MaxEntries = Conf->ReadInteger("chanfilter","maxsize",0,true); } - virtual int ProcessMessages(userrec* user,chanrec* chan,std::string &text) - { + virtual int ProcessMessages(userrec* user,chanrec* chan,std::string &text) + { // Create a copy of the string in irc::string irc::string line = text.c_str(); diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index b7d67d9ae..b6f277c03 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -59,10 +59,10 @@ class ModuleChanProtect : public Module List[I_On005Numeric] = List[I_OnUserKick] = List[I_OnUserPart] = List[I_OnRehash] = List[I_OnUserJoin] = List[I_OnAccessCheck] = List[I_OnExtendedMode] = List[I_OnSendList] = List[I_OnSyncChannel] = 1; } - virtual void On005Numeric(std::string &output) - { + virtual void On005Numeric(std::string &output) + { InsertMode(output,"qa",1); - } + } virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { @@ -301,18 +301,18 @@ class ModuleChanProtect : public Module } WriteServ(user->fd,"387 %s %s :End of channel founder list",user->nick, channel->name); } - if (mode == 'a') - { - chanuserlist cl = Srv->GetUsers(channel); - for (unsigned int i = 0; i < cl.size(); i++) - { - if (cl[i]->GetExt("cm_protect_"+std::string(channel->name))) - { - WriteServ(user->fd,"388 %s %s %s",user->nick, channel->name,cl[i]->nick); - } - } + if (mode == 'a') + { + chanuserlist cl = Srv->GetUsers(channel); + for (unsigned int i = 0; i < cl.size(); i++) + { + if (cl[i]->GetExt("cm_protect_"+std::string(channel->name))) + { + WriteServ(user->fd,"388 %s %s %s",user->nick, channel->name,cl[i]->nick); + } + } WriteServ(user->fd,"389 %s %s :End of channel protected user list",user->nick, channel->name); - } + } } diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index d77ddf515..1a547f548 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -30,12 +30,12 @@ static Server *Srv; class cmd_chghost : public command_t { public: - cmd_chghost () : command_t("CHGHOST",'o',2) - { - this->source = "m_chghost.so"; - } + cmd_chghost () : command_t("CHGHOST",'o',2) + { + this->source = "m_chghost.so"; + } - void Handle(char **parameters, int pcnt, userrec *user) + void Handle(char **parameters, int pcnt, userrec *user) { char * x = parameters[1]; diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 92ae1af6c..4b9be01c4 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -368,22 +368,22 @@ class ModuleCloaking : public Module this->GenHash(dest->host,ra); std::string b = ""; in_addr testaddr; - std::string hostcloak = prefix + "-" + std::string(ra) + a; - /* Fix by brain - if the cloaked host is > the max length of a host (64 bytes - * according to the DNS RFC) then tough titty, they get cloaked as an IP. - * Their ISP shouldnt go to town on subdomains, or they shouldnt have a kiddie - * vhost. - */ - if ((!inet_aton(dest->host,&testaddr)) && (hostcloak.length() < 64)) - { - // if they have a hostname, make something appropriate - b = hostcloak; - } - else - { - // else, they have an ip - b = std::string(ra) + "." + prefix + ".cloak"; - } + std::string hostcloak = prefix + "-" + std::string(ra) + a; + /* Fix by brain - if the cloaked host is > the max length of a host (64 bytes + * according to the DNS RFC) then tough titty, they get cloaked as an IP. + * Their ISP shouldnt go to town on subdomains, or they shouldnt have a kiddie + * vhost. + */ + if ((!inet_aton(dest->host,&testaddr)) && (hostcloak.length() < 64)) + { + // if they have a hostname, make something appropriate + b = hostcloak; + } + else + { + // else, they have an ip + b = std::string(ra) + "." + prefix + ".cloak"; + } Srv->Log(DEBUG,"cloak: allocated "+b); Srv->ChangeHost(dest,b); } diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index c838a495d..cfa96e2b3 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -57,8 +57,8 @@ class ModuleDenyChannels : public Module List[I_OnUserPreJoin] = List[I_OnRehash] = 1; } - virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) - { + virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) + { for (int j =0; j < Conf->Enumerate("badchan"); j++) { irc::string cn = Conf->ReadValue("badchan","name",j).c_str(); @@ -78,7 +78,7 @@ class ModuleDenyChannels : public Module } } return 0; - } + } }; // stuff down here is the module-factory stuff. For basic modules you can ignore this. diff --git a/src/modules/m_devoice.cpp b/src/modules/m_devoice.cpp index 3ea72de39..75bc4c4f3 100644 --- a/src/modules/m_devoice.cpp +++ b/src/modules/m_devoice.cpp @@ -46,12 +46,12 @@ class cmd_devoice : public command_t * * - I'm not aware what checking I need, so for now... be supreme evil. */ - char* modes[3]; - modes[0] = parameters[0]; - modes[1] = "-v"; - modes[2] = user->nick; + char* modes[3]; + modes[0] = parameters[0]; + modes[1] = "-v"; + modes[2] = user->nick; - Srv->SendMode(modes,3,user); + Srv->SendMode(modes,3,user); } }; @@ -96,7 +96,7 @@ class ModuleDeVoiceFactory : public ModuleFactory }; -extern "C" void * init_module( void ) +extern "C" void * devoice_init( void ) { return new ModuleDeVoiceFactory; } diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp index 4456a1352..1cb14ba83 100644 --- a/src/modules/m_globalload.cpp +++ b/src/modules/m_globalload.cpp @@ -16,12 +16,7 @@ using namespace std; -/* - * DEVOICE module for InspIRCd - * Syntax: /DEVOICE <#chan> - */ - -/* $ModDesc: Provides voiced users with the ability to devoice themselves. */ +/* $ModDesc: Allows global loading of a module. */ #include <stdio.h> #include "users.h" @@ -42,15 +37,15 @@ class cmd_gloadmodule : public command_t void Handle (char **parameters, int pcnt, userrec *user) { - if (ServerInstance->LoadModule(parameters[0])) - { - WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick); - WriteServ(user->fd,"975 %s %s :Module successfully loaded.",user->nick, parameters[0]); - } - else - { - WriteServ(user->fd,"974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError()); - } + if (ServerInstance->LoadModule(parameters[0])) + { + WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick); + WriteServ(user->fd,"975 %s %s :Module successfully loaded.",user->nick, parameters[0]); + } + else + { + WriteServ(user->fd,"974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError()); + } } }; @@ -64,14 +59,14 @@ class cmd_gunloadmodule : public command_t void Handle (char **parameters, int pcnt, userrec *user) { - if (ServerInstance->UnloadModule(parameters[0])) - { - WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick); - WriteServ(user->fd,"973 %s %s :Module successfully unloaded.",user->nick, parameters[0]); - } + if (ServerInstance->UnloadModule(parameters[0])) + { + WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick); + WriteServ(user->fd,"973 %s %s :Module successfully unloaded.",user->nick, parameters[0]); + } else { - WriteServ(user->fd,"972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError()); + WriteServ(user->fd,"972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError()); } } }; diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp index 49dd99f67..a4a5a8b08 100644 --- a/src/modules/m_hostchange.cpp +++ b/src/modules/m_hostchange.cpp @@ -46,7 +46,7 @@ class ModuleHostChange : public Module : Module::Module(Me) { Srv = Me; - Conf = new ConfigReader; + Conf = new ConfigReader; OnRehash(""); } diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index f11d6f330..2c6e40c8c 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -71,16 +71,16 @@ class RFC1413 : public InspSocket if (section) { while (*section == ' ') section++; // strip leading spaces - for (char* j = section; *j; j++) - if ((*j < 33) || (*j > 126)) + for (char* j = section; *j; j++) + if ((*j < 33) || (*j > 126)) *j = '\0'; // truncate at invalid chars - if (*section) - { - strlcpy(u->ident,section,IDENTMAX); - Srv->Log(DEBUG,"IDENT SET: "+std::string(u->ident)); - Srv->SendServ(u->fd,"NOTICE "+std::string(u->nick)+" :*** Found your ident: "+std::string(u->ident)); - } - return false; + if (*section) + { + strlcpy(u->ident,section,IDENTMAX); + Srv->Log(DEBUG,"IDENT SET: "+std::string(u->ident)); + Srv->SendServ(u->fd,"NOTICE "+std::string(u->nick)+" :*** Found your ident: "+std::string(u->ident)); + } + return false; } } } @@ -158,10 +158,12 @@ class ModuleIdent : public Module virtual void OnUserRegister(userrec* user) { - // when the new user connects, before they authenticate with USER/NICK/PASS, we do - // their ident lookup. We do this by instantiating an object of type RFC1413, which - // is derived from InspSocket, and inserting it into the socket engine using the - // Server::AddSocket() call. + /* + * when the new user connects, before they authenticate with USER/NICK/PASS, we do + * their ident lookup. We do this by instantiating an object of type RFC1413, which + * is derived from InspSocket, and inserting it into the socket engine using the + * Server::AddSocket() call. + */ Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :*** Looking up your ident..."); RFC1413* ident = new RFC1413(user, IdentTimeout, Srv); if (ident->GetState() != I_ERROR) @@ -178,9 +180,11 @@ class ModuleIdent : public Module virtual bool OnCheckReady(userrec* user) { - // The socket engine will clean up their ident request for us when it completes, - // either due to timeout or due to closing, so, we just hold them until they dont - // have an ident field any more. + /* + * The socket engine will clean up their ident request for us when it completes, + * either due to timeout or due to closing, so, we just hold them until they dont + * have an ident field any more. + */ RFC1413* ident = (RFC1413*)user->GetExt("ident_data"); return (!ident); } @@ -198,20 +202,22 @@ class ModuleIdent : public Module } } - virtual void OnUserDisconnect(userrec* user) - { - // when the user quits tidy up any ident lookup they have pending to keep things tidy. - // When we call RemoveSocket, the abstractions tied into the system evnetually work their - // way to RFC1459::OnClose(), which shrinks off the ident_data for us, so we dont need - // to do it here. If we don't tidy this up, there may still be lingering idents for users - // who have quit, as class RFC1459 is only loosely bound to userrec* via a pair of pointers - // and this would leave at least one of the invalid ;) + virtual void OnUserDisconnect(userrec* user) + { + /* + * when the user quits tidy up any ident lookup they have pending to keep things tidy. + * When we call RemoveSocket, the abstractions tied into the system evnetually work their + * way to RFC1459::OnClose(), which shrinks off the ident_data for us, so we dont need + * to do it here. If we don't tidy this up, there may still be lingering idents for users + * who have quit, as class RFC1459 is only loosely bound to userrec* via a pair of pointers + * and this would leave at least one of the invalid ;) + */ RFC1413* ident = (RFC1413*)user->GetExt("ident_data"); - if (ident) - { + if (ident) + { Srv->RemoveSocket(ident); - } - } + } + } virtual ~ModuleIdent() { diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index 9169cfd4c..c22fe5ff0 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -84,10 +84,10 @@ class ModuleKnock : public Module List[I_On005Numeric] = List[I_OnExtendedMode] = 1; } - virtual void On005Numeric(std::string &output) - { + virtual void On005Numeric(std::string &output) + { InsertMode(output,"K",4); - } + } virtual ~ModuleKnock() { diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 681ba616a..36d2ea1be 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -198,12 +198,12 @@ class ModuleMsgFlood : public Module } } - virtual void OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status) + virtual void OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status) { - if (target_type == TYPE_CHANNEL) - { - ProcessMessages(user,(chanrec*)dest,text); - } + if (target_type == TYPE_CHANNEL) + { + ProcessMessages(user,(chanrec*)dest,text); + } } virtual void OnUserNotice(userrec* user, void* dest, int target_type, const std::string &text, char status) diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp index 42d233002..7d69a92b6 100644 --- a/src/modules/m_noctcp.cpp +++ b/src/modules/m_noctcp.cpp @@ -42,10 +42,10 @@ class ModuleNoCTCP : public Module List[I_OnExtendedMode] = List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1; } - virtual void On005Numeric(std::string &output) - { + virtual void On005Numeric(std::string &output) + { InsertMode(output,"C",4); - } + } virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status) { diff --git a/src/modules/m_nokicks.cpp b/src/modules/m_nokicks.cpp index be16da608..564ff86e6 100644 --- a/src/modules/m_nokicks.cpp +++ b/src/modules/m_nokicks.cpp @@ -42,10 +42,10 @@ class ModuleNoKicks : public Module List[I_On005Numeric] = List[I_OnAccessCheck] = List[I_OnExtendedMode] = 1; } - virtual void On005Numeric(std::string &output) - { + virtual void On005Numeric(std::string &output) + { InsertMode(output,"Q",4); - } + } virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type) { diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp index 78d10db33..e4e2b72f3 100644 --- a/src/modules/m_nonicks.cpp +++ b/src/modules/m_nonicks.cpp @@ -53,10 +53,10 @@ class ModuleNoNickChange : public Module List[I_On005Numeric] = List[I_OnUserPreNick] = List[I_OnExtendedMode] = 1; } - virtual void On005Numeric(std::string &output) - { + virtual void On005Numeric(std::string &output) + { InsertMode(output,"N",4); - } + } virtual int OnUserPreNick(userrec* user, const std::string &newnick) { diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp index 1e977d355..0a079e885 100644 --- a/src/modules/m_nonotice.cpp +++ b/src/modules/m_nonotice.cpp @@ -63,10 +63,10 @@ class ModuleNoNotice : public Module return 0; } - virtual void On005Numeric(std::string &output) - { + virtual void On005Numeric(std::string &output) + { InsertMode(output,"T",4); - } + } virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms) { diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp index 7ff66bdb2..01b55f9cc 100644 --- a/src/modules/m_operchans.cpp +++ b/src/modules/m_operchans.cpp @@ -66,10 +66,10 @@ class ModuleOperChans : public Module return 0; } - virtual void On005Numeric(std::string &output) - { + virtual void On005Numeric(std::string &output) + { InsertMode(output,"O",4); - } + } virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) { diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp index cba931257..2517b385f 100644 --- a/src/modules/m_operjoin.cpp +++ b/src/modules/m_operjoin.cpp @@ -60,22 +60,22 @@ class ModuleOperjoin : public Module class ModuleOperjoinFactory : public ModuleFactory { public: - ModuleOperjoinFactory() - { - } - - ~ModuleOperjoinFactory() - { - } - - virtual Module * CreateModule(Server* Me) - { - return new ModuleOperjoin(Me); - } + ModuleOperjoinFactory() + { + } + + ~ModuleOperjoinFactory() + { + } + + virtual Module * CreateModule(Server* Me) + { + return new ModuleOperjoin(Me); + } }; extern "C" void * init_module( void ) { - return new ModuleOperjoinFactory; + return new ModuleOperjoinFactory; } diff --git a/src/modules/m_operlevels.cpp b/src/modules/m_operlevels.cpp index b4a76d5c0..8d545ade8 100644 --- a/src/modules/m_operlevels.cpp +++ b/src/modules/m_operlevels.cpp @@ -87,23 +87,23 @@ class ModuleOperLevels : public Module class ModuleOperLevelsFactory : public ModuleFactory { public: - ModuleOperLevelsFactory() - { - } + ModuleOperLevelsFactory() + { + } - ~ModuleOperLevelsFactory() - { - } + ~ModuleOperLevelsFactory() + { + } - virtual Module * CreateModule(Server* Me) - { - return new ModuleOperLevels(Me); - } + virtual Module * CreateModule(Server* Me) + { + return new ModuleOperLevels(Me); + } }; -extern "C" void * init_module( void ) +extern "C" void * operlevels_init( void ) { - return new ModuleOperLevelsFactory; + return new ModuleOperLevelsFactory; } diff --git a/src/modules/m_opermodes.cpp b/src/modules/m_opermodes.cpp index d99a7ad8a..6bf823d31 100644 --- a/src/modules/m_opermodes.cpp +++ b/src/modules/m_opermodes.cpp @@ -64,12 +64,12 @@ class ModuleModesOnOper : public Module // whenever a user opers, go through the oper types, find their <type:modes>, // and if they have one apply their modes. The mode string can contain +modes // to add modes to the user or -modes to take modes from the user. - for (int j =0; j < Conf->Enumerate("type"); j++) - { - std::string typen = Conf->ReadValue("type","name",j); - if (!strcmp(typen.c_str(),user->oper)) - { - std::string ThisOpersModes = Conf->ReadValue("type","modes",j); + for (int j =0; j < Conf->Enumerate("type"); j++) + { + std::string typen = Conf->ReadValue("type","name",j); + if (!strcmp(typen.c_str(),user->oper)) + { + std::string ThisOpersModes = Conf->ReadValue("type","modes",j); char first = *(ThisOpersModes.c_str()); if ((first != '+') && (first != '-')) ThisOpersModes = "+" + ThisOpersModes; @@ -80,9 +80,9 @@ class ModuleModesOnOper : public Module modes[1] = (char*)ThisOpersModes.c_str(); Srv->SendMode(modes,2,user); } - break; - } - } + break; + } + } } }; diff --git a/src/modules/m_operwho.cpp b/src/modules/m_operwho.cpp index 626c03df6..61832cd4b 100644 --- a/src/modules/m_operwho.cpp +++ b/src/modules/m_operwho.cpp @@ -165,7 +165,7 @@ class ModuleOperWho : public Module } if (*u->oper) { strlcat(tmp, "*" ,9); } WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, u->chans.size() && ((ucrec*)*(u->chans.begin()))->channel ? ((ucrec*)*(u->chans.begin()))->channel->name - : "*", u->ident, u->dhost, u->server, u->nick, tmp, u->fullname); + : "*", u->ident, u->dhost, u->server, u->nick, tmp, u->fullname); } WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]); return 1; @@ -173,10 +173,10 @@ class ModuleOperWho : public Module } if (pcnt == 2) { - if ((!strcmp(parameters[0],"0")) || (!strcmp(parameters[0],"*")) && (!strcmp(parameters[1],"o"))) - { + if ((!strcmp(parameters[0],"0")) || (!strcmp(parameters[0],"*")) && (!strcmp(parameters[1],"o"))) + { for (std::vector<userrec*>::iterator i = all_opers.begin(); i != all_opers.end(); i++) - { + { // If i were a rich man.. I wouldn't need to me making these bugfixes.. // But i'm a poor bastard with nothing better to do. userrec* oper = *i; @@ -186,12 +186,12 @@ class ModuleOperWho : public Module } else { strlcat(tmp, "H" ,9); } - WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() && ((ucrec*)*(oper->chans.begin()))->channel ? + WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() && ((ucrec*)*(oper->chans.begin()))->channel ? ((ucrec*)*(oper->chans.begin()))->channel->name : "*", oper->ident, oper->host, oper->server, oper->nick, tmp, oper->fullname); - } - WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]); - return 1; - } + } + WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]); + return 1; + } } return 0; } diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp index 4cd163af1..935efa39c 100644 --- a/src/modules/m_park.cpp +++ b/src/modules/m_park.cpp @@ -69,7 +69,7 @@ class cmd_park : public command_t int othersessions = 0; /* XXX - why can't just use pinfo.size() like we do below, rather than iterating over the whole vector? -- w00t */ if (pinfo.size()) - for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) + for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) if (j->host == std::string(user->host)) othersessions++; if (othersessions >= ConcurrentParks) @@ -153,8 +153,8 @@ class cmd_unpark : public command_t if (key == atoi(parameters[1])) { // first part the user from all chans theyre on, so things dont get messy - for (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++) - { + for (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++) + { if (((ucrec*)(*i))->channel != NULL) { Srv->PartUserFromChannel(user,((ucrec*)(*i))->channel->name,"Unparking"); @@ -240,24 +240,24 @@ class ModulePark : public Module this->ReadSettings(); } - virtual void On005Numeric(std::string &output) - { - output = output + std::string(" PARK"); - } + virtual void On005Numeric(std::string &output) + { + output = output + std::string(" PARK"); + } - virtual void OnUserQuit(userrec* user, const std::string &reason) - { - std::string nick = user->nick; - // track quits in our parked user list - for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) - { - if (j->nick == nick) - { - pinfo.erase(j); - break; - } - } - } + virtual void OnUserQuit(userrec* user, const std::string &reason) + { + std::string nick = user->nick; + // track quits in our parked user list + for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) + { + if (j->nick == nick) + { + pinfo.erase(j); + break; + } + } + } virtual void OnPrePrivmsg(userrec* user, userrec* dest, const std::string &text) @@ -283,42 +283,42 @@ class ModulePark : public Module // track nickchanges in our parked user list // (this isnt too efficient, i'll tidy it up some time) /* XXX - perhaps extend the user record, or, that wouldn't work - perhaps use a map? -- w00t */ - for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) - { - if (j->nick == std::string(user->nick)) - { - j->nick = newnick; - break; - } - } + for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) + { + if (j->nick == std::string(user->nick)) + { + j->nick = newnick; + break; + } + } return 0; } virtual void OnBackgroundTimer(time_t curtime) { - // look for parked clients which have timed out (this needs tidying) - if (pinfo.empty()) - return; - bool go_again = true; - while (go_again) - { - go_again = false; - for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) - { - if (time(NULL) >= (j->parktime+ParkMaxTime)) - { - userrec* thisnick = Srv->FindNick(j->nick); + // look for parked clients which have timed out (this needs tidying) + if (pinfo.empty()) + return; + bool go_again = true; + while (go_again) + { + go_again = false; + for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) + { + if (time(NULL) >= (j->parktime+ParkMaxTime)) + { + userrec* thisnick = Srv->FindNick(j->nick); // THIS MUST COME BEFORE THE QuitUser - QuitUser can // create a recursive call to OnUserQuit in this module // and then corrupt the pointer! pinfo.erase(j); - if (thisnick) - Srv->QuitUser(thisnick,"PARK timeout"); - go_again = true; - break; - } - } - } + if (thisnick) + Srv->QuitUser(thisnick,"PARK timeout"); + go_again = true; + break; + } + } + } } /* XXX - why is OnPrePrivmsg seperated here, I assume there is reason for the extra function call? --w00t */ @@ -332,11 +332,11 @@ class ModulePark : public Module return 0; } - virtual void OnWhois(userrec* src, userrec* dst) - { + virtual void OnWhois(userrec* src, userrec* dst) + { if (dst->GetExt("park_awaylog")) - Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a parked client"); - } + Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a parked client"); + } virtual Version GetVersion() { diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp index 430adf9ef..a3b4c4a7e 100644 --- a/src/modules/m_randquote.cpp +++ b/src/modules/m_randquote.cpp @@ -99,7 +99,7 @@ class ModuleRandQuote : public Module { RandquoteException e("m_randquote: Quotefile not specified - Please check your config."); throw(e); - } + } quotes = new FileReader(q_file); if(!quotes->Exists()) diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index fab61d07c..7662ef5d4 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -150,10 +150,10 @@ class ModuleRemove : public Module List[I_On005Numeric] = 1; } - virtual void On005Numeric(std::string &output) - { - output = output + std::string(" REMOVE"); - } + virtual void On005Numeric(std::string &output) + { + output = output + std::string(" REMOVE"); + } virtual ~ModuleRemove() { diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp index d4173213e..e9ea965f9 100644 --- a/src/modules/m_safelist.cpp +++ b/src/modules/m_safelist.cpp @@ -3,13 +3,13 @@ * +------------------------------------+ * * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. - * E-mail: - * <brain@chatspike.net> - * <Craig@chatspike.net> + * E-mail: + * <brain@chatspike.net> + * <Craig@chatspike.net> * * 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. * * --------------------------------------------------- */ @@ -62,44 +62,44 @@ class ListTimer : public InspTimer virtual void Tick(time_t TIME) { - bool go_again = true; + bool go_again = true; - while (go_again) - { - go_again = false; - for (UserList::iterator iter = listusers.begin(); iter != listusers.end(); iter++) - { - /* - * What we do here: - * - Get where they are up to - * - If it's > GetChannelCount, erase them from the iterator, set go_again to true - * - If not, spool the next 20 channels - */ - userrec* u = (userrec*)(*iter); - ListData* ld = (ListData*)u->GetExt("safelist_cache"); - if (ld->list_position > Srv->GetChannelCount()) - { - u->Shrink("safelist_cache"); - delete ld; - listusers.erase(iter); - go_again = true; - break; - } + while (go_again) + { + go_again = false; + for (UserList::iterator iter = listusers.begin(); iter != listusers.end(); iter++) + { + /* + * What we do here: + * - Get where they are up to + * - If it's > GetChannelCount, erase them from the iterator, set go_again to true + * - If not, spool more channels + */ + userrec* u = (userrec*)(*iter); + ListData* ld = (ListData*)u->GetExt("safelist_cache"); + if (ld->list_position > Srv->GetChannelCount()) + { + u->Shrink("safelist_cache"); + delete ld; + listusers.erase(iter); + go_again = true; + break; + } - log(DEBUG, "m_safelist.so: resuming spool of list to client %s at channel %ld", u->nick, ld->list_position); - chan = NULL; - /* Attempt to fill up to half the user's sendq with /LIST output */ - long amount_sent = 0; - do - { - log(DEBUG,"Channel %ld",ld->list_position); + log(DEBUG, "m_safelist.so: resuming spool of list to client %s at channel %ld", u->nick, ld->list_position); + chan = NULL; + /* Attempt to fill up to half the user's sendq with /LIST output */ + long amount_sent = 0; + do + { + log(DEBUG,"Channel %ld",ld->list_position); if (!ld->list_position) WriteServ(u->fd,"321 %s Channel :Users Name",u->nick); - chan = Srv->GetChannelIndex(ld->list_position); - /* spool details */ + chan = Srv->GetChannelIndex(ld->list_position); + /* spool details */ bool has_user = (chan && chan->HasUser(u)); - if ((chan) && (((!(chan->modes[CM_PRIVATE])) && (!(chan->modes[CM_SECRET]))) || (has_user))) - { + if ((chan) && (((!(chan->modes[CM_PRIVATE])) && (!(chan->modes[CM_SECRET]))) || (has_user))) + { long users = usercount(chan); if (users) { @@ -109,24 +109,24 @@ class ListTimer : public InspTimer log(DEBUG,"m_safelist.so: Sent %ld of safe %ld / 4",amount_sent,u->sendqmax); WriteServ_NoFormat(u->fd,buffer); } - } - else - { + } + else + { if (!chan) { - if (!ld->list_ended) - { - ld->list_ended = true; - WriteServ(u->fd,"323 %s :End of channel list.",u->nick); - } + if (!ld->list_ended) + { + ld->list_ended = true; + WriteServ(u->fd,"323 %s :End of channel list.",u->nick); + } } - } + } - ld->list_position++; - } - while ((chan != NULL) && (amount_sent < (u->sendqmax / 4))); - } - } + ld->list_position++; + } + while ((chan != NULL) && (amount_sent < (u->sendqmax / 4))); + } + } ListTimer* MyTimer = new ListTimer(1,Srv); Srv->AddTimer(MyTimer); @@ -220,16 +220,16 @@ class ModuleSafeList : public Module return 1; } - virtual void OnCleanup(int target_type, void* item) - { - if(target_type == TYPE_USER) + virtual void OnCleanup(int target_type, void* item) + { + if(target_type == TYPE_USER) { userrec* u = (userrec*)item; ListData* ld = (ListData*)u->GetExt("safelist_cache"); if (ld) { u->Shrink("safelist_cache"); - delete ld; + delete ld; } for (UserList::iterator iter = listusers.begin(); iter != listusers.end(); iter++) { diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index b4118da07..4beda4423 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -71,22 +71,22 @@ class cmd_silence : public command_t // does it contain any entries and does it exist? if (sl) { - if (sl->size()) - { - for (silencelist::iterator i = sl->begin(); i != sl->end(); i++) - { + if (sl->size()) + { + for (silencelist::iterator i = sl->begin(); i != sl->end(); i++) + { // search through for the item irc::string listitem = i->c_str(); irc::string target = nick; if (listitem == target) - { - sl->erase(i); + { + sl->erase(i); WriteServ(user->fd,"950 %s %s :Removed %s!*@* from silence list",user->nick, user->nick,nick); // we have modified the vector from within a loop, we must now bail out - return; - } - } - } + return; + } + } + } if (!sl->size()) { // tidy up -- if a user's list is empty, theres no use having it @@ -178,9 +178,9 @@ class ModuleSilence : public Module { for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++) { - irc::string listitem = c->c_str(); - irc::string target = user->nick; - if (listitem == target) + irc::string listitem = c->c_str(); + irc::string target = user->nick; + if (listitem == target) { return 1; } @@ -190,10 +190,10 @@ class ModuleSilence : public Module return 0; } - virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status) - { + virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status) + { return OnUserPreNotice(user,dest,target_type,text,status); - } + } virtual ~ModuleSilence() { diff --git a/src/modules/m_spy.cpp b/src/modules/m_spy.cpp index a32561760..32c19ccc9 100644 --- a/src/modules/m_spy.cpp +++ b/src/modules/m_spy.cpp @@ -65,30 +65,30 @@ void spy_userlist(userrec *user,chanrec *c) { static char list[MAXBUF]; - if ((!c) || (!user)) - return; - - snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); - - CUList *ulist= c->GetUsers(); - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) - { - strlcat(list,cmode(i->second,c),MAXBUF); - strlcat(list,i->second->nick,MAXBUF); - strlcat(list," ",MAXBUF); - if (strlen(list)>(480-NICKMAX)) - { - /* list overflowed into - * multiple numerics */ - WriteServ_NoFormat(user->fd,list); - snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); - } - } - /* if whats left in the list isnt empty, send it */ - if (list[strlen(list)-1] != ':') - { - WriteServ_NoFormat(user->fd,list); - } + if ((!c) || (!user)) + return; + + snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); + + CUList *ulist= c->GetUsers(); + for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) + { + strlcat(list,cmode(i->second,c),MAXBUF); + strlcat(list,i->second->nick,MAXBUF); + strlcat(list," ",MAXBUF); + if (strlen(list)>(480-NICKMAX)) + { + /* list overflowed into + * multiple numerics */ + WriteServ_NoFormat(user->fd,list); + snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); + } + } + /* if whats left in the list isnt empty, send it */ + if (list[strlen(list)-1] != ':') + { + WriteServ_NoFormat(user->fd,list); + } } @@ -96,20 +96,20 @@ void spy_userlist(userrec *user,chanrec *c) class cmd_spylist : public command_t { public: - cmd_spylist () : command_t("SPYLIST", 'o', 0) - { - this->source = "m_spy.so"; - } + cmd_spylist () : command_t("SPYLIST", 'o', 0) + { + this->source = "m_spy.so"; + } void Handle (char **parameters, int pcnt, userrec *user) { WriteOpers("*** Oper %s used SPYLIST to list +s/+p channels and keys.",user->nick); WriteServ(user->fd,"321 %s Channel :Users Name",user->nick); - for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++) - { + for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++) + { WriteServ(user->fd,"322 %s %s %d :[+%s] %s",user->nick,i->second->name,usercount(i->second),chanmodes(i->second,true),i->second->topic); - } - WriteServ(user->fd,"323 %s :End of channel list.",user->nick); + } + WriteServ(user->fd,"323 %s :End of channel list.",user->nick); } }; @@ -123,29 +123,29 @@ class cmd_spynames : public command_t void Handle (char **parameters, int pcnt, userrec *user) { - chanrec* c; + chanrec* c; - if (!pcnt) - { - WriteServ(user->fd,"366 %s * :End of /NAMES list.",user->nick); - return; - } + if (!pcnt) + { + WriteServ(user->fd,"366 %s * :End of /NAMES list.",user->nick); + return; + } - if (ServerInstance->Parser->LoopCall(this,parameters,pcnt,user,0,pcnt-1,0)) - return; + if (ServerInstance->Parser->LoopCall(this,parameters,pcnt,user,0,pcnt-1,0)) + return; WriteOpers("*** Oper %s used SPYNAMES to view the users on %s",user->nick,parameters[0]); - c = FindChan(parameters[0]); - if (c) - { - spy_userlist(user,c); - WriteServ(user->fd,"366 %s %s :End of /NAMES list.", user->nick, c->name); - } - else - { - WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]); - } + c = FindChan(parameters[0]); + if (c) + { + spy_userlist(user,c); + WriteServ(user->fd,"366 %s %s :End of /NAMES list.", user->nick, c->name); + } + else + { + WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]); + } } }; diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp index 22b1cf7e8..7a5a1141d 100644 --- a/src/modules/m_stripcolor.cpp +++ b/src/modules/m_stripcolor.cpp @@ -58,10 +58,10 @@ class ModuleStripColor : public Module } } - virtual void On005Numeric(std::string &output) - { + virtual void On005Numeric(std::string &output) + { InsertMode(output,"S",4); - } + } virtual ~ModuleStripColor() { @@ -176,7 +176,7 @@ class ModuleStripColorFactory : public ModuleFactory }; -extern "C" void * init_module( void ) +extern "C" void * stripcolor_init( void ) { return new ModuleStripColorFactory; } diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 190f89f0e..98a76ad63 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -62,8 +62,8 @@ class cmd_tban : public command_t } for (timedbans::iterator i = TimedBanList.begin(); i < TimedBanList.end(); i++) { - irc::string listitem = i->mask.c_str(); - irc::string target = parameters[2]; + irc::string listitem = i->mask.c_str(); + irc::string target = parameters[2]; irc::string listchan = i->channel.c_str(); irc::string targetchan = parameters[0]; if ((listitem == target) && (listchan == targetchan)) @@ -129,16 +129,16 @@ class ModuleTimedBans : public Module virtual int OnDelBan(userrec* source, chanrec* chan, const std::string &banmask) { - for (timedbans::iterator i = TimedBanList.begin(); i < TimedBanList.end(); i++) - { - irc::string listitem = banmask.c_str(); - irc::string target = i->mask.c_str(); - if (listitem == target) - { - TimedBanList.erase(i); - break; - } - } + for (timedbans::iterator i = TimedBanList.begin(); i < TimedBanList.end(); i++) + { + irc::string listitem = banmask.c_str(); + irc::string target = i->mask.c_str(); + if (listitem == target) + { + TimedBanList.erase(i); + break; + } + } return 0; } diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp index 07e975392..14660cf1e 100644 --- a/src/modules/m_uninvite.cpp +++ b/src/modules/m_uninvite.cpp @@ -37,50 +37,50 @@ class cmd_uninvite : public command_t void Handle (char **parameters, int pcnt, userrec *user) { - userrec* u = Find(parameters[0]); - chanrec* c = FindChan(parameters[1]); - - if ((!c) || (!u)) - { - if (!c) - { - WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[1]); - } - else - { - WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]); - } - - return; - } - - if (c->modes[CM_INVITEONLY]) - { - if (cstatus(user,c) < STATUS_HOP) - { - WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name); - return; - } - } + userrec* u = Find(parameters[0]); + chanrec* c = FindChan(parameters[1]); + + if ((!c) || (!u)) + { + if (!c) + { + WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[1]); + } + else + { + WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]); + } + + return; + } + + if (c->modes[CM_INVITEONLY]) + { + if (cstatus(user,c) < STATUS_HOP) + { + WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name); + return; + } + } irc::string xname(c->name); - if (!u->IsInvited(xname)) - { - WriteServ(user->fd,"491 %s %s %s :Is not invited to channel %s",user->nick,u->nick,c->name,c->name); - return; - } - if (!c->HasUser(user)) - { - WriteServ(user->fd,"492 %s %s :You're not on that channel!",user->nick, c->name); - return; - } - - u->RemoveInvite(xname); - WriteServ(user->fd,"494 %s %s %s :Uninvited",user->nick,c->name,u->nick); + if (!u->IsInvited(xname)) + { + WriteServ(user->fd,"491 %s %s %s :Is not invited to channel %s",user->nick,u->nick,c->name,c->name); + return; + } + if (!c->HasUser(user)) + { + WriteServ(user->fd,"492 %s %s :You're not on that channel!",user->nick, c->name); + return; + } + + u->RemoveInvite(xname); + WriteServ(user->fd,"494 %s %s %s :Uninvited",user->nick,c->name,u->nick); WriteServ(u->fd,"493 %s :You were uninvited from %s by %s",u->nick,c->name,user->nick); - WriteChannel(c,user,"NOTICE %s :*** %s uninvited %s.",c->name,user->nick,u->nick); - } + WriteChannel(c,user,"NOTICE %s :*** %s uninvited %s.",c->name,user->nick,u->nick); + } }; class ModuleUninvite : public Module diff --git a/src/modules/m_userip.cpp b/src/modules/m_userip.cpp index fe6435b9d..55101705e 100644 --- a/src/modules/m_userip.cpp +++ b/src/modules/m_userip.cpp @@ -37,18 +37,18 @@ class cmd_userip : public command_t void Handle (char **parameters, int pcnt, userrec *user) { - char Return[MAXBUF],junk[MAXBUF]; - snprintf(Return,MAXBUF,"340 %s :",user->nick); - for (int i = 0; i < pcnt; i++) - { - userrec *u = Find(parameters[i]); - if (u) - { - snprintf(junk,MAXBUF,"%s%s=+%s@%s ",u->nick,*u->oper ? "*" : "",u->ident,(char*)inet_ntoa(u->ip4)); - strlcat(Return,junk,MAXBUF); - } - } - WriteServ(user->fd,Return); + char Return[MAXBUF],junk[MAXBUF]; + snprintf(Return,MAXBUF,"340 %s :",user->nick); + for (int i = 0; i < pcnt; i++) + { + userrec *u = Find(parameters[i]); + if (u) + { + snprintf(junk,MAXBUF,"%s%s=+%s@%s ",u->nick,*u->oper ? "*" : "",u->ident,(char*)inet_ntoa(u->ip4)); + strlcat(Return,junk,MAXBUF); + } + } + WriteServ(user->fd,Return); } }; @@ -69,10 +69,10 @@ class ModuleUserIP : public Module List[I_On005Numeric] = 1; } - virtual void On005Numeric(std::string &output) - { + virtual void On005Numeric(std::string &output) + { output = output + std::string(" USERIP"); - } + } virtual ~ModuleUserIP() { diff --git a/src/modules/m_vhost.cpp b/src/modules/m_vhost.cpp index 22bb771c2..a2e77f091 100644 --- a/src/modules/m_vhost.cpp +++ b/src/modules/m_vhost.cpp @@ -29,30 +29,30 @@ static Server* Srv; class cmd_vhost : public command_t { public: - cmd_vhost() : command_t("VHOST", 0, 2) - { - this->source = "m_vhost.so"; - } + cmd_vhost() : command_t("VHOST", 0, 2) + { + this->source = "m_vhost.so"; + } - void Handle (char **parameters, int pcnt, userrec *user) - { - for (int index = 0; index < Conf->Enumerate("vhost"); index++) - { - std::string mask = Conf->ReadValue("vhost","host",index); + void Handle (char **parameters, int pcnt, userrec *user) + { + for (int index = 0; index < Conf->Enumerate("vhost"); index++) + { + std::string mask = Conf->ReadValue("vhost","host",index); std::string username = Conf->ReadValue("vhost","user",index); std::string pass = Conf->ReadValue("vhost","pass",index); - if ((!strcmp(parameters[0],username.c_str())) && (!strcmp(parameters[1],pass.c_str()))) - { - if (mask != "") - { - Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask); - Srv->ChangeHost(user,mask); - return; - } - } - } + if ((!strcmp(parameters[0],username.c_str())) && (!strcmp(parameters[1],pass.c_str()))) + { + if (mask != "") + { + Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask); + Srv->ChangeHost(user,mask); + return; + } + } + } Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Invalid username or password."); - } + } }; class ModuleVHost : public Module @@ -62,13 +62,12 @@ class ModuleVHost : public Module cmd_vhost* mycommand; public: - ModuleVHost(Server* Me) - : Module::Module(Me) + ModuleVHost(Server* Me) : Module::Module(Me) { Srv = Me; - Conf = new ConfigReader; - mycommand = new cmd_vhost(); - Srv->AddCommand(mycommand); + Conf = new ConfigReader; + mycommand = new cmd_vhost(); + Srv->AddCommand(mycommand); } virtual ~ModuleVHost() diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index e3a0815a5..1e11dfd51 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -51,17 +51,17 @@ class cmd_watch : public command_t { if (!pcnt) { - for (watchlist::iterator q = watches.begin(); q != watches.end(); q++) - { - if (q->watcher == user) - { + for (watchlist::iterator q = watches.begin(); q != watches.end(); q++) + { + if (q->watcher == user) + { userrec* targ = Srv->FindNick(q->target); if (targ) { WriteServ(user->fd,"604 %s %s %s %s %lu :is online",user->nick,targ->nick,targ->ident,targ->dhost,targ->age); } - } - } + } + } WriteServ(user->fd,"607 %s :End of WATCH list",user->nick); } else if (pcnt > 0) @@ -72,46 +72,46 @@ class cmd_watch : public command_t if (!strcasecmp(nick,"C")) { // watch clear - bool done = false; - while (!done) - { - done = true; - for (watchlist::iterator q = watches.begin(); q != watches.end(); q++) - { - if (q->watcher == user) - { - done = false; - watches.erase(q); - break; - } - } - } + bool done = false; + while (!done) + { + done = true; + for (watchlist::iterator q = watches.begin(); q != watches.end(); q++) + { + if (q->watcher == user) + { + done = false; + watches.erase(q); + break; + } + } + } } else if (!strcasecmp(nick,"L")) { - for (watchlist::iterator q = watches.begin(); q != watches.end(); q++) - { - if (q->watcher == user) - { - userrec* targ = Srv->FindNick(q->target); - if (targ) - { - WriteServ(user->fd,"604 %s %s %s %s %lu :is online",user->nick,targ->nick,targ->ident,targ->dhost,targ->age); - } - } - } - WriteServ(user->fd,"607 %s :End of WATCH list",user->nick); + for (watchlist::iterator q = watches.begin(); q != watches.end(); q++) + { + if (q->watcher == user) + { + userrec* targ = Srv->FindNick(q->target); + if (targ) + { + WriteServ(user->fd,"604 %s %s %s %s %lu :is online",user->nick,targ->nick,targ->ident,targ->dhost,targ->age); + } + } + } + WriteServ(user->fd,"607 %s :End of WATCH list",user->nick); } else if (!strcasecmp(nick,"S")) { std::string list = ""; - for (watchlist::iterator q = watches.begin(); q != watches.end(); q++) - { - if (q->watcher == user) - { + for (watchlist::iterator q = watches.begin(); q != watches.end(); q++) + { + if (q->watcher == user) + { list = list + " " + q->target; - } - } + } + } char* l = (char*)list.c_str(); if (*l == ' ') l++; @@ -123,25 +123,25 @@ class cmd_watch : public command_t // removing an item from the list nick++; irc::string n1 = nick; - for (watchlist::iterator q = watches.begin(); q != watches.end(); q++) - { - if (q->watcher == user) - { + for (watchlist::iterator q = watches.begin(); q != watches.end(); q++) + { + if (q->watcher == user) + { irc::string n2 = q->target.c_str(); userrec* a = Srv->FindNick(q->target); - if (a) - { - WriteServ(user->fd,"602 %s %s %s %s %lu :stopped watching",user->nick,a->nick,a->ident,a->dhost,a->age); - } - else - { - WriteServ(user->fd,"602 %s %s * * 0 :stopped watching",user->nick,q->target.c_str()); - } - if (n1 == n2) - { - watches.erase(q); - break; - } + if (a) + { + WriteServ(user->fd,"602 %s %s %s %s %lu :stopped watching",user->nick,a->nick,a->ident,a->dhost,a->age); + } + else + { + WriteServ(user->fd,"602 %s %s * * 0 :stopped watching",user->nick,q->target.c_str()); + } + if (n1 == n2) + { + watches.erase(q); + break; + } } } } @@ -170,15 +170,15 @@ class cmd_watch : public command_t watches.push_back(w); log(DEBUG,"*** Added %s to watchlist of %s",nick,user->nick); } - userrec* a = Srv->FindNick(nick); - if (a) - { - WriteServ(user->fd,"604 %s %s %s %s %lu :is online",user->nick,a->nick,a->ident,a->dhost,a->age); - } - else - { - WriteServ(user->fd,"605 %s %s * * 0 :is offline",user->nick,nick); - } + userrec* a = Srv->FindNick(nick); + if (a) + { + WriteServ(user->fd,"604 %s %s %s %s %lu :is online",user->nick,a->nick,a->ident,a->dhost,a->age); + } + else + { + WriteServ(user->fd,"605 %s %s * * 0 :is offline",user->nick,nick); + } } } } |