mirror of
https://github.com/samba-team/samba.git
synced 2025-11-26 04:23:49 +03:00
r5357: added ldb_msg_add_fmt(), for creating formatted ldb record values
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
e467715c63
commit
18fb48204f
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user