1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-28 12:23:49 +03:00

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

This commit is contained in:
Andrew Tridgell
2005-02-12 11:30:33 +00:00
committed by Gerald (Jerry) Carter
parent e467715c63
commit 18fb48204f
2 changed files with 24 additions and 0 deletions

View File

@@ -212,6 +212,28 @@ int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg,
return ldb_msg_add_value(ldb, msg, attr_name, &val);
}
/*
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