svn commit: samba r19491 - in branches/SAMBA_3_0/source/lib/ldb: common include modules

idra at samba.org idra at samba.org
Wed Oct 25 02:06:07 GMT 2006


Author: idra
Date: 2006-10-25 02:06:05 +0000 (Wed, 25 Oct 2006)
New Revision: 19491

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19491

Log:

backport changes from samba4


Modified:
   branches/SAMBA_3_0/source/lib/ldb/common/ldb_ldif.c
   branches/SAMBA_3_0/source/lib/ldb/common/ldb_msg.c
   branches/SAMBA_3_0/source/lib/ldb/include/ldb.h
   branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map.c
   branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map_inbound.c
   branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map_outbound.c
   branches/SAMBA_3_0/source/lib/ldb/modules/objectclass.c
   branches/SAMBA_3_0/source/lib/ldb/modules/rdn_name.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/ldb/common/ldb_ldif.c
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/common/ldb_ldif.c	2006-10-25 01:59:07 UTC (rev 19490)
+++ branches/SAMBA_3_0/source/lib/ldb/common/ldb_ldif.c	2006-10-25 02:06:05 UTC (rev 19491)
@@ -613,7 +613,7 @@
 		}
 
 		if (empty) {
-			if (ldb_msg_add_empty(msg, (char *)value.data, flags) != 0) {
+			if (ldb_msg_add_empty(msg, (char *)value.data, flags, NULL) != 0) {
 				goto failed;
 			}
 			continue;

Modified: branches/SAMBA_3_0/source/lib/ldb/common/ldb_msg.c
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/common/ldb_msg.c	2006-10-25 01:59:07 UTC (rev 19490)
+++ branches/SAMBA_3_0/source/lib/ldb/common/ldb_msg.c	2006-10-25 02:06:05 UTC (rev 19491)
@@ -119,7 +119,10 @@
 /*
   add an empty element to a message
 */
-int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags)
+int ldb_msg_add_empty(struct ldb_message *msg,
+		      const char *attr_name,
+		      int flags,
+		      struct ldb_message_element **return_el)
 {
 	struct ldb_message_element *els;
 
@@ -146,6 +149,10 @@
 	msg->elements = els;
 	msg->num_elements++;
 
+	if (return_el) {
+		*return_el = &els[msg->num_elements-1];
+	}
+
 	return LDB_SUCCESS;
 }
 
@@ -156,7 +163,7 @@
 		const struct ldb_message_element *el, 
 		int flags)
 {
-	if (ldb_msg_add_empty(msg, el->name, flags) != 0) {
+	if (ldb_msg_add_empty(msg, el->name, flags, NULL) != 0) {
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
@@ -171,19 +178,20 @@
 */
 int ldb_msg_add_value(struct ldb_message *msg, 
 		      const char *attr_name,
-		      const struct ldb_val *val)
+		      const struct ldb_val *val,
+		      struct ldb_message_element **return_el)
 {
 	struct ldb_message_element *el;
 	struct ldb_val *vals;
+	int ret;
 
 	el = ldb_msg_find_element(msg, attr_name);
 	if (!el) {
-		ldb_msg_add_empty(msg, attr_name, 0);
-		el = ldb_msg_find_element(msg, attr_name);
+		ret = ldb_msg_add_empty(msg, attr_name, 0, &el);
+		if (ret != LDB_SUCCESS) {
+			return ret;
+		}
 	}
-	if (!el) {
-		return LDB_ERR_OPERATIONS_ERROR;
-	}
 
 	vals = talloc_realloc(msg, el->values, struct ldb_val, el->num_values+1);
 	if (!vals) {
@@ -194,6 +202,10 @@
 	el->values[el->num_values] = *val;
 	el->num_values++;
 
+	if (return_el) {
+		*return_el = el;
+	}
+
 	return LDB_SUCCESS;
 }
 
@@ -206,12 +218,10 @@
 			    struct ldb_val *val)
 {
 	int ret;
-	ret = ldb_msg_add_value(msg, attr_name, val);
+	struct ldb_message_element *el;
+
+	ret = ldb_msg_add_value(msg, attr_name, val, &el);
 	if (ret == LDB_SUCCESS) {
-		struct ldb_message_element *el;
-		if (!(el = ldb_msg_find_element(msg, attr_name))) {
-			return LDB_ERR_OPERATIONS_ERROR;
-		}
 		talloc_steal(el->values, val->data);
 	}
 	return ret;
@@ -234,7 +244,7 @@
 		return LDB_SUCCESS;
 	}
 
-	return ldb_msg_add_value(msg, attr_name, &val);
+	return ldb_msg_add_value(msg, attr_name, &val, NULL);
 }
 
 /*
@@ -578,7 +588,7 @@
 		if (!el) {
 			if (ldb_msg_add_empty(mod, 
 					      msg1->elements[i].name,
-					      LDB_FLAG_MOD_DELETE) != 0) {
+					      LDB_FLAG_MOD_DELETE, NULL) != 0) {
 				return NULL;
 			}
 		}

Modified: branches/SAMBA_3_0/source/lib/ldb/include/ldb.h
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/include/ldb.h	2006-10-25 01:59:07 UTC (rev 19490)
+++ branches/SAMBA_3_0/source/lib/ldb/include/ldb.h	2006-10-25 02:06:05 UTC (rev 19491)
@@ -1227,7 +1227,10 @@
 /**
    add a new empty element to a ldb_message
 */
-int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags);
+int ldb_msg_add_empty(struct ldb_message *msg,
+		      const char *attr_name,
+		      int flags,
+		      struct ldb_message_element **return_el);
 
 /**
    add a element to a ldb_message
@@ -1237,7 +1240,8 @@
 		int flags);
 int ldb_msg_add_value(struct ldb_message *msg, 
 		      const char *attr_name,
-		      const struct ldb_val *val);
+		      const struct ldb_val *val,
+		      struct ldb_message_element **return_el);
 int ldb_msg_add_steal_value(struct ldb_message *msg, 
 		      const char *attr_name,
 		      struct ldb_val *val);

Modified: branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map.c
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map.c	2006-10-25 01:59:07 UTC (rev 19490)
+++ branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map.c	2006-10-25 02:06:05 UTC (rev 19491)
@@ -964,7 +964,7 @@
 	if (dn == NULL) {
 		goto failed;
 	}
-	if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_REPLACE) != 0) {
+	if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_REPLACE, NULL) != 0) {
 		goto failed;
 	}
 	if (ldb_msg_add_string(msg, IS_MAPPED, dn) != 0) {

Modified: branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map_inbound.c
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map_inbound.c	2006-10-25 01:59:07 UTC (rev 19490)
+++ branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map_inbound.c	2006-10-25 02:06:05 UTC (rev 19491)
@@ -345,7 +345,7 @@
 		/* Add local 'IS_MAPPED' */
 		/* TODO: use GUIDs here instead */
 		dn = ldb_dn_linearize(msg, ac->remote_req->op.mod.message->dn);
