From aa6b2dcb9bdff582ac7628f0c2511de12da57242 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 19 Jun 2005 01:32:47 +0000 Subject: r7741: fixed the verbose option in ldbedit (This used to be commit a440133140a6adb5ea62d37690b9c4ae74dc6be0) --- source4/lib/ldb/tools/ldbedit.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'source4/lib/ldb/tools') diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index 73fb77dfd1..e8497ba18f 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -41,7 +41,7 @@ #include "system/filesys.h" #endif -static int verbose; +static struct ldb_cmdline *options; /* debug routine @@ -77,16 +77,16 @@ static int modify_record(struct ldb_context *ldb, return 0; } + if (options->verbose > 0) { + ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_MODIFY, mod); + } + if (ldb_modify(ldb, mod) != 0) { fprintf(stderr, "failed to modify %s - %s\n", msg1->dn, ldb_errstring(ldb)); return -1; } - if (verbose > 0) { - ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_MODIFY, mod); - } - return mod->num_elements; } @@ -121,14 +121,14 @@ static int merge_edits(struct ldb_context *ldb, for (i=0;idn); if (!msg) { + if (options->verbose > 0) { + ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_ADD, msgs2[i]); + } if (ldb_add(ldb, msgs2[i]) != 0) { fprintf(stderr, "failed to add %s - %s\n", msgs2[i]->dn, ldb_errstring(ldb)); return -1; } - if (verbose > 0) { - ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_ADD, msgs2[i]); - } adds++; } else { if (modify_record(ldb, msg, msgs2[i]) > 0) { @@ -141,14 +141,14 @@ static int merge_edits(struct ldb_context *ldb, for (i=0;idn); if (!msg) { + if (options->verbose > 0) { + ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_DELETE, msgs1[i]); + } if (ldb_delete(ldb, msgs1[i]->dn) != 0) { fprintf(stderr, "failed to delete %s - %s\n", msgs1[i]->dn, ldb_errstring(ldb)); return -1; } - if (verbose > 0) { - ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_DELETE, msgs1[i]); - } deletes++; } } @@ -280,7 +280,6 @@ static void usage(void) int ret; const char *expression = NULL; const char * const * attrs = NULL; - struct ldb_cmdline *options; ldb = ldb_init(NULL); -- cgit