svn commit: samba r20036 - in branches/SAMBA_3_0/source/lib/ldb/common: .

vlendec at samba.org vlendec at samba.org
Tue Dec 5 06:25:13 GMT 2006


Author: vlendec
Date: 2006-12-05 06:25:12 +0000 (Tue, 05 Dec 2006)
New Revision: 20036

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

Log:
Merge ldb_search_exp_fmt -- Thanks simo
Modified:
   branches/SAMBA_3_0/source/lib/ldb/common/ldb.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/ldb/common/ldb.c
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/common/ldb.c	2006-12-05 06:15:23 UTC (rev 20035)
+++ branches/SAMBA_3_0/source/lib/ldb/common/ldb.c	2006-12-05 06:25:12 UTC (rev 20036)
@@ -795,6 +795,45 @@
 }
 
 /*
+ a useful search function where you can easily define the expression and that
+ takes a memory context where results are allocated
+*/
+
+int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result,
+                        struct ldb_dn *base, enum ldb_scope scope, const char * const *attrs,
+                        const char *exp_fmt, ...)
+{
+	struct ldb_result *res;
+	char *expression;
+	va_list ap;
+	int ret;
+
+	res = NULL;
+	*result = NULL;
+
+	va_start(ap, exp_fmt);
+	expression = talloc_vasprintf(mem_ctx, exp_fmt, ap);
+	va_end(ap);
+
+	if ( ! expression) {
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
+	ret = ldb_search(ldb, base, scope, expression, attrs, &res);
+
+	if (ret == LDB_SUCCESS) {
+		talloc_steal(mem_ctx, res);
+		*result = res;
+	} else {
+		talloc_free(res);
+	}
+
+	talloc_free(expression);
+
+	return ret;
+}
+
+/*
   add a record to the database. Will fail if a record with the given class and key
   already exists
 */



More information about the samba-cvs mailing list