-		if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_ADD) != 0) {
+		if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_ADD, NULL) != 0) {
 			return LDB_ERR_OPERATIONS_ERROR;
 		}
 		if (ldb_msg_add_string(msg, IS_MAPPED, dn) != 0) {

Modified: branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map_outbound.c
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map_outbound.c	2006-10-25 01:59:07 UTC (rev 19490)
+++ branches/SAMBA_3_0/source/lib/ldb/modules/ldb_map_outbound.c	2006-10-25 02:06:05 UTC (rev 19491)
@@ -192,14 +192,9 @@
 
 	/* no local result, add as new element */
 	if (old == NULL) {
-		if (ldb_msg_add_empty(msg, el->name, 0) != 0) {
+		if (ldb_msg_add_empty(msg, el->name, 0, &old) != 0) {
 			return -1;
 		}
-
-		old = ldb_msg_find_element(msg, el->name);
-		if (old == NULL) {
-			return -1;
-		}
 	}
 
 	/* copy new element */

Modified: branches/SAMBA_3_0/source/lib/ldb/modules/objectclass.c
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/modules/objectclass.c	2006-10-25 01:59:07 UTC (rev 19490)
+++ branches/SAMBA_3_0/source/lib/ldb/modules/objectclass.c	2006-10-25 02:06:05 UTC (rev 19491)
@@ -250,7 +250,7 @@
 	}
 
 	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);
@@ -351,7 +351,7 @@
 		 * 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);
@@ -537,7 +537,7 @@
 	 * 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, "objectclass: could not clear objectclass in modify msg");
 		talloc_free(mem_ctx);

Modified: branches/SAMBA_3_0/source/lib/ldb/modules/rdn_name.c
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/modules/rdn_name.c	2006-10-25 01:59:07 UTC (rev 19490)
+++ branches/SAMBA_3_0/source/lib/ldb/modules/rdn_name.c	2006-10-25 02:06:05 UTC (rev 19491)
@@ -91,7 +91,7 @@
 		attribute->num_values = 0;
 	}
 
-	if (ldb_msg_add_value(msg, "name", &rdn->value) != 0) {
+	if (ldb_msg_add_value(msg, "name", &rdn->value, NULL) != 0) {
 		talloc_free(down_req);
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
@@ -99,7 +99,7 @@
 	attribute = rdn_name_find_attribute(msg, rdn->name);
 
 	if (!attribute) {
-		if (ldb_msg_add_value(msg, rdn->name, &rdn->value) != 0) {
+		if (ldb_msg_add_value(msg, rdn->name, &rdn->value, NULL) != 0) {
 			talloc_free(down_req);
 			return LDB_ERR_OPERATIONS_ERROR;
 		}
@@ -213,16 +213,16 @@
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
-	if (ldb_msg_add_empty(msg, rdn->name, LDB_FLAG_MOD_REPLACE) != 0) {
+	if (ldb_msg_add_empty(msg, rdn->name, LDB_FLAG_MOD_REPLACE, NULL) != 0) {
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
-	if (ldb_msg_add_value(msg, rdn->name, &rdn->value) != 0) {
+	if (ldb_msg_add_value(msg, rdn->name, &rdn->value, NULL) != 0) {
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
-	if (ldb_msg_add_empty(msg, "name", LDB_FLAG_MOD_REPLACE) != 0) {
+	if (ldb_msg_add_empty(msg, "name", LDB_FLAG_MOD_REPLACE, NULL) != 0) {
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
-	if (ldb_msg_add_value(msg, "name", &rdn->value) != 0) {
+	if (ldb_msg_add_value(msg, "name", &rdn->value, NULL) != 0) {
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
 



More information about the samba-cvs mailing list