lib: modules: Change XXX_init interface from XXX_init(void) to XXX_init(TALLOC_CTX *)
[sfrench/samba-autobuild/.git] / source4 / ntvfs / sysdep / sys_notify.c
index 1664461d3324713d02f8c170b08dbcf3b092126c..aad3b900dd17c9014798f1e98d42d498670f7882 100644 (file)
 #include "includes.h"
 #include "system/filesys.h"
 #include "ntvfs/sysdep/sys_notify.h"
-#include "lib/events/events.h"
-#include "lib/util/dlinklist.h"
+#include <tevent.h>
+#include "../lib/util/dlinklist.h"
 #include "param/param.h"
-#include "build.h"
+#include "lib/util/samba_modules.h"
 
 /* list of registered backends */
 static struct sys_notify_backend *backends;
@@ -41,7 +41,7 @@ static uint32_t num_backends;
 */
 _PUBLIC_ struct sys_notify_context *sys_notify_context_create(struct share_config *scfg,
                                                              TALLOC_CTX *mem_ctx, 
-                                                             struct event_context *ev)
+                                                             struct tevent_context *ev)
 {
        struct sys_notify_context *ctx;
        const char *bname;
@@ -52,7 +52,7 @@ _PUBLIC_ struct sys_notify_context *sys_notify_context_create(struct share_confi
        }
 
        if (ev == NULL) {
-               ev = event_context_find(mem_ctx);
+               return NULL;
        }
 
        ctx = talloc_zero(mem_ctx, struct sys_notify_context);
@@ -62,7 +62,7 @@ _PUBLIC_ struct sys_notify_context *sys_notify_context_create(struct share_confi
 
        ctx->ev = ev;
 
-       bname = share_string_option(scfg, NOTIFY_BACKEND, NULL);
+       bname = share_string_option(ctx, scfg, NOTIFY_BACKEND, NULL);
        if (!bname) {
                if (num_backends) {
                        bname = backends[0].name;
@@ -72,6 +72,17 @@ _PUBLIC_ struct sys_notify_context *sys_notify_context_create(struct share_confi
        }
 
        for (i=0;i<num_backends;i++) {
+               char *enable_opt_name;
+               bool enabled;
+               
+               enable_opt_name = talloc_asprintf(mem_ctx, "notify:%s", 
+                                                                                 backends[i].name);
+               enabled = share_bool_option(scfg, enable_opt_name, true);
+               talloc_free(enable_opt_name);
+
+               if (!enabled) 
+                       continue;
+
                if (strcasecmp(backends[i].name, bname) == 0) {
                        bname = backends[i].name;
                        break;
@@ -124,19 +135,14 @@ _PUBLIC_ NTSTATUS sys_notify_register(struct sys_notify_backend *backend)
 _PUBLIC_ NTSTATUS sys_notify_init(void)
 {
        static bool initialized = false;
-
-       init_module_fn static_init[] = STATIC_sys_notify_MODULES;
-       init_module_fn *shared_init;
+#define _MODULE_PROTO(init) extern NTSTATUS init(TALLOC_CTX *);
+       STATIC_sys_notify_MODULES_PROTO;
+       init_module_fn static_init[] = { STATIC_sys_notify_MODULES };
 
        if (initialized) return NT_STATUS_OK;
        initialized = true;
 
-       shared_init = load_samba_modules(NULL, global_loadparm, "sys_notify");
-
-       run_init_functions(static_init);
-       run_init_functions(shared_init);
-
-       talloc_free(shared_init);
+       run_init_functions(NULL, static_init);
        
        return NT_STATUS_OK;
 }