Anope IRC Services  Version 1.8
Functions | Variables
events.c File Reference
#include "modules.h"
#include "language.h"
#include "version.h"
Include dependency graph for events.c:

Go to the source code of this file.

Functions

EvtMessagefind_event (const char *name)
 
EvtHookfind_eventhook (const char *name)
 
void send_event (const char *name, int argc,...)
 
void eventprintf (char *fmt,...)
 
void event_message_process (char *eventbuf)
 
void event_process_hook (const char *name, int argc, char **argv)
 
int displayEventMessage (EvtMessage *evm)
 
int displayEventHook (EvtHook *evh)
 
int displayHookFromHash (char *name)
 
int displayEvtMessageFromHash (char *name)
 
EvtMessagecreateEventHandler (char *name, int(*func)(char *source, int ac, char **av))
 
EvtHookcreateEventHook (char *name, int(*func)(int argc, char **argv))
 
EvtMessagefindEventHandler (EvtMessageHash *msgEvtTable[], const char *name)
 
EvtHookfindEventHook (EvtHookHash *hookEvtTable[], const char *name)
 
int addCoreEventHandler (EvtMessageHash *msgEvtTable[], EvtMessage *evm)
 
int addEventHandler (EvtMessageHash *msgEvtTable[], EvtMessage *evm)
 
int addEventHook (EvtHookHash *hookEvtTable[], EvtHook *evh)
 
int addCoreEventHook (EvtHookHash *hookEvtTable[], EvtHook *evh)
 
int moduleAddEventHandler (EvtMessage *evm)
 
int moduleAddEventHook (EvtHook *evh)
 
int moduleEventDelHandler (char *name)
 
int moduleEventDelHook (const char *name)
 
int delEventHandler (EvtMessageHash *msgEvtTable[], EvtMessage *evm, char *mod_name)
 
int delEventHook (EvtHookHash *hookEvtTable[], EvtHook *evh, char *mod_name)
 
int destroyEventHandler (EvtMessage *evm)
 
int destroyEventHook (EvtHook *evh)
 

Variables

char * mod_current_evtbuffer = NULL
 
EvtMessageHashEVENT [MAX_CMD_HASH]
 
EvtHookHashEVENTHOOKS [MAX_CMD_HASH]
 

Function Documentation

int addCoreEventHandler ( EvtMessageHash msgEvtTable[],
EvtMessage evm 
)

Add the given message (m) to the MessageHash marking it as a core command

Parameters
msgTablethe MessageHash we want to add to
mthe Message we are adding
Returns
MOD_ERR_OK on a successful add.

Definition at line 376 of file events.c.

References addEventHandler(), EvtMessage_::core, and MOD_ERR_PARAMS.

int addCoreEventHook ( EvtHookHash hookEvtTable[],
EvtHook evh 
)

Add the given message (m) to the MessageHash marking it as a core command

Parameters
msgTablethe MessageHash we want to add to
mthe Message we are adding
Returns
MOD_ERR_OK on a successful add.

Definition at line 483 of file events.c.

References addEventHook(), EvtHook_::core, and MOD_ERR_PARAMS.

int addEventHandler ( EvtMessageHash msgEvtTable[],
EvtMessage evm 
)

Add a message to the MessageHash.

Parameters
msgTablethe MessageHash we want to add a message to
mthe Message we want to add
Returns
MOD_ERR_OK on a successful add.

Definition at line 391 of file events.c.

References alog(), CMD_HASH, current, debug, EvtMessageHash_::evm, fatal(), MOD_ERR_OK, MOD_ERR_PARAMS, EvtMessage_::name, EvtMessageHash_::name, EvtMessage_::next, EvtMessageHash_::next, sstrdup(), and stricmp().

Referenced by addCoreEventHandler(), and moduleAddEventHandler().

int addEventHook ( EvtHookHash hookEvtTable[],
EvtHook evh 
)

Add a message to the MessageHash.

Parameters
msgTablethe MessageHash we want to add a message to
mthe Message we want to add
Returns
MOD_ERR_OK on a successful add.

Definition at line 437 of file events.c.

References alog(), CMD_HASH, current, debug, EvtHookHash_::evh, fatal(), MOD_ERR_OK, MOD_ERR_PARAMS, EvtHook_::name, EvtHookHash_::name, EvtHook_::next, EvtHookHash_::next, sstrdup(), and stricmp().

Referenced by addCoreEventHook(), and moduleAddEventHook().

EvtMessage* createEventHandler ( char *  name,
int(*)(char *source, int ac, char **av)  func 
)

Create a new Message struct.

