summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-05-03 14:51:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:43 -0500
commit208e09747c242ab5bd59a658033db49efa8d8696 (patch)
tree46fd31e75aa1e805f3abb9fa572f36da2b70b3da /source4/lib/ldb/ldb_tdb
parentb96695ca23f8d1d95ed2e038ea66e6a0580356c3 (diff)
downloadsamba-208e09747c242ab5bd59a658033db49efa8d8696.tar.gz
samba-208e09747c242ab5bd59a658033db49efa8d8696.tar.bz2
samba-208e09747c242ab5bd59a658033db49efa8d8696.zip
r456: - added -i option to ldbsearch
- fixed sorting bug in ldb index handing (This used to be commit cdd48e2b9b3ca6be5503eec401e09db162408ac8)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c13
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c12
2 files changed, 15 insertions, 10 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 987ee017b6..d250bc10be 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -96,6 +96,11 @@ static int ldb_msg_find_idx(const struct ldb_message *msg, const char *attr,
return -1;
}
+/* used in sorting dn lists */
+static int list_cmp(const char **s1, const char **s2)
+{
+ return strcmp(*s1, *s2);
+}
/*
return a list of dn's that might match a simple indexed search or
@@ -164,7 +169,7 @@ static int ltdb_index_dn_simple(struct ldb_context *ldb,
ltdb_search_dn1_free(ldb, &msg);
- qsort(list->dn, list->count, sizeof(char *), (comparison_fn_t) strcmp);
+ qsort(list->dn, list->count, sizeof(char *), (comparison_fn_t) list_cmp);
return 1;
}
@@ -309,7 +314,7 @@ static int list_union(struct dn_list *list, const struct dn_list *list2)
}
if (list->count != count) {
- qsort(list->dn, list->count, sizeof(char *), (comparison_fn_t)strcmp);
+ qsort(list->dn, list->count, sizeof(char *), (comparison_fn_t)list_cmp);
}
return 0;
@@ -483,7 +488,7 @@ static int ldb_index_filter(struct ldb_context *ldb, struct ldb_parse_tree *tree
const char *base,
enum ldb_scope scope,
const struct dn_list *dn_list,
- char * const attrs[], struct ldb_message ***res)
+ const char * const attrs[], struct ldb_message ***res)
{
int i;
unsigned int count = 0;
@@ -523,7 +528,7 @@ int ltdb_search_indexed(struct ldb_context *ldb,
const char *base,
enum ldb_scope scope,
struct ldb_parse_tree *tree,
- char * const attrs[], struct ldb_message ***res)
+ const char * const attrs[], struct ldb_message ***res)
{
struct ltdb_private *ltdb = ldb->private_data;
struct dn_list dn_list;
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 1dce8f83a2..cce865e052 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -148,7 +148,7 @@ static int msg_add_all_elements(struct ldb_message *ret,
*/
static struct ldb_message *ltdb_pull_attrs(struct ldb_context *ldb,
const struct ldb_message *msg,
- char * const *attrs)
+ const char * const *attrs)
{
struct ldb_message *ret;
int i;
@@ -294,7 +294,7 @@ int ltdb_search_dn1(struct ldb_context *ldb, const char *dn, struct ldb_message
search the database for a single simple dn
*/
int ltdb_search_dn(struct ldb_context *ldb, char *dn,
- char * const attrs[], struct ldb_message ***res)
+ const char * const attrs[], struct ldb_message ***res)
{
int ret;
struct ldb_message msg, *msg2;
@@ -330,7 +330,7 @@ int ltdb_search_dn(struct ldb_context *ldb, char *dn,
return 0 on success, -1 on failure
*/
int ltdb_add_attr_results(struct ldb_context *ldb, struct ldb_message *msg,
- char * const attrs[],
+ const char * const attrs[],
unsigned int *count,
struct ldb_message ***res)
{
@@ -368,7 +368,7 @@ struct ltdb_search_info {
struct ldb_parse_tree *tree;
const char *base;
enum ldb_scope scope;
- char * const *attrs;
+ const char * const *attrs;
struct ldb_message **msgs;
int failures;
int count;
@@ -445,7 +445,7 @@ static int ltdb_search_full(struct ldb_context *ldb,
const char *base,
enum ldb_scope scope,
struct ldb_parse_tree *tree,
- char * const attrs[], struct ldb_message ***res)
+ const char * const attrs[], struct ldb_message ***res)
{
struct ltdb_private *ltdb = ldb->private_data;
int ret;
@@ -478,7 +478,7 @@ static int ltdb_search_full(struct ldb_context *ldb,
*/
int ltdb_search(struct ldb_context *ldb, const char *base,
enum ldb_scope scope, const char *expression,
- char * const attrs[], struct ldb_message ***res)
+ const char * const attrs[], struct ldb_message ***res)
{
struct ldb_parse_tree *tree;
int ret;