Anope IRC Services  Version 2.0
Data Structures | Macros | Typedefs | Enumerations
modules.h File Reference
#include "serialize.h"
#include "base.h"
#include "modes.h"
#include "timers.h"
#include "logger.h"
#include "extensible.h"
Include dependency graph for modules.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  ModuleVersion
 
class  NotImplementedException
 
class  Module
 
class  ModuleManager
 

Macros

#define MODULE_INIT(x)
 
#define FOREACH_MOD(ename, args)
 
#define FOREACH_RESULT(ename, ret, args)
 

Typedefs

typedef unsigned short ModType
 

Enumerations

enum  EventReturn { EVENT_STOP, EVENT_CONTINUE, EVENT_ALLOW }
 
enum  ModuleReturn {
  MOD_ERR_OK, MOD_ERR_PARAMS, MOD_ERR_EXISTS, MOD_ERR_NOEXIST,
  MOD_ERR_NOLOAD, MOD_ERR_UNKNOWN, MOD_ERR_FILE_IO, MOD_ERR_EXCEPTION,
  MOD_ERR_VERSION
}
 
enum  Priority {
  PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE,
  PRIORITY_AFTER
}
 
enum  {
  MT_BEGIN, THIRD = 1 << 0, VENDOR = 1 << 1, EXTRA = 1 << 2,
  DATABASE = 1 << 3, ENCRYPTION = 1 << 4, PSEUDOCLIENT = 1 << 5, PROTOCOL = 1 << 6,
  MT_END = 1 << 7
}
 
enum  Implementation {
  I_OnPreUserKicked, I_OnUserKicked, I_OnReload, I_OnPreBotAssign,
  I_OnBotAssign, I_OnBotUnAssign, I_OnUserConnect, I_OnNewServer,
  I_OnUserNickChange, I_OnPreHelp, I_OnPostHelp, I_OnPreCommand,
  I_OnPostCommand, I_OnSaveDatabase, I_OnLoadDatabase, I_OnEncrypt,
  I_OnDecrypt, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan,
  I_OnBadWordAdd, I_OnBadWordDel, I_OnCreateBot, I_OnDelBot,
  I_OnBotKick, I_OnPrePartChannel, I_OnPartChannel, I_OnLeaveChannel,
  I_OnJoinChannel, I_OnTopicUpdated, I_OnPreChanExpire, I_OnChanExpire,
  I_OnPreServerConnect, I_OnServerConnect, I_OnPreUplinkSync, I_OnServerDisconnect,
  I_OnRestart, I_OnShutdown, I_OnPreNickExpire, I_OnNickExpire,
  I_OnDefconLevel, I_OnExceptionAdd, I_OnExceptionDel, I_OnAddXLine,
  I_OnDelXLine, I_IsServicesOper, I_OnServerQuit, I_OnUserQuit,
  I_OnPreUserLogoff, I_OnPostUserLogoff, I_OnBotCreate, I_OnBotChange,
  I_OnBotDelete, I_OnAccessDel, I_OnAccessAdd, I_OnAccessClear,
  I_OnLevelChange, I_OnChanDrop, I_OnChanRegistered, I_OnChanSuspend,
  I_OnChanUnsuspend, I_OnCreateChan, I_OnDelChan, I_OnChannelCreate,
  I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick,
  I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv, I_OnNickDrop,
  I_OnNickGroup, I_OnNickIdentify, I_OnUserLogin, I_OnNickLogout,
  I_OnNickRegister, I_OnNickSuspend, I_OnNickUnsuspended, I_OnDelNick,
  I_OnNickCoreCreate, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickClearAccess,
  I_OnNickAddAccess, I_OnNickEraseAccess, I_OnNickClearCert, I_OnNickAddCert,
  I_OnNickEraseCert, I_OnNickInfo, I_OnBotInfo, I_OnCheckAuthentication,
  I_OnNickUpdate, I_OnFingerprint, I_OnUserAway, I_OnInvite,
  I_OnDeleteVhost, I_OnSetVhost, I_OnSetDisplayedHost, I_OnMemoSend,
  I_OnMemoDel, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet,
  I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd, I_OnMLock,
  I_OnUnMLock, I_OnModuleLoad, I_OnModuleUnload, I_OnServerSync,
  I_OnUplinkSync, I_OnBotPrivmsg, I_OnBotNotice, I_OnPrivmsg,
  I_OnLog, I_OnLogMessage, I_OnDnsRequest, I_OnCheckModes,
  I_OnChannelSync, I_OnSetCorrectModes, I_OnSerializeCheck, I_OnSerializableConstruct,
  I_OnSerializableDestruct, I_OnSerializableUpdate, I_OnSerializeTypeCreate, I_OnSetChannelOption,
  I_OnSetNickOption, I_OnMessage, I_OnCanSet, I_OnCheckDelete,
  I_OnExpireTick, I_OnNickValidate, I_SIZE
}
 