Parameters
namethe name of the message
funca pointer to the function to call when we recive this message
Returns
a new Message object

Definition at line 281 of file events.c.

References fatal(), EvtMessage_::func, EvtMessage_::mod_name, EvtMessage_::name, EvtMessage_::next, and sstrdup().

Referenced by AnopeInit().

EvtHook* createEventHook ( char *  name,
int(*)(int argc, char **argv)  func 
)

Create a new Message struct.

Parameters
namethe name of the message
funca pointer to the function to call when we recive this message
Returns
a new Message object

Definition at line 305 of file events.c.

References fatal(), EvtHook_::func, EvtHook_::mod_name, EvtHook_::name, EvtHook_::next, and sstrdup().

Referenced by AnopeInit().

int delEventHandler ( EvtMessageHash msgEvtTable[],
EvtMessage evm,
char *  mod_name 
)

remove the given message from the given message hash, for the given module

Parameters
msgTablewhich MessageHash we are removing from
mthe Message we want to remove the name of the module we are removing
Returns
MOD_ERR_OK on success, althing else on fail.

Definition at line 611 of file events.c.

References CMD_HASH, current, EvtMessageHash_::evm, MOD_ERR_NOEXIST, MOD_ERR_OK, MOD_ERR_PARAMS, EvtMessage_::mod_name, EvtMessage_::name, EvtMessageHash_::name, EvtMessage_::next, EvtMessageHash_::next, and stricmp().

Referenced by moduleEventDelHandler(), and prepForUnload().

int delEventHook ( EvtHookHash hookEvtTable[],
EvtHook evh,
char *  mod_name 
)

remove the given message from the given message hash, for the given module

Parameters
msgTablewhich MessageHash we are removing from
mthe Message we want to remove the name of the module we are removing
Returns
MOD_ERR_OK on success, althing else on fail.

Definition at line 686 of file events.c.

References CMD_HASH, current, EvtHookHash_::evh, MOD_ERR_NOEXIST, MOD_ERR_OK, MOD_ERR_PARAMS, EvtHook_::mod_name, EvtHook_::name, EvtHookHash_::name, EvtHook_::next, EvtHookHash_::next, and stricmp().

Referenced by moduleEventDelHook(), and prepForUnload().

int destroyEventHandler ( EvtMessage evm)

Destory a message, freeing its memory.

Parameters
mthe message to be destroyed
Returns
MOD_ERR_SUCCESS on success

Definition at line 759 of file events.c.

References EvtMessage_::func, MOD_ERR_OK, MOD_ERR_PARAMS, EvtMessage_::mod_name, EvtMessage_::name, and EvtMessage_::next.

Referenced by moduleEventDelHandler(), and prepForUnload().

int destroyEventHook ( EvtHook evh)

Destory a message, freeing its memory.

Parameters
mthe message to be destroyed
Returns
MOD_ERR_SUCCESS on success

Definition at line 781 of file events.c.

References EvtHook_::func, MOD_ERR_OK, MOD_ERR_PARAMS, EvtHook_::mod_name, EvtHook_::name, and EvtHook_::next.

Referenced by moduleEventDelHook(), and prepForUnload().

int displayEventHook ( EvtHook evh)

Displays a message list for a given message. Again this is of little use other than debugging.

Parameters
mthe message to display
Returns
0 is returned and has no meaning

Definition at line 209 of file events.c.

References alog(), EvtHook_::name, and EvtHook_::next.

Referenced by displayHookFromHash().

int displayEventMessage ( EvtMessage evm)

Displays a message list for a given message. Again this is of little use other than debugging.

Parameters
mthe message to display
Returns
0 is returned and has no meaning

Definition at line 191 of file events.c.

References alog(), EvtMessage_::name, and EvtMessage_::next.

Referenced by displayEvtMessageFromHash().

int displayEvtMessageFromHash ( char *  name)

Display the message call stak. Prints the call stack for a message based on the message name, again useful for debugging and little lese :)

Parameters
namethe name of the message to print info for
Returns
the return int has no relevence atm :)

Definition at line 252 of file events.c.

References alog(), CMD_HASH, current, debug, displayEventMessage(), EvtMessageHash_::evm, EvtMessageHash_::name, EvtMessageHash_::next, and stricmp().

Referenced by moduleAddEventHandler(), and moduleEventDelHandler().

int displayHookFromHash ( char *  name)

Display the message call stak. Prints the call stack for a message based on the message name, again useful for debugging and little lese :)

Parameters
namethe name of the message to print info for
Returns
the return int has no relevence atm :)

