r23798: updated old Temple Place FSF addresses to new URL
[samba.git] / source4 / lib / ldb / modules / objectclass.c
index a8c99226cd815c1287aa8d30e347f91d25e687e3..51e95076bd1decb5fbbc2ba09d952ff411818f18 100644 (file)
@@ -11,7 +11,7 @@
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
-   version 2 of the License, or (at your option) any later version.
+   version 3 of the License, or (at your option) any later version.
 
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,8 +19,7 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
@@ -33,8 +32,7 @@
  *  Author: Andrew Bartlett
  */
 
-#include "includes.h"
-#include "ldb/include/includes.h"
+#include "ldb_includes.h"
 
 struct oc_context {
 
@@ -63,7 +61,7 @@ static struct ldb_handle *oc_init_handle(struct ldb_request *req, struct ldb_mod
 
        h = talloc_zero(req, struct ldb_handle);
        if (h == NULL) {
-               ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+               ldb_set_errstring(module->ldb, "Out of Memory");
                return NULL;
        }
 
@@ -71,7 +69,7 @@ static struct ldb_handle *oc_init_handle(struct ldb_request *req, struct ldb_mod
 
        ac = talloc_zero(h, struct oc_context);
        if (ac == NULL) {
-               ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+               ldb_set_errstring(module->ldb, "Out of Memory");
                talloc_free(h);
                return NULL;
        }
@@ -129,7 +127,7 @@ static int objectclass_sort(struct ldb_module *module,
        for (i=0; i < objectclass_element->num_values; i++) {
                current = talloc(mem_ctx, struct class_list);
                if (!current) {
-                       ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "objectclass: out of memory allocating objectclass list"));
+                       ldb_set_errstring(module->ldb, "objectclass: out of memory allocating objectclass list");
                        talloc_free(mem_ctx);
                        return LDB_ERR_OPERATIONS_ERROR;
                }
@@ -138,9 +136,9 @@ static int objectclass_sort(struct ldb_module *module,
                /* this is the root of the tree.  We will start
                 * looking for subclasses from here */
                if (ldb_attr_cmp("top", current->objectclass) == 0) {
-                       DLIST_ADD(parent_class, current);
+                       DLIST_ADD_END(parent_class, current, struct class_list *);
                } else {
-                       DLIST_ADD(unsorted, current);
+                       DLIST_ADD_END(unsorted, current, struct class_list *);
                }
        }
 
@@ -235,7 +233,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req)
        /* prepare the first operation */
        down_req = talloc(req, struct ldb_request);
        if (down_req == NULL) {
-               ldb_set_errstring(module->ldb, talloc_asprintf(module->ldb, "Out of memory!"));
+               ldb_set_errstring(module->ldb, "Out of memory!");
                talloc_free(mem_ctx);
                return LDB_ERR_OPERATIONS_ERROR;
        }
@@ -250,7 +248,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req)
        }
 
        ldb_msg_remove_attr(msg, "objectClass");
-       ret = ldb_msg_add_empty(msg, "objectClass", 0);
+       ret = ldb_msg_add_empty(msg, "objectClass", 0, NULL);
        
        if (ret != LDB_SUCCESS) {
                talloc_free(mem_ctx);
@@ -264,7 +262,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req)
        for (current = sorted; current; current = current->next) {
                ret = ldb_msg_add_string(msg, "objectClass", current->objectclass);
                if (ret != LDB_SUCCESS) {
-                       ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "objectclass: could not re-add sorted objectclass to modify msg"));
+                       ldb_set_errstring(module->ldb, "objectclass: could not re-add sorted objectclass to modify msg");
                        talloc_free(mem_ctx);
                        return ret;
                }
@@ -328,7 +326,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req
                /* prepare the first operation */
                down_req = talloc(req, struct ldb_request);
                if (down_req == NULL) {
-                       ldb_set_errstring(module->ldb, talloc_asprintf(module->ldb, "Out of memory!"));
+                       ldb_set_errstring(module->ldb, "Out of memory!");
                        talloc_free(mem_ctx);
                        return LDB_ERR_OPERATIONS_ERROR;
                }
@@ -351,7 +349,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req
                 * because we need it sorted */
                
                ldb_msg_remove_attr(msg, "objectClass");
