diff options
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r-- | source4/lib/ldb/common/ldb_msg.c | 22 |
1 files changed, 22 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 */ |