mirror of
https://github.com/anope/anope.git
synced 2026-07-06 06:13:13 +02:00
Always set mod_current_module and mod_current_module_name, fixes a few of the functions in modules.c relying on it.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/stable@2931 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
+4
-3
@@ -96,18 +96,18 @@ void do_run_cmd(char *service, User * u, Command * c, const char *cmd)
|
||||
}
|
||||
} else {
|
||||
mod_current_module_name = c->mod_name;
|
||||
mod_current_module = NULL;
|
||||
mod_current_module = findModule(c->mod_name);
|
||||
if ((c->has_priv == NULL) || c->has_priv(u)) {
|
||||
retVal = c->routine(u);
|
||||
mod_current_module_name = NULL;
|
||||
if (retVal == MOD_CONT) {
|
||||
current = c->next;
|
||||
while (current && retVal == MOD_CONT) {
|
||||
mod_current_module_name = current->mod_name;
|
||||
mod_current_module = NULL;
|
||||
mod_current_module = findModule(current->mod_name);
|
||||
if (current->routine)
|
||||
retVal = current->routine(u);
|
||||
mod_current_module_name = NULL;
|
||||
mod_current_module = NULL;
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
@@ -117,6 +117,7 @@ void do_run_cmd(char *service, User * u, Command * c, const char *cmd)
|
||||
u->nick, service, cmd);
|
||||
}
|
||||
mod_current_module_name = NULL;
|
||||
mod_current_module = NULL;
|
||||
}
|
||||
} else {
|
||||
if ((!checkDefCon(DEFCON_SILENT_OPER_ONLY)) || is_oper(u)) {
|
||||
|
||||
+10
-9
@@ -129,14 +129,18 @@ void event_message_process(char *eventbuf)
|
||||
if (evm) {
|
||||
if (evm->func) {
|
||||
mod_current_module_name = evm->mod_name;
|
||||
mod_current_module = findModule(evm->mod_name);
|
||||
retVal = evm->func(source, ac, av);
|
||||
mod_current_module_name = NULL;
|
||||
mod_current_module = NULL;
|
||||
if (retVal == MOD_CONT) {
|
||||
current = evm->next;
|
||||
while (current && current->func && retVal == MOD_CONT) {
|
||||
mod_current_module_name = current->mod_name;
|
||||
mod_current_module = findModule(current->mod_name);
|
||||
retVal = current->func(source, ac, av);
|
||||
mod_current_module_name = NULL;
|
||||
mod_current_module = NULL;
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
@@ -158,14 +162,18 @@ void event_process_hook(const char *name, int argc, char **argv)
|
||||
evh = find_eventhook(name);
|
||||
if (evh) {
|
||||
if (evh->func) {
|
||||
mod_current_module = findModule(evh->mod_name);
|
||||
mod_current_module_name = evh->mod_name;
|
||||
retVal = evh->func(argc, argv);
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
if (retVal == MOD_CONT) {
|
||||
current = evh->next;
|
||||
while (current && current->func && retVal == MOD_CONT) {
|
||||
mod_current_module = findModule(current->mod_name);
|
||||
mod_current_module_name = current->mod_name;
|
||||
retVal = current->func(argc, argv);
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
current = current->next;
|
||||
}
|
||||
@@ -495,14 +503,10 @@ int moduleAddEventHandler(EvtMessage * evm)
|
||||
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 */
|
||||
|
||||
evm->core = 0;
|
||||
if (!evm->mod_name) {
|
||||
evm->mod_name = sstrdup(mod_current_module->name);
|
||||
@@ -529,13 +533,10 @@ int moduleAddEventHook(EvtHook * evh)
|
||||
return MOD_ERR_PARAMS;
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
evh->core = 0;
|
||||
if (!evh->mod_name) {
|
||||
evh->mod_name = sstrdup(mod_current_module->name);
|
||||
|
||||
+31
-14
@@ -105,6 +105,7 @@ void modules_init(void)
|
||||
if (!m) {
|
||||
m = createModule(ModulesAutoload[idx]);
|
||||
mod_current_module = m;
|
||||
mod_current_module_name = m->name;
|
||||
mod_current_user = NULL;
|
||||
alog("trying to load [%s]", mod_current_module->name);
|
||||
ret = loadModule(mod_current_module, NULL);
|
||||
@@ -112,6 +113,7 @@ void modules_init(void)
|
||||
if (ret != MOD_ERR_OK)
|
||||
destroyModule(m);
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
mod_current_user = NULL;
|
||||
}
|
||||
}
|
||||
@@ -133,8 +135,11 @@ void modules_core_init(int number, char **list)
|
||||
if (!m) {
|
||||
m = createModule(list[idx]);
|
||||
mod_current_module = m;
|
||||
mod_current_module_name = m->name;
|
||||
mod_current_user = NULL;
|
||||
status = loadModule(mod_current_module, NULL);
|
||||
mod_current_module = m;
|
||||
mod_current_module_name = m->name;
|
||||
if (debug || status) {
|
||||
alog("debug: trying to load core module [%s]",
|
||||
mod_current_module->name);
|
||||
@@ -143,6 +148,7 @@ void modules_core_init(int number, char **list)
|
||||
destroyModule(mod_current_module);
|
||||
}
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
mod_current_user = NULL;
|
||||
}
|
||||
}
|
||||
@@ -156,12 +162,16 @@ int encryption_module_init(void) {
|
||||
|
||||
m = createModule(EncModule);
|
||||
mod_current_module = m;
|
||||
mod_current_module_name = m->name;
|
||||
mod_current_user = NULL;
|
||||
alog("Loading Encryption Module: [%s]", mod_current_module->name);
|
||||
ret = loadModule(mod_current_module, NULL);
|
||||
mod_current_module = m;
|
||||
mod_current_module_name = m->name;
|
||||
moduleSetType(ENCRYPTION);
|
||||
alog("status: [%d][%s]", ret, ModuleGetErrStr(ret));
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
if (ret != MOD_ERR_OK) {
|
||||
destroyModule(m);
|
||||
}
|
||||
@@ -178,12 +188,16 @@ int protocol_module_init(void)
|
||||
|
||||
m = createModule(IRCDModule);
|
||||
mod_current_module = m;
|
||||
mod_current_module_name = m->name;
|
||||
mod_current_user = NULL;
|
||||
alog("Loading IRCD Protocol Module: [%s]", mod_current_module->name);
|
||||
ret = loadModule(mod_current_module, NULL);
|
||||
mod_current_module = m;
|
||||
mod_current_module_name = m->name;
|
||||
moduleSetType(PROTOCOL);
|
||||
alog("status: [%d][%s]", ret, ModuleGetErrStr(ret));
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
|
||||
if (ret == MOD_ERR_OK) {
|
||||
/* This is really NOT the correct place to do config checks, but
|
||||
@@ -235,11 +249,13 @@ void modules_delayed_init(void)
|
||||
if (!m) {
|
||||
m = createModule(ModulesDelayedAutoload[idx]);
|
||||
mod_current_module = m;
|
||||
mod_current_module_name = m->name;
|
||||
mod_current_user = NULL;
|
||||
alog("trying to load [%s]", mod_current_module->name);
|
||||
ret = loadModule(mod_current_module, NULL);
|
||||
alog("status: [%d][%s]", ret, ModuleGetErrStr(ret));
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
mod_current_user = NULL;
|
||||
if (ret != MOD_ERR_OK)
|
||||
destroyModule(m);
|
||||
@@ -271,12 +287,11 @@ void modules_unload_all(boolean fini, boolean unload_proto)
|
||||
next = mh->next;
|
||||
if (unload_proto || (mh->m->type != PROTOCOL)) {
|
||||
mod_current_module = mh->m;
|
||||
mod_current_module_name = mh->m->name;
|
||||
if(fini) {
|
||||
func = (void (*)(void))ano_modsym(mh->m->handle, "AnopeFini");
|
||||
if (func) {
|
||||
mod_current_module_name = mh->m->name;
|
||||
func(); /* exec AnopeFini */
|
||||
mod_current_module_name = NULL;
|
||||
}
|
||||
|
||||
if (prepForUnload(mh->m) != MOD_ERR_OK) {
|
||||
@@ -291,6 +306,8 @@ void modules_unload_all(boolean fini, boolean unload_proto)
|
||||
} else {
|
||||
delModule(mh->m);
|
||||
}
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
}
|
||||
mh = next;
|
||||
}
|
||||
@@ -347,6 +364,7 @@ int destroyModule(Module * m)
|
||||
}
|
||||
|
||||
mod_current_module = m;
|
||||
mod_current_module_name = m->name;
|
||||
for (i = 0; i < NUM_LANGS; i++) {
|
||||
moduleDeleteLanguage(i);
|
||||
}
|
||||
@@ -368,6 +386,10 @@ int destroyModule(Module * m)
|
||||
|
||||
/* No need to free our cmd/msg list, as they will always be empty by the module is destroyed */
|
||||
free(m);
|
||||
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
|
||||
return MOD_ERR_OK;
|
||||
}
|
||||
|
||||
@@ -651,6 +673,7 @@ int loadModule(Module * m, User * u)
|
||||
return MOD_ERR_NOLOAD;
|
||||
}
|
||||
/* TODO */
|
||||
mod_current_module = m;
|
||||
mod_current_module_name = m->name;
|
||||
/* argv[0] is the user if there was one, or NULL if not */
|
||||
if (u) {
|
||||
@@ -674,10 +697,12 @@ int loadModule(Module * m, User * u)
|
||||
if (ret == MOD_STOP) {
|
||||
alog("%s requested unload...", m->name);
|
||||
unloadModule(m, NULL);
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
return MOD_ERR_NOLOAD;
|
||||
}
|
||||
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
}
|
||||
|
||||
@@ -726,8 +751,10 @@ int unloadModule(Module * m, User * u)
|
||||
|
||||
func = (void (*)(void))ano_modsym(m->handle, "AnopeFini");
|
||||
if (func) {
|
||||
mod_current_module = m;
|
||||
mod_current_module_name = m->name;
|
||||
func(); /* exec AnopeFini */
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
}
|
||||
|
||||
@@ -761,9 +788,6 @@ int unloadModule(Module * m, User * u)
|
||||
**/
|
||||
void moduleSetType(MODType type)
|
||||
{
|
||||
if ((mod_current_module_name) && (!mod_current_module)) {
|
||||
mod_current_module = findModule(mod_current_module_name);
|
||||
}
|
||||
mod_current_module->type = type;
|
||||
}
|
||||
|
||||
@@ -1018,10 +1042,6 @@ int moduleAddCommand(CommandHash * cmdTable[], Command * c, int pos)
|
||||
if (!cmdTable || !c) {
|
||||
return MOD_ERR_PARAMS;
|
||||
}
|
||||
/* ok, this appears to be a module adding a command 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;
|
||||
@@ -1542,11 +1562,6 @@ int moduleAddMessage(Message * m, int pos)
|
||||
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 */
|
||||
@@ -1777,9 +1792,11 @@ void moduleCallBackRun(void)
|
||||
if (debug)
|
||||
alog("debug: executing callback: %s", tmp->name ? tmp->name : "<unknown>");
|
||||
if (tmp->func) {
|
||||
mod_current_module = findModule(tmp->owner_name);
|
||||
mod_current_module_name = tmp->owner_name;
|
||||
tmp->func(tmp->argc, tmp->argv);
|
||||
mod_current_module = NULL;
|
||||
mod_current_module_name = NULL;
|
||||
moduleCallBackDeleteEntry(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,14 +395,18 @@ void process()
|
||||
if (m) {
|
||||
if (m->func) {
|
||||
mod_current_module_name = m->mod_name;
|
||||
mod_current_module = findModule(m->mod_name);
|
||||
retVal = m->func(source, ac, av);
|
||||
mod_current_module_name = NULL;
|
||||
mod_current_module = NULL;
|
||||
if (retVal == MOD_CONT) {
|
||||
current = m->next;
|
||||
while (current && current->func && retVal == MOD_CONT) {
|
||||
mod_current_module_name = current->mod_name;
|
||||
mod_current_module = findModule(current->mod_name);
|
||||
retVal = current->func(source, ac, av);
|
||||
mod_current_module_name = NULL;
|
||||
mod_current_module = NULL;
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -9,9 +9,10 @@ VERSION_MAJOR="1"
|
||||
VERSION_MINOR="8"
|
||||
VERSION_PATCH="4"
|
||||
VERSION_EXTRA="-svn"
|
||||
VERSION_BUILD="2930"
|
||||
VERSION_BUILD="2931"
|
||||
|
||||
# $Log$ # Changes since the 1.8.4 Release
|
||||
#Revision 2931 - Always set mod_current_module and mod_current_module_name, fixes a few of the functions in modules.c relying on it.
|
||||
#Revision 2930 - Print an error if the TS6 SID isn't set/is set incorrectly, most people don't know how to work logfiles
|
||||
#Revision 2929 - Added an internal event called when a nick is requested
|
||||
#Revision 2918 - Fixed deleting nick requests to only delete the requested nick
|
||||
|
||||
Reference in New Issue
Block a user