X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmodules.c;h=2b722dbb029c19cd5c8846e3b65cfc4153b0991a;hb=57e7d4b1753480c4d93b79e8fa4c57f1b5a71dbd;hp=d29e7a8018515653d5e7ed38b19919be46ee6017;hpb=8b89857bfaca58d04c19b31a73f1d7d8575940db;p=NeonServV5.git
diff --git a/src/modules.c b/src/modules.c
index d29e7a8..2b722db 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -1,4 +1,4 @@
-/* modules.c - NeonServ v5.3
+/* modules.c - NeonServ v5.5
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
@@ -15,7 +15,9 @@
* along with this program. If not, see .
*/
#include "modules.h"
+#ifndef WIN32
#include
+#endif
/* 000-011 */ #include "main.h"
/* 012 */ #include "BanNode.h"
@@ -42,6 +44,10 @@
/* 170-180 */ #include "UserNode.h"
/* 181-183 */ #include "WHOHandler.h"
/* 184-188 */ #include "version.h"
+/* 189 */ /* modules.h */
+/* 190 */ /* UserNode.h */
+/* 191-193 */ #include "ModuleFunctions.h"
+/* 194 */ /* bots.h */
#define Function void *
@@ -107,8 +113,8 @@ void *global_functions[] = {
/* 054 */ (Function) unbind_nick,
/* 055 */ (Function) bind_part,
/* 056 */ (Function) unbind_part,
-/* 057 */ (Function) bind_quit,
-/* 058 */ (Function) unbind_quit,
+/* 057 */ (Function) bind_reload,
+/* 058 */ (Function) unbind_reload,
/* 059 */ (Function) bind_kick,
/* 060 */ (Function) unbind_kick,
/* 061 */ (Function) bind_topic,
@@ -180,7 +186,7 @@ void *global_functions[] = {
/* 120 */ (Function) find_botwise_cmd_binding,
/* 121 */ (Function) bind_botwise_unbound_required_functions,
/* 122 */ (Function) find_cmd_function,
-/* 123 */ (Function) getTextBot,
+/* 123 */ (Function) NULL, /* deprecated */
/* 124 */ (Function) register_command_alias,
/* 125 */ (Function) getAllBinds,
/* 126 */ (Function) createModeNode,
@@ -245,7 +251,13 @@ void *global_functions[] = {
/* 185 */ (Function) get_creation,
/* 186 */ (Function) get_revision,
/* 187 */ (Function) get_codelines,
-/* 188 */ (Function) get_patchlevel
+/* 188 */ (Function) get_patchlevel,
+/* 189 */ (Function) get_module_name,
+/* 190 */ (Function) isUserModeSet,
+/* 191 */ (Function) module_global_cmd_register_neonbackup,
+/* 192 */ (Function) module_global_cmd_unregister_neonbackup,
+/* 193 */ (Function) module_neonbackup_recover_chan,
+/* 194 */ (Function) requestInvite
};
static int module_id_counter = 1;
@@ -255,6 +267,7 @@ static void unregister_module_hooks(int module_id);
void loadModules() {
char **modulelist = get_all_fieldnames("modules");
+ if(!modulelist) return;
int i = 0;
char tmp[MAXLEN];
struct ModuleInfo *modinfo;
@@ -263,11 +276,12 @@ void loadModules() {
if(get_int_field(tmp)) {
modinfo = loadModule(modulelist[i]);
sprintf(tmp, "modules.%s.protected", modulelist[i]);
- if(!get_int_field(tmp))
+ if(get_int_field(tmp))
modinfo->state |= MODINFO_STATE_PROTECTED;
}
i++;
}
+ free(modulelist);
start_modules();
}
@@ -280,13 +294,17 @@ struct ModuleInfo *loadModule(char *name) {
#ifndef WIN32
sprintf(fname, "%s.so", name);
void* module = dlopen(fname, RTLD_LAZY);
+ if(!module) {
+ sprintf(fname, "./%s.so", name);
+ module = dlopen(fname, RTLD_LAZY);
+ }
if(!module) {
sprintf(fname, ".libs/%s.so", name);
module = dlopen(fname, RTLD_LAZY);
- if(!module) {
- putlog(LOGLEVEL_ERROR, "Error loading module '%s': %s not found.\n", name, fname);
- return NULL;
- }
+ }
+ if(!module) {
+ putlog(LOGLEVEL_ERROR, "Error loading module '%s': %s not found.\n", name, fname);
+ return NULL;
}
void* initfunc = dlsym(module, "init_module");
void* startfunc = dlsym(module, "start_module");
@@ -333,8 +351,10 @@ struct ModuleInfo *loadModule(char *name) {
modinfo->startfunc = startfunc;
modinfo->loopfunc = loopfunc;
modinfo->stopfunc = stopfunc;
+ modinfo->state = 0;
modinfo->next = modules;
modules = modinfo;
+ scan_module(modinfo);
return modinfo;
}
@@ -375,6 +395,7 @@ int ext_unload_module(char *name) {
unregister_module_hooks(old_modinfo->module_id);
((void (*)(int)) old_modinfo->stopfunc)(MODSTATE_STARTSTOP);
closemodule(old_modinfo->module);
+ free_module_functions(old_modinfo);
free(old_modinfo->name);
free(old_modinfo);
return 1;
@@ -397,6 +418,7 @@ int ext_reload_module(char *name) {
unregister_module_hooks(old_modinfo->module_id);
((void (*)(int)) old_modinfo->stopfunc)(MODSTATE_RELOAD);
closemodule(old_modinfo->module);
+ free_module_functions(old_modinfo);
free(old_modinfo->name);
free(old_modinfo);
break;
@@ -443,6 +465,7 @@ void stop_modules() {
unregister_module_hooks(modinfo->module_id);
((void (*)(int)) modinfo->stopfunc)(MODSTATE_STARTSTOP);
closemodule(modinfo->module);
+ free_module_functions(modinfo);
free(modinfo->name);
free(modinfo);
}
@@ -453,6 +476,7 @@ static void unregister_module_hooks(int module_id) {
unregister_module_commands(module_id);
unregister_module_events(module_id);
unregister_module_timers(module_id);
+
}
int module_loaded(int module_id) {
@@ -464,3 +488,15 @@ int module_loaded(int module_id) {
}
return 0;
}
+
+char *get_module_name(int module_id) {
+ if(!module_id) return NULL;
+ struct ModuleInfo *modinfo;
+ for(modinfo = modules; modinfo; modinfo = modinfo->next) {
+ if(modinfo->module_id == module_id)
+ return modinfo->name;
+ }
+ return NULL;
+}
+
+