diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-05-06 04:40:15 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:51:45 -0500 |
commit | d8ce7c6a2acbf371509a23775470e7614bcb6027 (patch) | |
tree | 3b0d2157dc855a17a6e7f0ace37cddfb60dfdb04 /source4/lib/ldb/tools/ldbsearch.c | |
parent | 3aa278b873c5d06a279e0e65a96d6e6b42b64583 (diff) | |
download | samba-d8ce7c6a2acbf371509a23775470e7614bcb6027.tar.gz samba-d8ce7c6a2acbf371509a23775470e7614bcb6027.tar.bz2 samba-d8ce7c6a2acbf371509a23775470e7614bcb6027.zip |
r502: modified ldb to allow the use of an external pool memory
allocator. The way to use this is to call ldb_set_alloc() with a
function pointer to whatever memory allocator you like. It includes a
context pointer to allow for pool based allocators.
(This used to be commit 3955c482e6c2c9e975a4bb809ec8cb6068e48e34)
Diffstat (limited to 'source4/lib/ldb/tools/ldbsearch.c')
-rw-r--r-- | source4/lib/ldb/tools/ldbsearch.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index 541024dd2d..edda31b793 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -45,11 +45,11 @@ static void usage(void) exit(1); } -static void do_search(struct ldb_context *ldb, - const char *basedn, - int scope, - const char *expression, - char * const *attrs) +static int do_search(struct ldb_context *ldb, + const char *basedn, + int scope, + const char *expression, + char * const *attrs) { int ret, i; struct ldb_message **msgs; @@ -57,7 +57,7 @@ static void do_search(struct ldb_context *ldb, ret = ldb_search(ldb, basedn, scope, expression, attrs, &msgs); if (ret == -1) { printf("search failed - %s\n", ldb_errstring(ldb)); - return; + return -1; } printf("# returned %d records\n", ret); @@ -69,7 +69,7 @@ static void do_search(struct ldb_context *ldb, ldif.changetype = LDB_CHANGETYPE_NONE; ldif.msg = *msgs[i]; - ldif_write_file(stdout, &ldif); + ldif_write_file(ldb, stdout, &ldif); } if (ret > 0) { @@ -79,6 +79,8 @@ static void do_search(struct ldb_context *ldb, exit(1); } } + + return 0; } int main(int argc, char * const argv[]) @@ -89,7 +91,7 @@ static void do_search(struct ldb_context *ldb, const char *basedn = NULL; int opt; enum ldb_scope scope = LDB_SCOPE_SUBTREE; - int interactive = 0; + int interactive = 0, ret=0; ldb_url = getenv("LDB_URL"); @@ -150,12 +152,14 @@ static void do_search(struct ldb_context *ldb, if (interactive) { char line[1024]; while (fgets(line, sizeof(line), stdin)) { - do_search(ldb, basedn, scope, line, attrs); + if (do_search(ldb, basedn, scope, line, attrs) == -1) { + ret = -1; + } } } else { - do_search(ldb, basedn, scope, argv[0], attrs); + ret = do_search(ldb, basedn, scope, argv[0], attrs); } ldb_close(ldb); - return 0; + return ret; } |