summaryrefslogtreecommitdiff
path: root/src/modules.c
diff options
context:
space:
mode:
authorrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2006-06-20 22:04:47 +0000
committerrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2006-06-20 22:04:47 +0000
commita6f7ffef9b6093ecae85317629a70e17d1730073 (patch)
treeb1865adfe5ff0fbb66a2034f4dc85dcf173a5279 /src/modules.c
parent3a14edd254f78fa977abc63569bc1ef151eac8d6 (diff)
Modules wont load invalid revisions - NOT FULLY COMPLETE YET (altho it works to some degree)
git-svn-id: svn://svn.anope.org/anope/trunk@1065 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@789 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/modules.c')
-rw-r--r--src/modules.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/modules.c b/src/modules.c
index f366ff23e..8e8882afa 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -523,6 +523,7 @@ int loadModule(Module * m, User * u)
int len;
const char *err;
int (*func) (int, char **);
+ int (*version)();
int ret = 0;
char *argv[1];
int argc = 0;
@@ -557,8 +558,6 @@ int loadModule(Module * m, User * u)
buf[4095] = '\0';
/* Don't skip return value checking! -GD */
if ((ret = moduleCopyFile(m->name, buf)) != MOD_ERR_OK) {
- if (u)
- notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
m->filename = sstrdup(buf);
return ret;
}
@@ -568,22 +567,25 @@ int loadModule(Module * m, User * u)
m->handle = ano_modopen(m->filename);
if ((err = ano_moderr()) != NULL) {
alog(err);
- if (u) {
- notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
- }
return MOD_ERR_NOLOAD;
}
ano_modclearerr();
func = (int (*)(int, char **))ano_modsym(m->handle, "AnopeInit");
if ((err = ano_moderr()) != NULL) {
ano_modclose(m->handle); /* If no AnopeInit - it isnt an Anope Module, close it */
- if (u) {
- notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
- }
-
return MOD_ERR_NOLOAD;
}
if (func) {
+ version = (int (*)())ano_modsym(m->handle,"getAnopeBuildVersion");
+ if(version && version() >= VERSION_BUILD ) {
+ alog("Module %s compiled against anope revision %d, this is %d",m->name,version(),VERSION_BUILD);
+ } else {
+ ano_modclose(m->handle);
+ ano_modclearerr();
+ alog("Module %s is compiled against an old version of anope!",m->name);
+ return MOD_ERR_NOLOAD;
+ }
+ /* TODO */
mod_current_module_name = m->name;
/* argv[0] is the user if there was one, or NULL if not */
if (u) {
@@ -602,9 +604,6 @@ int loadModule(Module * m, User * u)
ret = MOD_STOP;
}
if (ret == MOD_STOP) {
- if (u) {
- notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
- }
alog("%s requested unload...", m->name);
unloadModule(m, NULL);
mod_current_module_name = NULL;
@@ -623,10 +622,6 @@ int loadModule(Module * m, User * u)
return MOD_ERR_OK;
#else
- if (u) {
- notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name);
- }
-
return MOD_ERR_NOLOAD;
#endif
}
@@ -2706,8 +2701,12 @@ void handleModuleOperationQueue(void)
alog("Trying to load module [%s]", mod_operation_queue->m->name);
status = loadModule(mod_operation_queue->m, mod_operation_queue->u);
alog("Module loading status: %d", status);
- if (status != MOD_ERR_OK)
+ if (status != MOD_ERR_OK) {
+ if(mod_current_user) {
+ notice_lang(s_OperServ, mod_current_user, OPER_MODULE_LOAD_FAIL,mod_operation_queue->m->name);
+ }
destroyModule(mod_operation_queue->m);
+ }
} else if (mod_operation_queue->op == MOD_OP_UNLOAD) {
alog("Trying to unload module [%s]", mod_operation_queue->m->name);
status = unloadModule(mod_operation_queue->m, mod_operation_queue->u);