Use <tdb.h> to include tdb, so the system include file gets used when building against
[kai/samba.git] / source4 / ntvfs / common / notify.c
index 94d32488eb95487457690b1f7c69565889743381..0b5f91bfe19cd20e51a49325227ab96742b993d2 100644 (file)
 
 #include "includes.h"
 #include "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
-#include "lib/util/util_tdb.h"
+#include <tdb.h>
+#include "../lib/util/util_tdb.h"
 #include "messaging/messaging.h"
 #include "tdb_wrap.h"
 #include "lib/messaging/irpc.h"
-#include "librpc/gen_ndr/ndr_notify.h"
-#include "lib/util/dlinklist.h"
+#include "librpc/gen_ndr/ndr_s4_notify.h"
+#include "../lib/util/dlinklist.h"
 #include "ntvfs/common/ntvfs_common.h"
 #include "ntvfs/sysdep/sys_notify.h"
 #include "cluster/cluster.h"
 #include "param/param.h"
+#include "lib/util/tsort.h"
 
 struct notify_context {
        struct tdb_wrap *w;
@@ -83,7 +84,7 @@ static int notify_destructor(struct notify_context *notify)
 struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, 
                                   struct messaging_context *messaging_ctx,
                                   struct loadparm_context *lp_ctx,
-                                  struct event_context *ev,
+                                  struct tevent_context *ev,
                                   struct share_config *scfg)
 {
        struct notify_context *notify;
@@ -92,6 +93,10 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
                return NULL;
        }
 
+       if (ev == NULL) {
+               return NULL;
+       }
+
        notify = talloc(mem_ctx, struct notify_context);
        if (notify == NULL) {
                return NULL;
@@ -171,8 +176,7 @@ static NTSTATUS notify_load(struct notify_context *notify)
        blob.data = dbuf.dptr;
        blob.length = dbuf.dsize;
 
-       ndr_err = ndr_pull_struct_blob(&blob, notify->array, lp_iconv_convenience(global_loadparm),
-                                      notify->array,
+       ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array,
                                       (ndr_pull_flags_fn_t)ndr_pull_notify_array);
        free(dbuf.dptr);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
@@ -220,7 +224,7 @@ static NTSTATUS notify_save(struct notify_context *notify)
        tmp_ctx = talloc_new(notify);
        NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
 
-       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), notify->array,
+       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->array,
                                       (ndr_push_flags_fn_t)ndr_push_notify_array);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
@@ -256,7 +260,7 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data
                return;
        }
 
-       ndr_err = ndr_pull_struct_blob(data, tmp_ctx, lp_iconv_convenience(global_loadparm), &ev,
+       ndr_err = ndr_pull_struct_blob(data, tmp_ctx, &ev,
                                      (ndr_pull_flags_fn_t)ndr_pull_notify_event);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
@@ -322,9 +326,7 @@ static NTSTATUS notify_add_array(struct notify_context *notify, struct notify_en
        d->max_mask |= e->filter;
        d->max_mask_subdir |= e->subdir_filter;
 
-       if (d->num_entries > 1) {
-               qsort(d->entries, d->num_entries, sizeof(d->entries[0]), notify_compare);
-       }
+       TYPESAFE_QSORT(d->entries, d->num_entries, notify_compare);
 
        /* recalculate the maximum masks */
        d->max_mask = 0;
@@ -555,7 +557,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e,
 
        tmp_ctx = talloc_new(notify);
 
-       ndr_err = ndr_push_struct_blob(&data, tmp_ctx, lp_iconv_convenience(global_loadparm), &ev, (ndr_push_flags_fn_t)ndr_push_notify_event);
+       ndr_err = ndr_push_struct_blob(&data, tmp_ctx, &ev, (ndr_push_flags_fn_t)ndr_push_notify_event);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
                return;