diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/os_modinfo.c | 20 | ||||
-rw-r--r-- | src/modules.c | 66 | ||||
-rw-r--r-- | src/modules/cs_tban.c | 6 | ||||
-rw-r--r-- | src/process.c | 4 |
4 files changed, 22 insertions, 74 deletions
diff --git a/src/core/os_modinfo.c b/src/core/os_modinfo.c index 485ba89bb..93100c3f1 100644 --- a/src/core/os_modinfo.c +++ b/src/core/os_modinfo.c @@ -17,7 +17,6 @@ int do_modinfo(User * u); void myOperServHelp(User * u); -int showModuleMsgLoaded(MessageHash * msgList, const char *mod_name, User * u); int showModuleCmdLoaded(CommandHash * cmdList, const char *mod_name, User * u); class OSModInfo : public Module @@ -81,8 +80,6 @@ int do_modinfo(User * u) showModuleCmdLoaded(BOTSERV[idx], m->name.c_str(), u); showModuleCmdLoaded(MEMOSERV[idx], m->name.c_str(), u); showModuleCmdLoaded(HELPSERV[idx], m->name.c_str(), u); - showModuleMsgLoaded(IRCD[idx], m->name.c_str(), u); - } } else { notice_lang(s_OperServ, u, OPER_MODULE_NO_INFO, file); @@ -108,21 +105,4 @@ int showModuleCmdLoaded(CommandHash * cmdList, const char *mod_name, User * u) return display; } -int showModuleMsgLoaded(MessageHash * msgList, const char *mod_name, User * u) -{ - Message *msg; - MessageHash *mcurrent; - int display = 0; - for (mcurrent = msgList; mcurrent; mcurrent = mcurrent->next) { - for (msg = mcurrent->m; msg; msg = msg->next) { - if ((msg->mod_name) && (stricmp(msg->mod_name, mod_name) == 0)) { - notice_lang(s_OperServ, u, OPER_MODULE_MSG_LIST, - msg->name); - display++; - } - } - } - return display; -} - MODULE_INIT("os_modinfo", OSModInfo) diff --git a/src/modules.c b/src/modules.c index e2e40a7c8..ceebe1660 100644 --- a/src/modules.c +++ b/src/modules.c @@ -565,7 +565,6 @@ Message *createMessage(const char *name, } m->name = sstrdup(name); m->func = func; - m->mod_name = NULL; m->next = NULL; return m; } @@ -677,10 +676,9 @@ int addCoreMessage(MessageHash * msgTable[], Message * m) * 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 - * @mod_name the name of the module we are removing * @return MOD_ERR_OK on success, althing else on fail. **/ -int delMessage(MessageHash * msgTable[], Message * m, const char *mod_name) +int delMessage(MessageHash * msgTable[], Message * m) { int index = 0; MessageHash *current = NULL; @@ -699,15 +697,12 @@ int delMessage(MessageHash * msgTable[], Message * m, const char *mod_name) tail = current->m; if (tail->next) { while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->m = tail->next; - } - return MOD_ERR_OK; + if (last) { + last->next = tail->next; + } else { + current->m = tail->next; } + return MOD_ERR_OK; last = tail; tail = tail->next; } @@ -720,15 +715,12 @@ int delMessage(MessageHash * msgTable[], Message * m, const char *mod_name) tail = current->m; if (tail->next) { while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->m = tail->next; - } - return MOD_ERR_OK; + if (last) { + last->next = tail->next; + } else { + current->m = tail->next; } + return MOD_ERR_OK; last = tail; tail = tail->next; } @@ -758,9 +750,6 @@ int destroyMessage(Message * m) free(m->name); } m->func = NULL; - if (m->mod_name) { - free(m->mod_name); - } m->next = NULL; return MOD_ERR_OK; } @@ -768,18 +757,8 @@ int destroyMessage(Message * m) /******************************************************************************* * Module Callback Functions *******************************************************************************/ - /** - * Adds a timed callback for the current module. - * This allows modules to request that anope executes one of there functions at a time in the future, without an event to trigger it - * @param name the name of the callback, this is used for refrence mostly, but is needed it you want to delete this particular callback later on - * @param when when should the function be executed, this is a time in the future, seconds since 00:00:00 1970-01-01 UTC - * @param func the function to be executed when the callback is ran, its format MUST be int func(int argc, char **argv); - * @param argc the argument count for the argv paramter - * @param atgv a argument list to be passed to the called function. - * @return MOD_ERR_OK on success, anything else on fail. - * @see moduleDelCallBack - **/ -int moduleAddCallback(const char *name, time_t when, + +int Module::AddCallback(const char *name, time_t when, int (*func) (int argc, char *argv[]), int argc, char **argv) { @@ -794,11 +773,7 @@ int moduleAddCallback(const char *name, time_t when, else newcb->name = NULL; newcb->when = when; - if (mod_current_module_name) { - newcb->owner_name = sstrdup(mod_current_module_name); - } else { - newcb->owner_name = NULL; - } + newcb->owner_name = sstrdup(this->name.c_str()); newcb->func = func; newcb->argc = argc; newcb->argv = (char **)malloc(sizeof(char *) * argc); @@ -886,29 +861,22 @@ static ModuleCallBack *moduleCallBackFindEntry(const char *mod_name, bool * foun } } -/** - * Allow module coders to delete a callback by name. - * @param name the name of the callback they wish to delete - **/ -void moduleDelCallback(char *name) +void Module::DelCallback(const char *name) { ModuleCallBack *current = NULL; ModuleCallBack *prev = NULL, *tmp = NULL; int del = 0; - if (!mod_current_module_name) { - return; - } if (!name) { return; } current = moduleCallBackHead; while (current) { if ((current->owner_name) && (current->name)) { - if ((strcmp(mod_current_module_name, current->owner_name) == 0) + if ((strcmp(this->name.c_str(), current->owner_name) == 0) && (strcmp(current->name, name) == 0)) { if (debug) { alog("debug: removing CallBack %s for module %s", name, - mod_current_module_name); + this->name.c_str()); } tmp = current->next; /* get a pointer to the next record, as once we delete this record, we'll lose it :) */ moduleCallBackDeleteEntry(prev); /* delete this record */ diff --git a/src/modules/cs_tban.c b/src/modules/cs_tban.c index 6045c7a98..871b610ff 100644 --- a/src/modules/cs_tban.c +++ b/src/modules/cs_tban.c @@ -33,6 +33,8 @@ int canBanUser(Channel * c, User * u, User * u2); void mAddLanguages(void); +static Module *me = NULL; + #define LANG_NUM_STRINGS 4 #define TBAN_HELP 0 #define TBAN_SYNTAX 1 @@ -46,6 +48,8 @@ class CSTBan : public Module { Command *c; + me = this; + moduleSetChanHelp(myHelp); c = createCommand("TBAN", do_tban, NULL, -1, -1, -1, -1, -1); moduleAddHelp(c, myFullHelp); @@ -194,7 +198,7 @@ void addBan(Channel * c, time_t timeout, char *banmask) ircdproto->SendMode(whosends(c->ci), c->name, "+b %s", av[1]); chan_set_modes(s_ChanServ, c, 2, av, 1); - moduleAddCallback("tban", time(NULL) + timeout, delBan, 2, cb); + me->AddCallback("tban", time(NULL) + timeout, delBan, 2, cb); } int delBan(int argc, char **argv) diff --git a/src/process.c b/src/process.c index 54a4dc1e8..253fd31b7 100644 --- a/src/process.c +++ b/src/process.c @@ -409,15 +409,11 @@ void process() m = find_message(cmd); if (m) { if (m->func) { - mod_current_module_name = m->mod_name; retVal = m->func(source, ac, av); - mod_current_module_name = NULL; if (retVal == MOD_CONT) { current = m->next; while (current && current->func && retVal == MOD_CONT) { - mod_current_module_name = current->mod_name; retVal = current->func(source, ac, av); - mod_current_module_name = NULL; current = current->next; } } |