Macro Definition Documentation

#define FOREACH_MOD (   ename,
  args 
)
Value:
if (true) \
{ \
std::vector<Module *> &_modules = ModuleManager::EventHandlers[I_ ## ename]; \
for (std::vector<Module *>::iterator _i = _modules.begin(); _i != _modules.end();) \
{ \
try \
{ \
(*_i)->ename args; \
} \
catch (const ModuleException &modexcept) \
{ \
Log() << "Exception caught: " << modexcept.GetReason(); \
} \
catch (const NotImplementedException &) \
{ \
_i = _modules.erase(_i); \
continue; \
} \
++_i; \
} \
} \
else \
static_cast<void>(0)
static std::vector< Module * > EventHandlers[I_SIZE]
Definition: modules.h:1114

This #define allows us to call a method in all loaded modules in a readable simple way, e.g.:

FOREACH_MOD(OnUserConnect, (user, exempt));

Definition at line 62 of file modules.h.

Referenced by NickCore::AddAccess(), BadWordsImpl::AddBadWord(), NSCertListImpl::AddCert(), ModeManager::AddChannelMode(), ModeManager::AddUserMode(), BotInfo::Assign(), BotInfo::BotInfo(), User::ChangeNick(), Channel::ChangeTopic(), Channel::ChangeTopicInternal(), Channel::Channel(), ChannelInfo::ChannelInfo(), BSKick::check_ban(), Channel::CheckModes(), NickCore::ClearAccess(), NSCertListImpl::ClearCert(), Configuration::Conf::Conf(), Uplink::Connect(), Server::Delete(), Channel::DeleteUser(), CommandCSAKick::DoAdd(), CommandBSBot::DoAdd(), CommandCSAccess::DoAdd(), CommandCSXOP::DoAdd(), CommandBSBot::DoChange(), MyXMLRPCEvent::DoCheckAuthentication(), CommandCSFlags::DoClear(), CommandOSAKill::DoClear(), CommandCSXOP::DoClear(), CommandCSAccess::DoClear(), ExceptionDelCallback::DoDel(), CommandCSAKick::DoDel(), CommandOSAKill::DoDel(), CommandBSBot::DoDel(), CommandCSXOP::DoDel(), CommandCSAccess::DoDel(), CommandCSLevels::DoDisable(), CommandCSFlags::DoModify(), CommandCSLevels::DoReset(), CommandCSLevels::DoSet(), NickCore::EraseAccess(), BadWordsImpl::EraseBadWord(), NSCertListImpl::EraseCert(), CommandMSCancel::Execute(), CommandNSDrop::Execute(), CommandCSRegister::Execute(), CommandNSUpdate::Execute(), CommandHSDel::Execute(), CommandHSSet::Execute(), CommandCSClone::Execute(), CommandCSInfo::Execute(), CommandNSInfo::Execute(), CommandNSLogout::Execute(), CommandHelp::Execute(), CommandMSDel::Execute(), CommandBSInfo::Execute(), CommandCSSuspend::Execute(), CommandHSDelAll::Execute(), CommandNSSuspend::Execute(), CommandNSIdentify::Execute(), CommandNSGroup::Execute(), CommandNSRegister::Execute(), CommandHSSetAll::Execute(), CommandNSRecover::Execute(), CommandCSUnSuspend::Execute(), CommandNSUnSuspend::Execute(), CommandOSDefcon::Execute(), CommandHSActivate::Execute(), MemoDelCallback::HandleNumber(), MyManager::HandlePacket(), User::Identify(), BotInfo::Join(), Channel::KickInternal(), ModuleManager::LoadModule(), User::Login(), main(), NickCore::NickCore(), CommandOSSXLineBase::OnClear(), UplinkSocket::OnConnect(), CommandOSSXLineBase::OnDel(), NickServCore::OnDelCore(), ChanServCore::OnExpireTick(), NickServCore::OnExpireTick(), Fantasy::OnPrivmsg(), WebCPanel::Index::OnRequest(), SQLAuthenticationResult::OnResult(), IdentifyInterface::OnResult(), NSGroupRequest::OnSuccess(), BotInfo::Part(), Plain::ProcessMessage(), DHBS::ProcessMessage(), DHAES::ProcessMessage(), LogInfo::ProcessMessage(), Serializable::QueueUpdate(), User::Quit(), User::RemoveModeInternal(), Message::Away::Run(), Message::Invite::Run(), Message::Join::Run(), Message::Notice::Run(), Message::Part::Run(), Message::Privmsg::Run(), IRCDMessageEncap::Run(), Command::Run(), IRCDMessageCertFP::Run(), IRCDMessageMetadata::Run(), Anope::SaveDatabases(), MemoServCore::Send(), Serializable::Serializable(), Server::Server(), Channel::SetCorrectModes(), NickCore::SetDisplay(), User::SetDisplayedHost(), User::SetModeInternal(), Message::Join::SJoin(), CommandHSGroup::Sync(), Channel::Sync(), Server::Sync(), ExpireTimer::Tick(), DefConTimeout::Tick(), ModuleManager::UnloadModule(), User::User(), BotInfo::~BotInfo(), Channel::~Channel(), ChannelInfo::~ChannelInfo(), Log::~Log(), NickAlias::~NickAlias(), NickCore::~NickCore(), Serializable::~Serializable(), UplinkSocket::~UplinkSocket(), and User::~User().

#define FOREACH_RESULT (   ename,
  ret,
  args 
)
Value:
if (true) \
{ \
ret = EVENT_CONTINUE; \
std::vector<Module *> &_modules = ModuleManager::EventHandlers[I_ ## ename]; \
for (std::vector<Module *>::iterator _i = _modules.begin(); _i != _modules.end();) \
{ \
try \
{ \
EventReturn res = (*_i)->ename args; \
if (res != EVENT_CONTINUE) \
{ \
ret = res; \
break; \
} \
} \
catch (const ModuleException &modexcept) \
{ \
Log() << "Exception caught: " << modexcept.GetReason(); \
} \
catch (const NotImplementedException &) \
{ \
_i = _modules.erase(_i); \
continue; \
} \
++_i; \
} \
} \
else \
static_cast<void>(0)
static std::vector< Module * > EventHandlers[I_SIZE]
Definition: modules.h:1114
EventReturn
Definition: modules.h:129

This define is similar to the one above but returns a result. The first module to return a result other than EVENT_CONTINUE is the value to be accepted, and any modules after are ignored. This is used like:

EventReturn MOD_RESULT; FOREACH_RESULT(OnUserConnect, MOD_RESULT, (user, exempt));

Definition at line 95 of file modules.h.

Referenced by BotInfo::Assign(), ChannelMode::CanSet(), Channel::CheckDelete(), Channel::CheckKick(), Anope::Decrypt(), CommandOSAKill::DoAdd(), CommandOSException::DoAdd(), Anope::Encrypt(), CommandCSSetChanstats::Execute(), CommandCSDrop::Execute(), CommandCSSetKeepTopic::Execute(), CommandHelp::Execute(), CommandCSSetAutoOp::Execute(), CommandCSSetMisc::Execute(), CommandCSSetBanType::Execute(), CommandCSSetPrivate::Execute(), CommandCSSetDescription::Execute(), CommandCSSetFounder::Execute(), CommandCSSetKeepModes::Execute(), CommandCSSetPeace::Execute(), CommandCSSetPersist::Execute(), CommandCSSetRestricted::Execute(), CommandCSSetSecure::Execute(), CommandCSSetSecureFounder::Execute(), CommandCSSetSecureOps::Execute(), CommandCSSetSignKick::Execute(), CommandCSSetSuccessor::Execute(), AccessGroup::HasPriv(), HasPriv(), Anope::Init(), User::IsServicesOper(), Channel::Kick(), CommandCSTopic::Lock(), CommandOSSNLine::OnAdd(), CommandOSSQLine::OnAdd(), Fantasy::OnPrivmsg(), Anope::Process(), ModeLocksImpl::RemoveMLock(), Channel::RemoveModeInternal(), CommandNSSetChanstats::Run(), CommandNSSetGreet::Run(), CommandNSSetMisc::Run(), Message::Privmsg::Run(), CommandNSSetHide::Run(), Command::Run(), CommandNSSetPrivate::Run(), CommandNSSetAutoOp::Run(), CommandNSSetDisplay::Run(), CommandNSSetEmail::Run(), CommandNSSetKeepModes::Run(), CommandNSSetKill::Run(), CommandNSSetLanguage::Run(), CommandNSSetMessage::Run(), CommandNSSetSecure::Run(), ModeLocksImpl::SetMLock(), Channel::SetModeInternal(), BotInfo::UnAssign(), CommandCSTopic::Unlock(), and NickServCore::Validate().

#define MODULE_INIT (   x)
Value:
extern "C" DllExport Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
{ \
return new x(modname, creator); \
} \
extern "C" DllExport void AnopeFini(x *m) \
{ \
delete m; \
}
#define DllExport
Definition: services.h:61

This definition is used as shorthand for the various classes and functions needed to make a module loadable by the OS. It defines the class factory and external AnopeInit and AnopeFini functions.

Definition at line 45 of file modules.h.

Referenced by GnuTLS::X509CertCredentials::cert_callback().

Typedef Documentation

typedef unsigned short ModType

Definition at line 174 of file modules.h.

Enumeration Type Documentation

anonymous enum
Enumerator
MT_BEGIN 
THIRD 
VENDOR 
EXTRA 
DATABASE 
ENCRYPTION 
PSEUDOCLIENT 
PROTOCOL 
MT_END 

Definition at line 153 of file modules.h.

Possible return types from events.

Enumerator
EVENT_STOP 
EVENT_CONTINUE 
EVENT_ALLOW 

Definition at line 129 of file modules.h.

Enumerator
I_OnPreUserKicked 
I_OnUserKicked 
I_OnReload 
I_OnPreBotAssign 
I_OnBotAssign 
I_OnBotUnAssign 
I_OnUserConnect 
I_OnNewServer 
I_OnUserNickChange 
I_OnPreHelp 
I_OnPostHelp 
I_OnPreCommand 
I_OnPostCommand 
I_OnSaveDatabase 
I_OnLoadDatabase 
I_OnEncrypt 
I_OnDecrypt 
I_OnBotFantasy 
I_OnBotNoFantasyAccess 
I_OnBotBan 
I_OnBadWordAdd 
I_OnBadWordDel 
I_OnCreateBot 
I_OnDelBot 
I_OnBotKick 
I_OnPrePartChannel 
I_OnPartChannel 
I_OnLeaveChannel 
I_OnJoinChannel 
I_OnTopicUpdated 
I_OnPreChanExpire 
I_OnChanExpire 
I_OnPreServerConnect 
I_OnServerConnect 
I_OnPreUplinkSync 
I_OnServerDisconnect 
I_OnRestart 
I_OnShutdown 
I_OnPreNickExpire 
I_OnNickExpire 
I_OnDefconLevel 
I_OnExceptionAdd 
I_OnExceptionDel 
I_OnAddXLine 
I_OnDelXLine 
I_IsServicesOper 
I_OnServerQuit 
I_OnUserQuit 
I_OnPreUserLogoff 
I_OnPostUserLogoff 
I_OnBotCreate 
I_OnBotChange 
I_OnBotDelete 
I_OnAccessDel 
I_OnAccessAdd 
I_OnAccessClear 
I_OnLevelChange 
I_OnChanDrop 
I_OnChanRegistered 
I_OnChanSuspend 
I_OnChanUnsuspend 
I_OnCreateChan 
I_OnDelChan 
I_OnChannelCreate 
I_OnChannelDelete 
I_OnAkickAdd 
I_OnAkickDel 
I_OnCheckKick 
I_OnChanInfo 
I_OnCheckPriv 
I_OnGroupCheckPriv 
I_OnNickDrop 
I_OnNickGroup 
I_OnNickIdentify 
I_OnUserLogin 
I_OnNickLogout 
I_OnNickRegister 
I_OnNickSuspend 
I_OnNickUnsuspended 
I_OnDelNick 
I_OnNickCoreCreate 
I_OnDelCore 
I_OnChangeCoreDisplay 
I_OnNickClearAccess 
I_OnNickAddAccess 
I_OnNickEraseAccess 
I_OnNickClearCert 
I_OnNickAddCert 
I_OnNickEraseCert 
I_OnNickInfo 
I_OnBotInfo 
I_OnCheckAuthentication 
I_OnNickUpdate 
I_OnFingerprint 
I_OnUserAway 
I_OnInvite 
I_OnDeleteVhost 
I_OnSetVhost 
I_OnSetDisplayedHost 
I_OnMemoSend 
I_OnMemoDel 
I_OnChannelModeSet 
I_OnChannelModeUnset 
I_OnUserModeSet 
I_OnUserModeUnset 
I_OnChannelModeAdd 
I_OnUserModeAdd 
I_OnMLock 
I_OnUnMLock 
I_OnModuleLoad 
I_OnModuleUnload 
I_OnServerSync 
I_OnUplinkSync 
I_OnBotPrivmsg 
I_OnBotNotice 
I_OnPrivmsg 
I_OnLog 
I_OnLogMessage 
I_OnDnsRequest 
I_OnCheckModes 
I_OnChannelSync 
I_OnSetCorrectModes 
I_OnSerializeCheck 
I_OnSerializableConstruct 
I_OnSerializableDestruct 
I_OnSerializableUpdate 
I_OnSerializeTypeCreate 
I_OnSetChannelOption 
I_OnSetNickOption 
I_OnMessage 
I_OnCanSet 
I_OnCheckDelete 
I_OnExpireTick 
I_OnNickValidate 
I_SIZE 

Definition at line 1081 of file modules.h.

Enumerator
MOD_ERR_OK 
MOD_ERR_PARAMS 
MOD_ERR_EXISTS 
MOD_ERR_NOEXIST 
MOD_ERR_NOLOAD 
MOD_ERR_UNKNOWN 
MOD_ERR_FILE_IO 
MOD_ERR_EXCEPTION 
MOD_ERR_VERSION 

Definition at line 136 of file modules.h.

enum Priority

Priority types which can be returned from Module::Prioritize()

Enumerator
PRIORITY_FIRST 
PRIORITY_DONTCARE 
PRIORITY_LAST 
PRIORITY_BEFORE 
PRIORITY_AFTER 

Definition at line 151 of file modules.h.