ldb: add custom flags and functions for the application that wants to manipulate...
authorMatthieu Patou <mat@matws.net>
Wed, 20 Apr 2011 16:26:47 +0000 (20:26 +0400)
committerStefan Metzmacher <metze@samba.org>
Thu, 21 Apr 2011 12:41:56 +0000 (14:41 +0200)
Signed-off-by: Simo Sorce <idra@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
source4/lib/ldb/common/ldb.c
source4/lib/ldb/include/ldb_module.h
source4/lib/ldb/include/ldb_private.h

index 0aadeb0d30fd3a936d54e6db05bb88677d75e77c..433f30b7c194f387c7df011fa08f6be1f6afd4e5 100644 (file)
@@ -1112,6 +1112,7 @@ int ldb_build_search_req_ex(struct ldb_request **ret_req,
                req->handle->nesting++;
                req->handle->parent = parent;
                req->handle->flags = parent->handle->flags;
+               req->handle->custom_flags = parent->handle->custom_flags;
        }
 
        *ret_req = req;
@@ -1185,6 +1186,7 @@ int ldb_build_add_req(struct ldb_request **ret_req,
                req->handle->nesting++;
                req->handle->parent = parent;
                req->handle->flags = parent->handle->flags;
+               req->handle->custom_flags = parent->handle->custom_flags;
        }
 
        *ret_req = req;
@@ -1229,6 +1231,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req,
                req->handle->nesting++;
                req->handle->parent = parent;
                req->handle->flags = parent->handle->flags;
+               req->handle->custom_flags = parent->handle->custom_flags;
        }
 
        *ret_req = req;
@@ -1273,6 +1276,7 @@ int ldb_build_del_req(struct ldb_request **ret_req,
                req->handle->nesting++;
                req->handle->parent = parent;
                req->handle->flags = parent->handle->flags;
+               req->handle->custom_flags = parent->handle->custom_flags;
        }
 
        *ret_req = req;
@@ -1319,6 +1323,7 @@ int ldb_build_rename_req(struct ldb_request **ret_req,
                req->handle->nesting++;
                req->handle->parent = parent;
                req->handle->flags = parent->handle->flags;
+               req->handle->custom_flags = parent->handle->custom_flags;
        }
 
        *ret_req = req;
@@ -1394,6 +1399,7 @@ int ldb_build_extended_req(struct ldb_request **ret_req,
                req->handle->nesting++;
                req->handle->parent = parent;
                req->handle->flags = parent->handle->flags;
+               req->handle->custom_flags = parent->handle->custom_flags;
        }
 
        *ret_req = req;
@@ -1876,6 +1882,38 @@ void ldb_req_mark_trusted(struct ldb_request *req)
        req->handle->flags &= ~LDB_HANDLE_FLAG_UNTRUSTED;
 }
 
+/**
+  set custom flags. Those flags are set by applications using ldb,
+  they are application dependent and the same bit can have different
+  meaning in different application.
+ */
+void ldb_req_set_custom_flags(struct ldb_request *req, uint32_t flags)
+{
+       if (req != NULL && req->handle != NULL) {
+               req->handle->custom_flags = flags;
+       }
+}
+
+
+/**
+  get custom flags. Those flags are set by applications using ldb,
+  they are application dependent and the same bit can have different
+  meaning in different application.
+ */
+uint32_t ldb_req_get_custom_flags(struct ldb_request *req)
+{
+       if (req != NULL && req->handle != NULL) {
+               return req->handle->custom_flags;
+       }
+
+       /*
+        * 0 is not something any better or worse than
+        * anything else as req or the handle is NULL
+        */
+       return 0;
+}
+
+
 /**
    return true is a request is untrusted
  */
index db8726b7a36afb679768ebb7e38caee90d7890dd..6d6fff251cd50064f6e455932d5afd971386d51a 100644 (file)
@@ -240,6 +240,20 @@ void ldb_req_mark_trusted(struct ldb_request *req);
  */
 bool ldb_req_is_untrusted(struct ldb_request *req);
 
+/**
+  set custom flags. Those flags are set by applications using ldb,
+  they are application dependent and the same bit can have different
+  meaning in different application.
+ */
+void ldb_req_set_custom_flags(struct ldb_request *req, uint32_t flags);
+
+/**
+  get custom flags. Those flags are set by applications using ldb,
+  they are application dependent and the same bit can have different
+  meaning in different application.
+ */
+uint32_t ldb_req_get_custom_flags(struct ldb_request *req);
+
 /* load all modules from the given directory */
 int ldb_modules_load(const char *modules_path, const char *version);
 
index 5397b79ec50ffe2d40e556d19c527f2c8c81ece0..cafc020e29137dcd9907256315a02b077ec0126c 100644 (file)
@@ -58,6 +58,8 @@ struct ldb_handle {
        enum ldb_state state;
        struct ldb_context *ldb;
        unsigned flags;
+       /* flags dedicated to be set by application using ldb */
+       uint32_t custom_flags;
        unsigned nesting;
 
        /* used for debugging */