summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c3
-rw-r--r--src/module.cpp11
-rw-r--r--src/modulemanager.cpp1
-rw-r--r--src/modules.c98
4 files changed, 23 insertions, 90 deletions
diff --git a/src/main.c b/src/main.c
index dcbf8a303..ff4968ed3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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) {
diff --git a/src/module.cpp b/src/module.cpp
index f20404467..5676b16fb 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -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) {
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index edccd8dc5..c248817bc 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -248,4 +248,3 @@ int ModuleManager::UnloadModule(Module *m, User *u)
delete m;
return MOD_ERR_OK;
}
-
diff --git a/src/modules.c b/src/modules.c
index 79ef12420..e2e40a7c8 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -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);
@@ -677,59 +674,6 @@ int addCoreMessage(MessageHash * msgTable[], Message * m)
}
/**
- * 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
* @param m the Message we want to remove
@@ -887,25 +831,6 @@ int moduleAddCallback(const char *name, time_t when,
}
/**
- * 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 */