summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-02-12 11:30:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:45 -0500
commitff4797a9e4b01fe8cc9421e911371677433d070c (patch)
tree2f0dc8148ffb8fae5eb2bb08be227d96e3f6bbe3 /source4/lib
parent907d1d413d8c907876ae832a462a21839ac3d19a (diff)
downloadsamba-ff4797a9e4b01fe8cc9421e911371677433d070c.tar.gz
samba-ff4797a9e4b01fe8cc9421e911371677433d070c.tar.bz2
samba-ff4797a9e4b01fe8cc9421e911371677433d070c.zip
r5357: added ldb_msg_add_fmt(), for creating formatted ldb record values
(This used to be commit 18fb48204f4c0e22ea7e61575b3f174f30ff035c)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/common/ldb_msg.c22
-rw-r--r--source4/lib/ldb/include/ldb.h2
2 files changed, 24 insertions, 0 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index 3ef25e566f..b145565a84 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -213,6 +213,28 @@ int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg,
}
/*
+ 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
*/
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 310000b244..c6f96f6dea 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -259,6 +259,8 @@ int ldb_msg_add_value(struct ldb_context *ldb,
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,