diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-05-07 23:54:41 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:51:47 -0500 |
commit | 265023fafa463c742f89510879acb2a830de8ab9 (patch) | |
tree | 1614be24e20bd5c0bfc9f4a5d657a2b574df2c63 /source4/lib/ldb/common/ldb_msg.c | |
parent | dee25d910e5ed3d07a240cebe8600f4a95c94159 (diff) | |
download | samba-265023fafa463c742f89510879acb2a830de8ab9.tar.gz samba-265023fafa463c742f89510879acb2a830de8ab9.tar.bz2 samba-265023fafa463c742f89510879acb2a830de8ab9.zip |
r574: - another attempt at const cleanliness in ldb
- fixed a problem with searching for values containing an '=' sign
- fixed the semantics of attempting an attribute deletion on an attribute that doesn't exist.
- added some more ldb_msg_*() utilities
(This used to be commit 62b4ec367d170330d837b0f1fe5cd13205a53b59)
Diffstat (limited to 'source4/lib/ldb/common/ldb_msg.c')
-rw-r--r-- | source4/lib/ldb/common/ldb_msg.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index 5976db81b6..01f32751e1 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -132,6 +132,53 @@ int ldb_msg_add(struct ldb_context *ldb, } /* + add a value to a message +*/ +int ldb_msg_add_value(struct ldb_context *ldb, + struct ldb_message *msg, + char *attr_name, + struct ldb_val *val) +{ + struct ldb_message_element *el; + struct ldb_val *vals; + + el = ldb_msg_find_element(msg, attr_name); + if (!el) { + ldb_msg_add_empty(ldb, msg, attr_name, 0); + el = ldb_msg_find_element(msg, attr_name); + } + if (!el) { + return -1; + } + + vals = ldb_realloc_p(ldb, el->values, struct ldb_val, el->num_values+1); + if (!vals) { + errno = ENOMEM; + return -1; + } + el->values = vals; + el->values[el->num_values] = *val; + el->num_values++; + + return 0; +} + + +/* + add a string element to a message +*/ +int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, + char *attr_name, char *str) +{ + struct ldb_val val; + + 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 */ |