load_modules supports nsapi module init functions

Wed, 31 Jul 2013 13:02:06 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 31 Jul 2013 13:02:06 +0200
changeset 90
279f343bbf6c
parent 89
5eecce5314d6
child 91
fac51f87def0

load_modules supports nsapi module init functions

src/server/safs/init.c file | annotate | diff | comparison | revisions
--- a/src/server/safs/init.c	Wed Jul 31 11:35:57 2013 +0200
+++ b/src/server/safs/init.c	Wed Jul 31 13:02:06 2013 +0200
@@ -104,5 +104,26 @@
         }
     }
     
+    // if exists, execute nsapi_module_init
+    void *sym = dlsym(lib, "nsapi_module_init");
+    if(sym) {
+        /*
+         * We remove shlib and funcs from the pblock. The module init function
+         * gets all remaining parameters.
+         */
+        pblock_remove("shlib", pb);
+        pblock_remove("funcs", pb);
+        
+        FuncPtr init_func = (FuncPtr)sym;
+        int ret = init_func(pb, NULL, NULL);
+        if(ret != REQ_PROCEED && ret != REQ_NOACTION) {
+            log_ereport(
+                    LOG_FAILURE,
+                    "nsapi_module_init for module %s failed",
+                    shlib);
+            return REQ_ABORTED;
+        }
+    }
+    
     return REQ_PROCEED;
 }

mercurial