r26639: librpc: Pass iconv convenience on from RPC connection to NDR library, so...
[bbaumbach/samba-autobuild/.git] / source4 / ntvfs / common / notify.c
index 0214c39b2d753f844a6e97ec0fc7f9773e07621d..94d32488eb95487457690b1f7c69565889743381 100644 (file)
 #include "lib/tdb/include/tdb.h"
 #include "lib/util/util_tdb.h"
 #include "messaging/messaging.h"
-#include "db_wrap.h"
+#include "tdb_wrap.h"
 #include "lib/messaging/irpc.h"
 #include "librpc/gen_ndr/ndr_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"
 
 struct notify_context {
        struct tdb_wrap *w;
@@ -81,6 +82,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 share_config *scfg)
 {
@@ -95,7 +97,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
                return NULL;
        }
 
-       notify->w = cluster_tdb_tmp_open(notify, "notify.tdb", TDB_SEQNUM);
+       notify->w = cluster_tdb_tmp_open(notify, lp_ctx, "notify.tdb", TDB_SEQNUM);
        if (notify->w == NULL) {
                talloc_free(notify);
                return NULL;
@@ -146,7 +148,7 @@ static NTSTATUS notify_load(struct notify_context *notify)
 {
        TDB_DATA dbuf;
        DATA_BLOB blob;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        int seqnum;
 
        seqnum = tdb_get_seqnum(notify->w->tdb);
@@ -169,11 +171,15 @@ static NTSTATUS notify_load(struct notify_context *notify)
        blob.data = dbuf.dptr;
        blob.length = dbuf.dsize;
 
-       status = ndr_pull_struct_blob(&blob, notify->array, notify->array, 
-                                     (ndr_pull_flags_fn_t)ndr_pull_notify_array);
+       ndr_err = ndr_pull_struct_blob(&blob, notify->array, lp_iconv_convenience(global_loadparm),
+                                      notify->array,
+                                      (ndr_pull_flags_fn_t)ndr_pull_notify_array);
        free(dbuf.dptr);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               return ndr_map_error2ntstatus(ndr_err);
+       }
 
-       return status;
+       return NT_STATUS_OK;
 }
 
 /*
@@ -192,7 +198,7 @@ static NTSTATUS notify_save(struct notify_context *notify)
 {
        TDB_DATA dbuf;
        DATA_BLOB blob;
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        int ret;
        TALLOC_CTX *tmp_ctx;
 
@@ -214,11 +220,11 @@ static NTSTATUS notify_save(struct notify_context *notify)
        tmp_ctx = talloc_new(notify);
        NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
 
-       status = ndr_push_struct_blob(&blob, tmp_ctx, notify->array, 
-                                     (ndr_push_flags_fn_t)ndr_push_notify_array);
-       if (!NT_STATUS_IS_OK(status)) {
+       ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, lp_iconv_convenience(global_loadparm), notify->array,
+                                      (ndr_push_flags_fn_t)ndr_push_notify_array);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
-               return status;
+               return ndr_map_error2ntstatus(ndr_err);
        }
 
        dbuf.dptr = blob.data;
@@ -241,7 +247,7 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data
                           uint32_t msg_type, struct server_id server_id, DATA_BLOB *data)
 {
        struct notify_context *notify = talloc_get_type(private_data, struct notify_context);
-       NTSTATUS status;
+       enum ndr_err_code ndr_err;
        struct notify_event ev;
        TALLOC_CTX *tmp_ctx = talloc_new(notify);
        struct notify_list *listel;
@@ -250,9 +256,9 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data
                return;
        }
 
-       status = ndr_pull_struct_blob(data, tmp_ctx, &ev, 
+       ndr_err = ndr_pull_struct_blob(data, tmp_ctx, lp_iconv_convenience(global_loadparm), &ev,
                                      (ndr_pull_flags_fn_t)ndr_pull_notify_event);
-       if (!NT_STATUS_IS_OK(status)) {
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
                return;
        }
@@ -540,6 +546,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e,
        struct notify_event ev;
        DATA_BLOB data;
        NTSTATUS status;
+       enum ndr_err_code ndr_err;
        TALLOC_CTX *tmp_ctx;
 
        ev.action = action;
@@ -548,9 +555,8 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e,
 
        tmp_ctx = talloc_new(notify);
 
-       status = ndr_push_struct_blob(&data, tmp_ctx, &ev, 
-                                     (ndr_push_flags_fn_t)ndr_push_notify_event);
-       if (!NT_STATUS_IS_OK(status)) {
+       ndr_err = ndr_push_struct_blob(&data, tmp_ctx, lp_iconv_convenience(global_loadparm), &ev, (ndr_push_flags_fn_t)ndr_push_notify_event);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                talloc_free(tmp_ctx);
                return;
        }