1
0
mirror of https://github.com/anope/anope.git synced 2026-07-08 11:23:13 +02:00

Remove unused moduleAddMessage/moduleDelMessage, move moduleCallBackRun() into ModuleManager::

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1695 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
rburchell
2008-11-15 15:45:27 +00:00
parent 2145e97d70
commit 73f4cccf99
6 changed files with 30 additions and 99 deletions
-1
View File
@@ -715,7 +715,6 @@ E int str_is_cidr(char *str, uint32 * ip, uint32 * mask, char **host);
/**** modules.c ****/
E void modules_unload_all(bool fini, bool unload_proto); /* Read warnings near function source */
E void moduleCallBackRun(void);
E void moduleCleanStruct(ModuleData **moduleData);
E void ModuleDatabaseBackup(const char *dbname);
E void ModuleRemoveBackups(const char *dbname);
+7 -8
View File
@@ -269,28 +269,29 @@ CoreExport class Module
CoreExport class ModuleManager
{
public:
/**
* Load up a list of modules.
/** Load up a list of modules.
* @param total_modules The number of modules to load
* @param module_list The list of modules to load
**/
static void LoadModuleList(int total_modules, char **module_list);
/**
* Loads a given module.
/** Loads a given module.
* @param m the module to load
* @param u the user who loaded it, NULL for auto-load
* @return MOD_ERR_OK on success, anything else on fail
*/
static int LoadModule(const std::string &modname, User * u);
/**
* Unload the given module.
/** Unload the given module.
* @param m the module to unload
* @param u the user who unloaded it
* @return MOD_ERR_OK on success, anything else on fail
*/
static int UnloadModule(Module *m, User * u);
/** Run all pending module timer callbacks.
*/
static void RunCallbacks();
};
@@ -421,9 +422,7 @@ MDE Message *createMessage(const char *name,int (*func)(const char *source, int
Message *findMessage(MessageHash *msgTable[], const char *name); /* Find a Message */
MDE int addMessage(MessageHash *msgTable[], Message *m, int pos); /* Add a Message to a Message table */
MDE int addCoreMessage(MessageHash *msgTable[], Message *m); /* Add a Message to a Message table */
MDE int moduleAddMessage(Message *m, int pos);
int delMessage(MessageHash *msgTable[], Message *m, const char *mod_name); /* Del a Message from a msg table */
MDE int moduleDelMessage(const char *name);
int destroyMessage(Message *m); /* destroy a Message*/
/*************************************************************************/
+2 -1
View File
@@ -30,6 +30,7 @@
#include "timeout.h"
#include "version.h"
#include "datafiles.h"
#include "modules.h"
/******** Global variables! ********/
@@ -540,7 +541,7 @@ int main(int ac, char **av, char **envp)
if (delayed_quit)
break;
moduleCallBackRun();
ModuleManager::RunCallbacks();
waiting = -1;
if (t - last_check >= TimeoutCheck) {
-11
View File
@@ -77,11 +77,9 @@ Module::~Module()
int idx;
CommandHash *current = NULL;
MessageHash *mcurrent = NULL;
EvtHookHash *ehcurrent = NULL;
Command *c;
Message *msg;
EvtHook *eHook;
int status = 0;
@@ -151,15 +149,6 @@ Module::~Module()
}
}
for (mcurrent = IRCD[idx]; mcurrent; mcurrent = mcurrent->next) {
for (msg = mcurrent->m; msg; msg = msg->next) {
if ((msg->mod_name)
&& (stricmp(msg->mod_name, this->name.c_str()) == 0)) {
moduleDelMessage(msg->name);
}
}
}
for (ehcurrent = EVENTHOOKS[idx]; ehcurrent;
ehcurrent = ehcurrent->next) {
for (eHook = ehcurrent->evh; eHook; eHook = eHook->next) {
-1
View File
@@ -248,4 +248,3 @@ int ModuleManager::UnloadModule(Module *m, User *u)
delete m;
return MOD_ERR_OK;
}
+21 -77
View File
@@ -294,7 +294,7 @@ int destroyCommand(Command * c)
* @param pos the position in the cmd call stack to add the command
* @return MOD_ERR_OK will be returned on success.
*/
static int internal_addCommand(CommandHash * cmdTable[], Command * c, int pos)
static int internal_addCommand(Module *m, CommandHash * cmdTable[], Command * c, int pos)
{
/* We can assume both param's have been checked by this point.. */
int index = 0;
@@ -307,9 +307,6 @@ static int internal_addCommand(CommandHash * cmdTable[], Command * c, int pos)
return MOD_ERR_PARAMS;
}
if (mod_current_module_name && !c->mod_name)
return MOD_ERR_NO_MOD_NAME;
index = CMD_HASH(c->name);
for (current = cmdTable[index]; current; current = current->next) {
@@ -416,7 +413,7 @@ int Module::AddCommand(CommandHash * cmdTable[], Command * c, int pos)
} else
c->service = sstrdup("Unknown");
status = internal_addCommand(cmdTable, c, pos);
status = internal_addCommand(this, cmdTable, c, pos);
if (status != MOD_ERR_OK)
{
alog("ERROR! [%d]", status);
@@ -676,59 +673,6 @@ int addCoreMessage(MessageHash * msgTable[], Message * m)
return addMessage(msgTable, m, 0);
}
/**
* Add a module message to the IRCD message hash
* @param m the Message to add
* @param pos the Position to add the message to, e.g. MOD_HEAD, MOD_TAIL, MOD_UNIQUE
* @return MOD_ERR_OK on success, althing else on fail.
**/
int moduleAddMessage(Message * m, int pos)
{
int status;
if (!m) {
return MOD_ERR_PARAMS;
}
/* ok, this appears to be a module adding a message from outside of AnopeInit, try to look up its module struct for it */
if ((mod_current_module_name) && (!mod_current_module)) {
mod_current_module = findModule(mod_current_module_name);
}
if (!mod_current_module) {
return MOD_ERR_UNKNOWN;
} /* shouldnt happen */
m->core = 0;
if (!m->mod_name) {
m->mod_name = sstrdup(mod_current_module->name.c_str());
}
status = addMessage(IRCD, m, pos);
return status;
}
/**
* remove the given message from the IRCD message hash
* @param name the name of the message to remove
* @return MOD_ERR_OK on success, althing else on fail.
**/
int moduleDelMessage(const char *name)
{
Message *m;
int status;
if (!mod_current_module) {
return MOD_ERR_UNKNOWN;
}
m = findMessage(IRCD, name);
if (!m) {
return MOD_ERR_NOEXIST;
}
status = delMessage(IRCD, m, mod_current_module->name.c_str());
return status;
}
/**
* remove the given message from the given message hash, for the given module
* @param msgTable which MessageHash we are removing from
@@ -886,25 +830,6 @@ int moduleAddCallback(const char *name, time_t when,
return MOD_ERR_OK;
}
/**
* Execute a stored call back
**/
void moduleCallBackRun(void)
{
ModuleCallBack *tmp;
while ((tmp = moduleCallBackHead) && (tmp->when <= time(NULL))) {
if (debug)
alog("debug: executing callback: %s", tmp->name ? tmp->name : "<unknown>");
if (tmp->func) {
mod_current_module_name = tmp->owner_name;
tmp->func(tmp->argc, tmp->argv);
mod_current_module = NULL;
moduleCallBackDeleteEntry(NULL);
}
}
}
/**
* Removes a entry from the modules callback list
* @param prev a pointer to the previous entry in the list, NULL for the head
@@ -1840,4 +1765,23 @@ void ModuleRunTimeDirCleanUp(void)
}
}
/**
* Execute a stored call back
**/
void ModuleManager::RunCallbacks()
{
ModuleCallBack *tmp;
while ((tmp = moduleCallBackHead) && (tmp->when <= time(NULL))) {
if (debug)
alog("debug: executing callback: %s", tmp->name ? tmp->name : "<unknown>");
if (tmp->func) {
mod_current_module_name = tmp->owner_name;
tmp->func(tmp->argc, tmp->argv);
mod_current_module = NULL;
moduleCallBackDeleteEntry(NULL);
}
}
}
/* EOF */