fixed some missing newlines (\n) in putlog lines
[NeonServV5.git] / src / modules.c
index d29e7a8018515653d5e7ed38b19919be46ee6017..adbe37df4a4cd16432e45ed90e636b67a9401b51 100644 (file)
@@ -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
@@ -15,7 +15,9 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
  */
 #include "modules.h"
+#ifndef WIN32
 #include <dlfcn.h>
+#endif
 
 /* 000-011 */ #include "main.h"
 /* 012     */ #include "BanNode.h"
@@ -263,7 +265,7 @@ 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++;
@@ -280,13 +282,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,6 +339,7 @@ struct ModuleInfo *loadModule(char *name) {
     modinfo->startfunc = startfunc;
     modinfo->loopfunc = loopfunc;
     modinfo->stopfunc = stopfunc;
+    modinfo->state = 0;
     modinfo->next = modules;
     modules = modinfo;
     return modinfo;