1 /* ModuleFunctions.c - NeonServ v5.4
2 * Copyright (C) 2011-2012 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "ModuleFunctions.h"
24 #define FUNCTION_GLOBAL_CMD_REGISTER_NEONBACKUP 0
25 #define FUNCTION_GLOBAL_CMD_UNREGISTER_NEONBACKUP 1
26 #define FUNCTION_NEONBACKUP_RECOVER_CHAN 2
28 #define TOTAL_FUNCTIONS 3
30 struct module_function {
31 struct ModuleInfo *module;
35 static struct module_function module_functions[TOTAL_FUNCTIONS];
37 void init_modulefunctions() {
39 for(i = 0; i < TOTAL_FUNCTIONS; i++) {
40 module_functions[i].function = NULL;
44 void scan_module(struct ModuleInfo *module) {
45 char *function_names[] = {
46 "global_cmd_register_neonbackup", /* FUNCTION_GLOBAL_CMD_REGISTER_NEONBACKUP */
47 "global_cmd_unregister_neonbackup", /* FUNCTION_GLOBAL_CMD_UNREGISTER_NEONBACKUP */
48 "neonbackup_recover_chan" /* FUNCTION_NEONBACKUP_RECOVER_CHAN */
51 for(i = 0; i < TOTAL_FUNCTIONS; i++) {
53 void* func = dlsym(module->module, function_names[i]);
55 FARPROC func = GetProcAddress(module->module, function_names[i]);
58 module_functions[i].module = module;
59 module_functions[i].function = func;
64 void free_module_functions(struct ModuleInfo *module) {
66 for(i = 0; i < TOTAL_FUNCTIONS; i++) {
67 if(module_functions[i].module == module) {
68 module_functions[i].function = NULL;
73 /* function handlers */
74 void module_global_cmd_register_neonbackup(char *chan) {
75 if(!module_functions[FUNCTION_GLOBAL_CMD_REGISTER_NEONBACKUP].function)
77 ((void (*)(char *)) module_functions[FUNCTION_GLOBAL_CMD_REGISTER_NEONBACKUP].function)(chan);
80 void module_global_cmd_unregister_neonbackup(char *chan) {
81 if(!module_functions[FUNCTION_GLOBAL_CMD_UNREGISTER_NEONBACKUP].function)
83 ((void (*)(char *)) module_functions[FUNCTION_GLOBAL_CMD_UNREGISTER_NEONBACKUP].function)(chan);
86 void module_neonbackup_recover_chan(struct ChanNode *chan) {
87 if(!module_functions[FUNCTION_NEONBACKUP_RECOVER_CHAN].function)
89 ((void (*)(struct ChanNode *)) module_functions[FUNCTION_NEONBACKUP_RECOVER_CHAN].function)(chan);