]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb: Split out ldb_controls_get_control() to search a list of controls
authorJo Sutton <josutton@catalyst.net.nz>
Mon, 12 Feb 2024 22:57:07 +0000 (11:57 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 16 Feb 2024 02:41:36 +0000 (02:41 +0000)
Update the ldb ABI accordingly.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/ABI/ldb-2.10.0.sigs
lib/ldb/common/ldb_controls.c
lib/ldb/include/ldb.h

index 759659a22f94083379a1aba541d36e852d7b83cb..2266387cd60e2b94c1c316aa569ed375ba7d48b5 100644 (file)
@@ -26,6 +26,7 @@ ldb_comparison_fold: int (struct ldb_context *, void *, const struct ldb_val *,
 ldb_connect: int (struct ldb_context *, const char *, unsigned int, const char **)
 ldb_control_to_string: char *(TALLOC_CTX *, const struct ldb_control *)
 ldb_controls_except_specified: struct ldb_control **(struct ldb_control **, TALLOC_CTX *, struct ldb_control *)
+ldb_controls_get_control: struct ldb_control *(struct ldb_control **, const char *)
 ldb_debug: void (struct ldb_context *, enum ldb_debug_level, const char *, ...)
 ldb_debug_add: void (struct ldb_context *, const char *, ...)
 ldb_debug_end: void (struct ldb_context *, enum ldb_debug_level)
index b345506a0831e8db665719f8b634e5e4fd01b8e0..3bf89d844f9037ee91dabf53717eefbd11535aed 100644 (file)
 
 /* check if a control with the specified "oid" exist and return it */
 /* returns NULL if not found */
-struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char *oid)
+struct ldb_control *ldb_controls_get_control(struct ldb_control **controls, const char *oid)
 {
        unsigned int i;
 
-       if (req->controls != NULL) {
-               for (i = 0; req->controls[i]; i++) {
-                       if (req->controls[i]->oid && strcmp(oid, req->controls[i]->oid) == 0) {
+       if (controls != NULL) {
+               for (i = 0; controls[i]; i++) {
+                       if (controls[i]->oid && strcmp(oid, controls[i]->oid) == 0) {
                                break;
                        }
                }
 
-               return req->controls[i];
+               return controls[i];
        }
 
        return NULL;
@@ -54,21 +54,16 @@ struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char
 
 /* check if a control with the specified "oid" exist and return it */
 /* returns NULL if not found */
-struct ldb_control *ldb_reply_get_control(struct ldb_reply *rep, const char *oid)
+struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char *oid)
 {
-       unsigned int i;
-
-       if (rep->controls != NULL) {
-               for (i = 0; rep->controls[i]; i++) {
-                       if (rep->controls[i]->oid && strcmp(oid, rep->controls[i]->oid) == 0) {
-                               break;
-                       }
-               }
-
-               return rep->controls[i];
-       }
+       return ldb_controls_get_control(req->controls, oid);
+}
 
-       return NULL;
+/* check if a control with the specified "oid" exist and return it */
+/* returns NULL if not found */
+struct ldb_control *ldb_reply_get_control(struct ldb_reply *rep, const char *oid)
+{
+       return ldb_controls_get_control(rep->controls, oid);
 }
 
 /*
index 1f0e6abf5590e066b3bcde7532b3ebec63a86177..e98300d9e8df08936906927391928c326d927b43 100644 (file)
@@ -1342,6 +1342,15 @@ int ldb_request_add_control(struct ldb_request *req, const char *oid, bool criti
 */
 int ldb_request_replace_control(struct ldb_request *req, const char *oid, bool critical, void *data);
 
+/**
+   check if a control with the specified "oid" exist and return it
+  \param controls the array of controls
+  \param oid the object identifier of the control as string
+
+  \return the control, NULL if not found
+*/
+struct ldb_control *ldb_controls_get_control(struct ldb_control **controls, const char *oid);
+
 /**
    check if a control with the specified "oid" exist and return it
   \param req the request struct to search for the control