/**
* This #define allows us to call a method in all
* loaded modules in a readable simple way, e.g.:
- * 'FOREACH_MOD(I_OnConnect,OnConnect(user));'
+ * 'FOREACH_MOD(OnConnect,(user));'
*/
#define FOREACH_MOD(y,x) do { \
EventHandlerIter safei; \
- for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ) \
+ IntModuleList& _handlers = ServerInstance->Modules->EventHandlers[I_ ## y]; \
+ for (EventHandlerIter _i = _handlers.begin(); _i != _handlers.end(); ) \
{ \
safei = _i; \
++safei; \
try \
{ \
- (*_i)->x ; \
+ (*_i)->y x ; \
} \
catch (CoreException& modexcept) \
{ \
*/
#define DO_EACH_HOOK(n,v,args) \
do { \
- EventHandlerIter iter_ ## n = ServerInstance->Modules->EventHandlers[I_ ## n].begin(); \
- while (iter_ ## n != ServerInstance->Modules->EventHandlers[I_ ## n].end()) \
+ IntModuleList& _handlers = ServerInstance->Modules->EventHandlers[I_ ## n]; \
+ for (EventHandlerIter _i = _handlers.begin(); _i != _handlers.end(); ++_i) \
{ \
- Module* mod_ ## n = *iter_ ## n; \
- iter_ ## n ++; \
try \
{ \
- v = (mod_ ## n)->n args;
+ v = (*_i)->n args;
#define WHILE_EACH_HOOK(n) \
} \
catch (CoreException& except_ ## n) \
{ \
ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Exception caught: %s", (except_ ## n).GetReason()); \
- (void) mod_ ## n; /* catch mismatched pairs */ \
} \
} \
} while(0)
this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str());
this->topicset = ServerInstance->Time();
- FOREACH_MOD(I_OnPostTopicChange,OnPostTopicChange(u, this, this->topic));
+ FOREACH_MOD(OnPostTopicChange, (u, this, this->topic));
}
Membership* Channel::AddUser(User* user)
/* kill the record */
if (iter != ServerInstance->chanlist->end())
{
- FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
+ FOREACH_MOD(OnChannelDelete, (this));
ServerInstance->chanlist->erase(iter);
}
// Tell modules about this join, they have the chance now to populate except_list with users we won't send the JOIN (and possibly MODE) to
CUList except_list;
- FOREACH_MOD(I_OnUserJoin,OnUserJoin(memb, bursting, created_by_local, except_list));
+ FOREACH_MOD(OnUserJoin, (memb, bursting, created_by_local, except_list));
this->WriteAllExcept(user, false, 0, except_list, "JOIN :%s", this->name.c_str());
this->UserList(user);
}
- FOREACH_MOD(I_OnPostJoin,OnPostJoin(memb));
+ FOREACH_MOD(OnPostJoin, (memb));
}
bool Channel::IsBanned(User* user)
{
Membership* memb = membiter->second;
CUList except_list;
- FOREACH_MOD(I_OnUserPart,OnUserPart(memb, reason, except_list));
+ FOREACH_MOD(OnUserPart, (memb, reason, except_list));
WriteAllExcept(user, false, 0, except_list, "PART %s%s%s", this->name.c_str(), reason.empty() ? "" : " :", reason.c_str());
}
CUList except_list;
- FOREACH_MOD(I_OnUserKick,OnUserKick(src, memb, reason, except_list));
+ FOREACH_MOD(OnUserKick, (src, memb, reason, except_list));
WriteAllExcept(src, false, 0, except_list, "KICK %s %s :%s", name.c_str(), victim->nick.c_str(), reason.c_str());
prefixlist = this->GetPrefixChar(i->first);
nick = i->first->nick;
- FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->second, prefixlist, nick));
+ FOREACH_MOD(OnNamesListItem, (user, i->second, prefixlist, nick));
/* Nick was nuked, a module wants us to skip it */
if (nick.empty())
// Run the OnPostCommand hook with the last parameter (original line) being empty
// to indicate that the command had more targets in its original form.
item.clear();
- FOREACH_MOD(I_OnPostCommand, OnPostCommand(handler, new_parameters, localuser, result, item));
+ FOREACH_MOD(OnPostCommand, (handler, new_parameters, localuser, result, item));
}
}
}
*/
CmdResult result = handler->Handle(command_p, user);
- FOREACH_MOD(I_OnPostCommand, OnPostCommand(handler, command_p, user, result, cmd));
+ FOREACH_MOD(OnPostCommand, (handler, command_p, user, result, cmd));
}
}
int i=0;
while (lines[i])
user->SendText(":%s %03d %s :%s", ServerInstance->Config->ServerName.c_str(), RPL_INFO, user->nick.c_str(), lines[i++]);
- FOREACH_MOD(I_OnInfo,OnInfo(user));
+ FOREACH_MOD(OnInfo, (user));
user->SendText(":%s %03d %s :End of /INFO list", ServerInstance->Config->ServerName.c_str(), RPL_ENDOFINFO, user->nick.c_str());
return CMD_SUCCESS;
}
}
c->WriteAllExceptSender(user, true, prefix, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str());
}
- FOREACH_MOD(I_OnUserInvite,OnUserInvite(user,u,c,timeout));
+ FOREACH_MOD(OnUserInvite, (user,u,c,timeout));
}
else if (IS_LOCAL(user))
{
const char* text = temp.c_str();
const char* servermask = (parameters[0].c_str()) + 1;
- FOREACH_MOD(I_OnText,OnText(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list));
+ FOREACH_MOD(OnText, (user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list));
if (InspIRCd::Match(ServerInstance->Config->ServerName, servermask, NULL))
{
user->SendAll(MessageTypeString[mt], "%s", text);
}
- FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list, mt));
+ FOREACH_MOD(OnUserMessage, (user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list, mt));
return CMD_SUCCESS;
}
char status = 0;
return CMD_FAILURE;
}
- FOREACH_MOD(I_OnText,OnText(user,chan,TYPE_CHANNEL,text,status,except_list));
+ FOREACH_MOD(OnText, (user,chan,TYPE_CHANNEL,text,status,except_list));
if (status)
{
chan->WriteAllExcept(user, false, status, except_list, "%s %s :%s", MessageTypeString[mt], chan->name.c_str(), text);
}
- FOREACH_MOD(I_OnUserMessage, OnUserMessage(user,chan, TYPE_CHANNEL, text, status, except_list, mt));
+ FOREACH_MOD(OnUserMessage, (user,chan, TYPE_CHANNEL, text, status, except_list, mt));
}
else
{
const char* text = temp.c_str();
- FOREACH_MOD(I_OnText,OnText(user, dest, TYPE_USER, text, 0, except_list));
+ FOREACH_MOD(OnText, (user, dest, TYPE_USER, text, 0, except_list));
if (IS_LOCAL(dest))
{
user->WriteTo(dest, "%s %s :%s", MessageTypeString[mt], dest->nick.c_str(), text);
}
- FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, dest, TYPE_USER, text, 0, except_list, mt));
+ FOREACH_MOD(OnUserMessage, (user, dest, TYPE_USER, text, 0, except_list, mt));
}
else
{
{
std::string param = parameters.size() ? parameters[0] : "";
- FOREACH_MOD(I_OnPreRehash,OnPreRehash(user, param));
+ FOREACH_MOD(OnPreRehash, (user, param));
if (param.empty())
{
if (param[0] == '-')
param = param.substr(1);
- FOREACH_MOD(I_OnModuleRehash,OnModuleRehash(user, param));
+ FOREACH_MOD(OnModuleRehash, (user, param));
return CMD_SUCCESS;
}
/* Don't do anything with the logs here -- logs are restarted
* after the config thread has completed.
*/
- FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
+ FOREACH_MOD(OnGarbageCollect, ());
ServerInstance->ConfigThread = new ConfigReaderThread(user->uuid);
wholine.append(" :0 " + u->fullname);
- FOREACH_MOD(I_OnSendWhoLine, OnSendWhoLine(user, parms, u, wholine));
+ FOREACH_MOD(OnSendWhoLine, (user, parms, u, wholine));
if (!wholine.empty())
whoresults.push_back(wholine);
}
}
- FOREACH_MOD(I_OnWhois,OnWhois(user,dest));
+ FOREACH_MOD(OnWhois, (user,dest));
/*
* We only send these if we've been provided them. That is, if hidewhois is turned off, and user is local, or
static_cast<ListModeBase*>(*ban)->DoRehash();
Config->ApplyDisabledCommands(Config->DisabledCommands);
User* user = ServerInstance->FindNick(TheUserUID);
- FOREACH_MOD(I_OnRehash, OnRehash(user));
+ FOREACH_MOD(OnRehash, (user));
ServerInstance->ISupport.Build();
ServerInstance->Logs->CloseLogs();
{
std::string description;
- FOREACH_MOD(I_OnGetServerDescription,OnGetServerDescription(servername,description));
+ FOREACH_MOD(OnGetServerDescription, (servername,description));
if (!description.empty())
{
if ((TIME.tv_sec % 3600) == 0)
{
Users->GarbageCollect();
- FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
+ FOREACH_MOD(OnGarbageCollect, ());
}
Timers->TickTimers(TIME.tv_sec);
if ((TIME.tv_sec % 5) == 0)
{
- FOREACH_MOD(I_OnBackgroundTimer,OnBackgroundTimer(TIME.tv_sec));
+ FOREACH_MOD(OnBackgroundTimer, (TIME.tv_sec));
SNO->FlushSnotices();
}
}
else
targetuser->WriteFrom(user, "MODE " + LastParse);
- FOREACH_MOD(I_OnMode,OnMode(user, targetuser, targetchannel, LastParseParams, LastParseTranslate));
+ FOREACH_MOD(OnMode, (user, targetuser, targetchannel, LastParseParams, LastParseTranslate));
}
else if (targetchannel && parameters.size() == 2)
{
if (defer)
return true;
- FOREACH_MOD(I_OnLoadModule,OnLoadModule(newmod));
+ FOREACH_MOD(OnLoadModule, (newmod));
/* We give every module a chance to re-prioritize when we introduce a new one,
* not just the one thats loading, as the new module could affect the preference
* of others
ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Unable to load " + name + ": " + modexcept.GetReason());
return false;
}
- FOREACH_MOD(I_OnLoadModule,OnLoadModule(mod));
+ FOREACH_MOD(OnLoadModule, (mod));
/* We give every module a chance to re-prioritize when we introduce a new one,
* not just the one thats loading, as the new module could affect the preference
* of others
void Event::Send()
{
- FOREACH_MOD(I_OnEvent,OnEvent(*this));
+ FOREACH_MOD(OnEvent, (*this));
}
// These declarations define the behavours of the base class Module (which does nothing at all)
// First, notify all modules that a module is about to be unloaded, so in case
// they pass execution to the soon to be unloaded module, it will happen now,
// i.e. before we unregister the services of the module being unloaded
- FOREACH_MOD(I_OnUnloadModule,OnUnloadModule(mod));
+ FOREACH_MOD(OnUnloadModule, (mod));
std::map<std::string, Module*>::iterator modfind = Modules.find(mod->ModuleSourceFile);
banlm->DoSyncChannel(targchan, creator, user);
// Show other listmodes as well
- FOREACH_MOD(I_OnSyncChannel,OnSyncChannel(targchan,creator,user));
+ FOREACH_MOD(OnSyncChannel, (targchan,creator,user));
dumpExt(user, checkstr, targchan);
}
else
{
InternalState = HTTP_SERVE_WAIT_REQUEST;
- FOREACH_MOD(I_OnHookIO, OnHookIO(this, via));
+ FOREACH_MOD(OnHookIO, (this, via));
if (GetIOHook())
GetIOHook()->OnStreamSocketAccept(this, client, server);
}
UserChanList chans(user->chans);
std::map<User*, bool> exceptions;
- FOREACH_MOD(I_OnBuildNeighborList, OnBuildNeighborList(user, chans, exceptions));
+ FOREACH_MOD(OnBuildNeighborList, (user, chans, exceptions));
// Send it to all local users who were explicitly marked as neighbours by modules and have the required ext
for (std::map<User*, bool>::const_iterator i = exceptions.begin(); i != exceptions.end(); ++i)
{
chan_hash::iterator at = iter;
iter++;
- FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(c));
+ FOREACH_MOD(OnChannelDelete, (c));
ServerInstance->chanlist->erase(at);
ServerInstance->GlobalCulls.AddItem(c);
}
return true;
if (params.size())
{
- FOREACH_MOD(I_OnSetAway, OnSetAway(u, params[params.size() - 1]));
+ FOREACH_MOD(OnSetAway, (u, params[params.size() - 1]));
if (params.size() > 1)
u->awaytime = ConvToInt(params[0]);
}
else
{
- FOREACH_MOD(I_OnSetAway, OnSetAway(u, ""));
+ FOREACH_MOD(OnSetAway, (u, ""));
u->awaymsg.clear();
}
Utils->DoOneToAllButSender(prefix,"AWAY",params,u->server);
if (params[0] == "*")
{
std::string value = params.size() < 3 ? "" : params[2];
- FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(NULL,params[1],value));
+ FOREACH_MOD(OnDecodeMetaData, (NULL,params[1],value));
return CMD_SUCCESS;
}
ExtensionItem* item = ServerInstance->Extensions.GetItem(params[2]);
if (item)
item->unserialize(FORMAT_NETWORK, c, value);
- FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(c,params[2],value));
+ FOREACH_MOD(OnDecodeMetaData, (c,params[2],value));
}
else
{
if (item)
item->unserialize(FORMAT_NETWORK, u, value);
- FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(u,params[1],value));
+ FOREACH_MOD(OnDecodeMetaData, (u,params[1],value));
}
}
SyncChannel(i->second);
this->SendXLines();
- FOREACH_MOD(I_OnSyncNetwork,OnSyncNetwork(Utils->Creator,(void*)this));
+ FOREACH_MOD(OnSyncNetwork, (Utils->Creator,(void*)this));
this->WriteLine(":" + ServerInstance->Config->GetSID() + " ENDBURST");
ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+ s->GetName()+"\2.");
}
Utils->Creator->ProtoSendMetaData(this, chan, item->name, value);
}
- FOREACH_MOD(I_OnSyncChannel,OnSyncChannel(chan, Utils->Creator, this));
+ FOREACH_MOD(OnSyncChannel, (chan, Utils->Creator, this));
}
/** send all users and their oper state/modes */
Utils->Creator->ProtoSendMetaData(this, u->second, item->name, value);
}
- FOREACH_MOD(I_OnSyncUser,OnSyncUser(u->second,Utils->Creator,this));
+ FOREACH_MOD(OnSyncUser, (u->second,Utils->Creator,this));
}
}
}
capab = new CapabData;
capab->capab_phase = 0;
- FOREACH_MOD(I_OnHookIO, OnHookIO(this, via));
+ FOREACH_MOD(OnHookIO, (this, via));
if (GetIOHook())
GetIOHook()->OnStreamSocketAccept(this, client, server);
SendCapabilities(1);
if (dosend)
ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s (%s) [%s]", _new->server.c_str(), _new->GetFullRealHost().c_str(), _new->GetIPString().c_str(), _new->fullname.c_str());
- FOREACH_MOD(I_OnPostConnect,OnPostConnect(_new));
+ FOREACH_MOD(OnPostConnect, (_new));
return CMD_SUCCESS;
}
void RehashHandler::Call(const std::string &reason)
{
ServerInstance->SNO->WriteToSnoMask('a', "Rehashing config file %s %s",ServerConfig::CleanFilename(ServerInstance->ConfigFileName.c_str()), reason.c_str());
- FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
+ FOREACH_MOD(OnGarbageCollect, ());
if (!ServerInstance->ConfigThread)
{
ServerInstance->ConfigThread = new ConfigReaderThread("");
tokens["WALLCHOPS"] = tokens["WALLVOICES"];
// Modules can add new tokens and also edit or remove existing tokens
- FOREACH_MOD(I_On005Numeric, On005Numeric(tokens));
+ FOREACH_MOD(On005Numeric, (tokens));
// EXTBAN is a special case as we need to sort it and prepend a comma.
std::map<std::string, std::string>::iterator extban = tokens.find("EXTBAN");
std::string desc = GetDescription(LastLetter);
std::string msg = "(last message repeated " + ConvToStr(Count) + " times)";
- FOREACH_MOD(I_OnSendSnotice, OnSendSnotice(LastLetter, desc, msg));
+ FOREACH_MOD(OnSendSnotice, (LastLetter, desc, msg));
Snomask::Send(LastLetter, desc, msg);
}
switch (choice)
{
case '1':
- FOREACH_MOD(I_OnRunTestSuite, OnRunTestSuite());
+ FOREACH_MOD(OnRunTestSuite, ());
break;
case '2':
std::cout << "Enter module filename to load: ";
UserIOHandler* eh = &New->eh;
/* Give each of the modules an attempt to hook the user for I/O */
- FOREACH_MOD(I_OnHookIO, OnHookIO(eh, via));
+ FOREACH_MOD(OnHookIO, (eh, via));
if (eh->GetIOHook())
{
if (ServerInstance->Config->RawLog)
New->WriteNotice("*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.");
- FOREACH_MOD(I_OnSetUserIP,OnSetUserIP(New));
+ FOREACH_MOD(OnSetUserIP, (New));
if (New->quitting)
return;
- FOREACH_MOD(I_OnUserInit,OnUserInit(New));
+ FOREACH_MOD(OnUserInit, (New));
}
void UserManager::QuitUser(User *user, const std::string &quitreason, const char* operreason)
if (user->registered == REG_ALL)
{
- FOREACH_MOD(I_OnUserQuit,OnUserQuit(user, reason, oper_reason));
+ FOREACH_MOD(OnUserQuit, (user, reason, oper_reason));
user->WriteCommonQuit(reason, oper_reason);
}
if (IS_LOCAL(user))
{
LocalUser* lu = IS_LOCAL(user);
- FOREACH_MOD(I_OnUserDisconnect,OnUserDisconnect(lu));
+ FOREACH_MOD(OnUserDisconnect, (lu));
lu->eh.Close();
}
this->SetMode(opermh, true);
this->oper = info;
this->WriteServ("MODE %s :+o", this->nick.c_str());
- FOREACH_MOD(I_OnOper, OnOper(this, info->name));
+ FOREACH_MOD(OnOper, (this, info->name));
std::string opername;
if (info->oper_block)
if (IS_LOCAL(this))
oper->init();
- FOREACH_MOD(I_OnPostOper,OnPostOper(this, oper->name, opername));
+ FOREACH_MOD(OnPostOper, (this, oper->name, opername));
}
void OperInfo::init()
* We don't set REG_ALL until triggering OnUserConnect, so some module events don't spew out stuff
* for a user that doesn't exist yet.
*/
- FOREACH_MOD(I_OnUserConnect,OnUserConnect(this));
+ FOREACH_MOD(OnUserConnect, (this));
this->registered = REG_ALL;
- FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
+ FOREACH_MOD(OnPostConnect, (this));
ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d (class %s): %s (%s) [%s]",
this->GetServerPort(), this->MyClass->name.c_str(), GetFullRealHost().c_str(), this->GetIPString().c_str(), this->fullname.c_str());
(*(ServerInstance->Users->clientlist))[newnick] = this;
if (registered == REG_ALL)
- FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(this,oldnick));
+ FOREACH_MOD(OnUserPostNick, (this,oldnick));
return true;
}
if (recheck_eline)
this->exempt = (ServerInstance->XLines->MatchesLine("E", this) != NULL);
- FOREACH_MOD(I_OnSetUserIP,OnSetUserIP(this));
+ FOREACH_MOD(OnSetUserIP, (this));
}
}
exceptions[this] = include_self;
- FOREACH_MOD(I_OnBuildNeighborList,OnBuildNeighborList(this, include_c, exceptions));
+ FOREACH_MOD(OnBuildNeighborList, (this, include_c, exceptions));
for (std::map<User*,bool>::iterator i = exceptions.begin(); i != exceptions.end(); ++i)
{
UserChanList include_c(chans);
std::map<User*,bool> exceptions;
- FOREACH_MOD(I_OnBuildNeighborList,OnBuildNeighborList(this, include_c, exceptions));
+ FOREACH_MOD(OnBuildNeighborList, (this, include_c, exceptions));
for (std::map<User*,bool>::iterator i = exceptions.begin(); i != exceptions.end(); ++i)
{
FIRST_MOD_RESULT(OnChangeLocalUserGECOS, MOD_RESULT, (IS_LOCAL(this),gecos));
if (MOD_RESULT == MOD_RES_DENY)
return false;
- FOREACH_MOD(I_OnChangeName,OnChangeName(this,gecos));
+ FOREACH_MOD(OnChangeName, (this,gecos));
}
this->fullname.assign(gecos, 0, ServerInstance->Config->Limits.MaxGecos);
UserChanList include_c(chans);
std::map<User*,bool> exceptions;
- FOREACH_MOD(I_OnBuildNeighborList,OnBuildNeighborList(this, include_c, exceptions));
+ FOREACH_MOD(OnBuildNeighborList, (this, include_c, exceptions));
for (std::map<User*,bool>::iterator i = exceptions.begin(); i != exceptions.end(); ++i)
{
return false;
}
- FOREACH_MOD(I_OnChangeHost, OnChangeHost(this,shost));
+ FOREACH_MOD(OnChangeHost, (this,shost));
std::string quitstr = ":" + GetFullHost() + " QUIT :Changing host";
if (this->ident == newident)
return true;
- FOREACH_MOD(I_OnChangeIdent, OnChangeIdent(this,newident));
+ FOREACH_MOD(OnChangeIdent, (this,newident));
std::string quitstr = ":" + GetFullHost() + " QUIT :Changing ident";
lookup_lines[line->type][line->Displayable().c_str()] = line;
line->OnAdd();
- FOREACH_MOD(I_OnAddLine,OnAddLine(user, line));
+ FOREACH_MOD(OnAddLine, (user, line));
return true;
}
ServerInstance->BanCache->RemoveEntries(y->second->type, true);
- FOREACH_MOD(I_OnDelLine,OnDelLine(user, y->second));
+ FOREACH_MOD(OnDelLine, (user, y->second));
y->second->Unset();
// removes lines that have expired
void XLineManager::ExpireLine(ContainerIter container, LookupIter item)
{
- FOREACH_MOD(I_OnExpireLine, OnExpireLine(item->second));
+ FOREACH_MOD(OnExpireLine, (item->second));
item->second->DisplayExpiry();
item->second->Unset();