X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmodules.c;h=0de4505ea9df74c1474f0c7ce95298e0360d59fc;hb=8a1a716ef73af7b5288f7b5f8ab1b37be80f1247;hp=d024c3e186f3abb39bdf80534cf77aa3f16f2d8d;hpb=406c308308e4d131475a692cd425cb156e0776f1;p=NeonServV5.git diff --git a/src/modules.c b/src/modules.c index d024c3e..0de4505 100644 --- a/src/modules.c +++ b/src/modules.c @@ -1,4 +1,4 @@ -/* modules.c - NeonServ v5.4 +/* modules.c - NeonServ v5.6 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -45,6 +45,11 @@ /* 181-183 */ #include "WHOHandler.h" /* 184-188 */ #include "version.h" /* 189 */ /* modules.h */ +/* 190 */ /* UserNode.h */ +/* 191-193 */ #include "ModuleFunctions.h" +/* 194 */ /* bots.h */ +/* 195-196 */ /* version.h */ +/* 197-198 */ /* IRCEvents.h */ #define Function void * @@ -86,7 +91,7 @@ void *global_functions[] = { /* 030 */ (Function) create_socket, /* 031 */ (Function) connect_socket, /* 032 */ (Function) close_socket, -/* 033 */ (Function) disconnect_socket, +/* 033 */ (Function) destroy_socket, /* 034 */ (Function) write_socket, /* 035 */ (Function) putsock, /* 036 */ (Function) getBots, @@ -110,8 +115,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, @@ -183,7 +188,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, @@ -249,7 +254,16 @@ void *global_functions[] = { /* 186 */ (Function) get_revision, /* 187 */ (Function) get_codelines, /* 188 */ (Function) get_patchlevel, -/* 189 */ (Function) get_module_name +/* 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, +/* 195 */ (Function) is_stable_revision, +/* 196 */ (Function) get_dev_revision, +/* 197 */ (Function) bind_freeclient, +/* 198 */ (Function) unbind_freeclient }; static int module_id_counter = 1; @@ -259,6 +273,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; @@ -272,6 +287,7 @@ void loadModules() { } i++; } + free(modulelist); start_modules(); } @@ -298,7 +314,6 @@ struct ModuleInfo *loadModule(char *name) { } void* initfunc = dlsym(module, "init_module"); void* startfunc = dlsym(module, "start_module"); - void* loopfunc = dlsym(module, "loop_module"); void* stopfunc = dlsym(module, "stop_module"); void* modversion = dlsym(module, "modversion"); #else @@ -310,11 +325,10 @@ struct ModuleInfo *loadModule(char *name) { } FARPROC initfunc = GetProcAddress(module, "init_module"); FARPROC startfunc = GetProcAddress(module, "start_module"); - FARPROC loopfunc = GetProcAddress(module, "loop_module"); FARPROC stopfunc = GetProcAddress(module, "stop_module"); FARPROC modversion = GetProcAddress(module, "modversion"); #endif - if(!startfunc || !loopfunc || !stopfunc || !modversion) { + if(!startfunc || !stopfunc || !modversion) { putlog(LOGLEVEL_ERROR, "Error loading module '%s': required symbols not found.\n", name); return NULL; } @@ -339,11 +353,11 @@ struct ModuleInfo *loadModule(char *name) { modinfo->module_id = module_id; modinfo->module = module; modinfo->startfunc = startfunc; - modinfo->loopfunc = loopfunc; modinfo->stopfunc = stopfunc; modinfo->state = 0; modinfo->next = modules; modules = modinfo; + scan_module(modinfo); return modinfo; } @@ -384,6 +398,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; @@ -406,6 +421,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; @@ -438,13 +454,6 @@ void start_modules() { } } -void loop_modules() { - struct ModuleInfo *modinfo; - for(modinfo = modules; modinfo; modinfo = modinfo->next) { - ((void (*)(void)) modinfo->loopfunc)(); - } -} - void stop_modules() { struct ModuleInfo *modinfo, *next; for(modinfo = modules; modinfo; modinfo = next) { @@ -452,6 +461,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); } @@ -462,6 +472,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) { @@ -483,3 +494,5 @@ char *get_module_name(int module_id) { } return NULL; } + +