-               ret = ldb_msg_add_empty(msg, "objectClass", LDB_FLAG_MOD_REPLACE);
+               ret = ldb_msg_add_empty(msg, "objectClass", LDB_FLAG_MOD_REPLACE, NULL);
                
                if (ret != LDB_SUCCESS) {
                        talloc_free(mem_ctx);
@@ -362,7 +360,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req
                for (current = sorted; current; current = current->next) {
                        ret = ldb_msg_add_string(msg, "objectClass", current->objectclass);
                        if (ret != LDB_SUCCESS) {
-                               ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "objectclass: could not re-add sorted objectclass to modify msg"));
+                               ldb_set_errstring(module->ldb, "objectclass: could not re-add sorted objectclass to modify msg");
                                talloc_free(mem_ctx);
                                return ret;
                        }
@@ -404,7 +402,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req
                /* prepare the first operation */
                ac->down_req = talloc(ac, struct ldb_request);
                if (ac->down_req == NULL) {
-                       ldb_set_errstring(module->ldb, talloc_asprintf(module->ldb, "Out of memory!"));
+                       ldb_set_errstring(module->ldb, "Out of memory!");
                        return LDB_ERR_OPERATIONS_ERROR;
                }
                
@@ -425,7 +423,7 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_
        struct oc_context *ac;
 
        if (!context || !ares) {
-               ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
+               ldb_set_errstring(ldb, "NULL Context or Result in callback");
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
@@ -434,12 +432,12 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_
        /* we are interested only in the single reply (base search) we receive here */
        if (ares->type == LDB_REPLY_ENTRY) {
                if (ac->search_res != NULL) {
-                       ldb_set_errstring(ldb, talloc_asprintf(ldb, "Too many results"));
+                       ldb_set_errstring(ldb, "Too many results");
                        talloc_free(ares);
                        return LDB_ERR_OPERATIONS_ERROR;
                }
 
-               ac->search_res = talloc_steal(ac, ares);
+               ac->search_res = talloc_move(ac, &ares);
        } else {
                talloc_free(ares);
        }
@@ -464,9 +462,9 @@ static int objectclass_search_self(struct ldb_handle *h) {
        ac->search_req->operation = LDB_SEARCH;
        ac->search_req->op.search.base = ac->orig_req->op.mod.message->dn;
        ac->search_req->op.search.scope = LDB_SCOPE_BASE;
-       ac->search_req->op.search.tree = ldb_parse_tree(ac->module->ldb, NULL);
+       ac->search_req->op.search.tree = ldb_parse_tree(ac->search_req, NULL);
        if (ac->search_req->op.search.tree == NULL) {
-               ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: Internal error producing null search"));
+               ldb_set_errstring(ac->module->ldb, "objectclass: Internal error producing null search");
                return LDB_ERR_OPERATIONS_ERROR;
        }
        ac->search_req->op.search.attrs = attrs;
@@ -511,7 +509,7 @@ static int objectclass_do_mod(struct ldb_handle *h) {
        /* use a new message structure */
        ac->mod_req->op.mod.message = msg = ldb_msg_new(ac->mod_req);
        if (msg == NULL) {
-               ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: could not create new modify msg"));
+               ldb_set_errstring(ac->module->ldb, "objectclass: could not create new modify msg");
                talloc_free(mem_ctx);
                return LDB_ERR_OPERATIONS_ERROR;
        }
@@ -537,9 +535,9 @@ static int objectclass_do_mod(struct ldb_handle *h) {
         * We could do a constrained add/del, but we are meant to be
         * in a transaction... */
 
-       ret = ldb_msg_add_empty(msg, "objectClass", LDB_FLAG_MOD_REPLACE);
+       ret = ldb_msg_add_empty(msg, "objectClass", LDB_FLAG_MOD_REPLACE, NULL);
        if (ret != LDB_SUCCESS) {
-               ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: could not clear objectclass in modify msg"));
+               ldb_set_errstring(ac->module->ldb, "objectclass: could not clear objectclass in modify msg");
                talloc_free(mem_ctx);
                return ret;
        }
@@ -548,7 +546,7 @@ static int objectclass_do_mod(struct ldb_handle *h) {
        for (current = sorted; current; current = current->next) {
                ret = ldb_msg_add_string(msg, "objectClass", current->objectclass);
                if (ret != LDB_SUCCESS) {
-                       ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: could not re-add sorted objectclass to modify msg"));
+                       ldb_set_errstring(ac->module->ldb, "objectclass: could not re-add sorted objectclass to modify msg");
                        talloc_free(mem_ctx);
                        return ret;
                }