projects
/
NeonServV5.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added OPER support (let the bots try to op themselves)
[NeonServV5.git]
/
src
/
modules.c
diff --git
a/src/modules.c
b/src/modules.c
index d29e7a8018515653d5e7ed38b19919be46ee6017..4372c48433d1bec7140922c977e862a754acffce 100644
(file)
--- a/
src/modules.c
+++ b/
src/modules.c
@@
-1,4
+1,4
@@
-/* modules.c - NeonServ v5.
3
+/* modules.c - NeonServ v5.
4
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
* 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 <http://www.gnu.org/licenses/>.
*/
#include "modules.h"
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "modules.h"
+#ifndef WIN32
#include <dlfcn.h>
#include <dlfcn.h>
+#endif
/* 000-011 */ #include "main.h"
/* 012 */ #include "BanNode.h"
/* 000-011 */ #include "main.h"
/* 012 */ #include "BanNode.h"
@@
-42,6
+44,8
@@
/* 170-180 */ #include "UserNode.h"
/* 181-183 */ #include "WHOHandler.h"
/* 184-188 */ #include "version.h"
/* 170-180 */ #include "UserNode.h"
/* 181-183 */ #include "WHOHandler.h"
/* 184-188 */ #include "version.h"
+/* 189 */ /* modules.h */
+/* 190 */ /* UserNode.h */
#define Function void *
#define Function void *
@@
-245,7
+249,9
@@
void *global_functions[] = {
/* 185 */ (Function) get_creation,
/* 186 */ (Function) get_revision,
/* 187 */ (Function) get_codelines,
/* 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
};
static int module_id_counter = 1;
};
static int module_id_counter = 1;
@@
-255,6
+261,7
@@
static void unregister_module_hooks(int module_id);
void loadModules() {
char **modulelist = get_all_fieldnames("modules");
void loadModules() {
char **modulelist = get_all_fieldnames("modules");
+ if(!modulelist) return;
int i = 0;
char tmp[MAXLEN];
struct ModuleInfo *modinfo;
int i = 0;
char tmp[MAXLEN];
struct ModuleInfo *modinfo;
@@
-263,11
+270,12
@@
void loadModules() {
if(get_int_field(tmp)) {
modinfo = loadModule(modulelist[i]);
sprintf(tmp, "modules.%s.protected", modulelist[i]);
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++;
}
modinfo->state |= MODINFO_STATE_PROTECTED;
}
i++;
}
+ free(modulelist);
start_modules();
}
start_modules();
}
@@
-280,13
+288,17
@@
struct ModuleInfo *loadModule(char *name) {
#ifndef WIN32
sprintf(fname, "%s.so", name);
void* module = dlopen(fname, RTLD_LAZY);
#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) {
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");
}
void* initfunc = dlsym(module, "init_module");
void* startfunc = dlsym(module, "start_module");
@@
-333,6
+345,7
@@
struct ModuleInfo *loadModule(char *name) {
modinfo->startfunc = startfunc;
modinfo->loopfunc = loopfunc;
modinfo->stopfunc = stopfunc;
modinfo->startfunc = startfunc;
modinfo->loopfunc = loopfunc;
modinfo->stopfunc = stopfunc;
+ modinfo->state = 0;
modinfo->next = modules;
modules = modinfo;
return modinfo;
modinfo->next = modules;
modules = modinfo;
return modinfo;
@@
-464,3
+477,13
@@
int module_loaded(int module_id) {
}
return 0;
}
}
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;
+}