svn commit: samba r5357 - in branches/SAMBA_4_0/source/lib/ldb: common include

tridge at samba.org tridge at samba.org
Sat Feb 12 11:30:33 GMT 2005


Author: tridge
Date: 2005-02-12 11:30:33 +0000 (Sat, 12 Feb 2005)
New Revision: 5357

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

Log:
added ldb_msg_add_fmt(), for creating formatted ldb record values


Modified:
   branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c
   branches/SAMBA_4_0/source/lib/ldb/include/ldb.h


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c	2005-02-12 03:10:50 UTC (rev 5356)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c	2005-02-12 11:30:33 UTC (rev 5357)
@@ -213,6 +213,28 @@
 }
 
 /*
+  add a printf formatted element to a message
+*/
+int ldb_msg_add_fmt(struct ldb_context *ldb, struct ldb_message *msg, 
+		    const char *attr_name, const char *fmt, ...)
+{
+	struct ldb_val val;
+	va_list ap;
+	char *str;
+
+	va_start(ap, fmt);
+	str = talloc_vasprintf(msg, fmt, ap);
+	va_end(ap);
+
+	if (str == NULL) return -1;
+
+	val.data   = str;
+	val.length = strlen(str);
+
+	return ldb_msg_add_value(ldb, msg, attr_name, &val);
+}
+
+/*
   compare two ldb_message_element structures
   assumes case senistive comparison
 */

Modified: branches/SAMBA_4_0/source/lib/ldb/include/ldb.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/include/ldb.h	2005-02-12 03:10:50 UTC (rev 5356)
+++ branches/SAMBA_4_0/source/lib/ldb/include/ldb.h	2005-02-12 11:30:33 UTC (rev 5357)
@@ -259,6 +259,8 @@
 		      const struct ldb_val *val);
 int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, 
 		       const char *attr_name, const char *str);
+int ldb_msg_add_fmt(struct ldb_context *ldb, struct ldb_message *msg, 
+		    const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(4,5);
 
 /* compare two message elements - return 0 on match */
 int ldb_msg_element_compare(struct ldb_message_element *el1, 



More information about the samba-cvs mailing list