Definition at line 227 of file events.c.

References alog(), CMD_HASH, current, debug, displayEventHook(), EvtHookHash_::evh, EvtHookHash_::name, EvtHookHash_::next, and stricmp().

Referenced by moduleAddEventHook(), and moduleEventDelHook().

void event_message_process ( char *  eventbuf)
void event_process_hook ( const char *  name,
int  argc,
char **  argv 
)
void eventprintf ( char *  fmt,
  ... 
)

Definition at line 66 of file events.c.

References event_message_process(), sstrdup(), and vsnprintf().

Referenced by vsend_cmd().

EvtMessage* find_event ( const char *  name)

Definition at line 23 of file events.c.

References findEventHandler().

Referenced by event_message_process().

EvtHook* find_eventhook ( const char *  name)

Definition at line 30 of file events.c.

References findEventHook().

Referenced by event_process_hook().

EvtMessage* findEventHandler ( EvtMessageHash msgEvtTable[],
const char *  name 
)

find a message in the given table. Looks up the message <name> in the MessageHash given

Parameters
MessageHashthe message table to search for this command, will almost always be IRCD
namethe name of the command were looking for
Returns
NULL if we cant find it, or a pointer to the Message if we can

Definition at line 328 of file events.c.

References CMD_HASH, current, EvtMessageHash_::evm, EvtMessageHash_::name, EvtMessageHash_::next, and stricmp().

Referenced by find_event(), and moduleEventDelHandler().

EvtHook* findEventHook ( EvtHookHash hookEvtTable[],
const char *  name 
)

find a message in the given table. Looks up the message <name> in the MessageHash given

Parameters
MessageHashthe message table to search for this command, will almost always be IRCD
namethe name of the command were looking for
Returns
NULL if we cant find it, or a pointer to the Message if we can

Definition at line 353 of file events.c.

References CMD_HASH, current, EvtHookHash_::evh, EvtHookHash_::name, EvtHookHash_::next, and stricmp().

Referenced by find_eventhook(), and moduleEventDelHook().

int moduleAddEventHandler ( EvtMessage evm)

Add a module message to the IRCD message hash

Parameters
mthe Message to add
posthe Position to add the message to, e.g. MOD_HEAD, MOD_TAIL, MOD_UNIQUE
Returns
MOD_ERR_OK on success, althing else on fail.

Definition at line 498 of file events.c.

References addEventHandler(), EvtMessage_::core, debug, displayEvtMessageFromHash(), mod_current_module, MOD_ERR_PARAMS, MOD_ERR_UNKNOWN, EvtMessage_::mod_name, Module_::name, EvtMessage_::name, and sstrdup().

Referenced by AnopeInit().

int moduleAddEventHook ( EvtHook evh)

Add a module message to the IRCD message hash

Parameters
mthe Message to add
posthe Position to add the message to, e.g. MOD_HEAD, MOD_TAIL, MOD_UNIQUE
Returns
MOD_ERR_OK on success, althing else on fail.

Definition at line 528 of file events.c.

References addEventHook(), EvtHook_::core, debug, displayHookFromHash(), mod_current_module, MOD_ERR_PARAMS, MOD_ERR_UNKNOWN, EvtHook_::mod_name, Module_::name, EvtHook_::name, and sstrdup().

Referenced by AnopeInit().

int moduleEventDelHandler ( char *  name)

remove the given message from the IRCD message hash

Parameters
namethe name of the message to remove
Returns
MOD_ERR_OK on success, althing else on fail.

Definition at line 557 of file events.c.

References debug, delEventHandler(), destroyEventHandler(), displayEvtMessageFromHash(), findEventHandler(), mod_current_module, MOD_ERR_NOEXIST, MOD_ERR_UNKNOWN, Module_::name, and EvtMessage_::name.

int moduleEventDelHook ( const char *  name)

remove the given message from the IRCD message hash

Parameters
namethe name of the message to remove
Returns
MOD_ERR_OK on success, althing else on fail.

Definition at line 583 of file events.c.

References debug, delEventHook(), destroyEventHook(), displayHookFromHash(), findEventHook(), mod_current_module, MOD_ERR_NOEXIST, MOD_ERR_UNKNOWN, Module_::name, and EvtHook_::name.

void send_event ( const char *  name,
int  argc,
  ... 
)

Variable Documentation

Definition at line 20 of file events.c.

EvtHookHash* EVENTHOOKS[MAX_CMD_HASH]

Definition at line 21 of file events.c.

char* mod_current_evtbuffer = NULL

Definition at line 18 of file events.c.

Referenced by event_process_hook().