diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-10-12 06:10:23 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2005-10-12 06:10:23 +0000 |
commit | 1ff8a15849323c3d86606193c2587b93efa38cd3 (patch) | |
tree | e253592d789c33c12692765fcf249b1094126f6e /source/lib/ldb/common/ldb_parse.c | |
parent | 3612d2056fb3eb8bd95801d58f45dfca51e5f5dc (diff) | |
download | samba-1ff8a15849323c3d86606193c2587b93efa38cd3.tar.gz samba-1ff8a15849323c3d86606193c2587b93efa38cd3.tar.xz samba-1ff8a15849323c3d86606193c2587b93efa38cd3.zip |
r10913: This patch isn't as big as it looks ...
most of the changes are fixes to make all the ldb code compile without
warnings on gcc4. Unfortunately That required a lot of casts :-(
I have also added the start of an 'operational' module, which will
replace the timestamp module, plus add support for some other
operational attributes
In ldb_msg_*() I added some new utility functions to make the
operational module sane, and remove the 'ldb' argument from the
ldb_msg_add_*() functions. That argument was only needed back in the
early days of ldb when we didn't use the hierarchical talloc and thus
needed a place to get the allocation function from. Now its just a
pain to pass around everywhere.
Also added a ldb_debug_set() function that calls ldb_debug() plus sets
the result using ldb_set_errstring(). That saves on some awkward
coding in a few places.
Diffstat (limited to 'source/lib/ldb/common/ldb_parse.c')
-rw-r--r-- | source/lib/ldb/common/ldb_parse.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/source/lib/ldb/common/ldb_parse.c b/source/lib/ldb/common/ldb_parse.c index e61511ebec2..5824a8d003d 100644 --- a/source/lib/ldb/common/ldb_parse.c +++ b/source/lib/ldb/common/ldb_parse.c @@ -753,3 +753,51 @@ char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree) return NULL; } + + +/* + replace any occurances of an attribute name in the parse tree with a + new name +*/ +void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, + const char *attr, + const char *replace) +{ + int i; + switch (tree->operation) { + case LDB_OP_AND: + case LDB_OP_OR: + for (i=0;i<tree->u.list.num_elements;i++) { + ldb_parse_tree_attr_replace(tree->u.list.elements[i], + attr, replace); + } + break; + case LDB_OP_NOT: + ldb_parse_tree_attr_replace(tree->u.isnot.child, attr, replace); + break; + case LDB_OP_EQUALITY: + case LDB_OP_GREATER: + case LDB_OP_LESS: + case LDB_OP_APPROX: + if (ldb_attr_cmp(tree->u.equality.attr, attr) == 0) { + tree->u.equality.attr = replace; + } + break; + case LDB_OP_SUBSTRING: + if (ldb_attr_cmp(tree->u.substring.attr, attr) == 0) { + tree->u.substring.attr = replace; + } + break; + case LDB_OP_PRESENT: + if (ldb_attr_cmp(tree->u.present.attr, attr) == 0) { + tree->u.present.attr = replace; + } + break; + case LDB_OP_EXTENDED: + if (tree->u.extended.attr && + ldb_attr_cmp(tree->u.extended.attr, attr) == 0) { + tree->u.extended.attr = replace; + } + break; + } +} |