diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-09-17 10:42:33 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:46 -0500 |
commit | be480ac55c1f3ebe29781ad718f28e5b95441d13 (patch) | |
tree | 489010032ba4354b0b849e70c810d0858ab76012 | |
parent | 66f1e8d020709aa66b3b64c9b583fd326aa6d3b0 (diff) | |
download | samba-be480ac55c1f3ebe29781ad718f28e5b95441d13.tar.gz samba-be480ac55c1f3ebe29781ad718f28e5b95441d13.tar.bz2 samba-be480ac55c1f3ebe29781ad718f28e5b95441d13.zip |
r2381: added a -v debugging option to ldbedit
(This used to be commit 03d4a7832cd3670a8166820a1b9b4aaf2307bd1a)
-rw-r--r-- | source4/lib/ldb/tools/ldbedit.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index 90a6f94750..b97c40ff1a 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -34,6 +34,22 @@ #include "includes.h" +static int verbose; + +/* + debug routine +*/ +static void ldif_write_msg(struct ldb_context *ldb, + FILE *f, + enum ldb_changetype changetype, + struct ldb_message *msg) +{ + struct ldb_ldif ldif; + ldif.changetype = changetype; + ldif.msg = *msg; + ldb_ldif_write_file(ldb, f, &ldif); +} + /* modify a database record so msg1 becomes msg2 returns the number of modified elements @@ -91,6 +107,10 @@ static int modify_record(struct ldb_context *ldb, return -1; } + if (verbose > 0) { + ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_MODIFY, &mod); + } + return count; } @@ -130,6 +150,9 @@ static int merge_edits(struct ldb_context *ldb, 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) { @@ -147,6 +170,9 @@ static int merge_edits(struct ldb_context *ldb, msgs1[i]->dn, ldb_errstring(ldb)); return -1; } + if (verbose > 0) { + ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_DELETE, msgs1[i]); + } deletes++; } } @@ -295,7 +321,7 @@ static void usage(void) editor = "vi"; } - while ((opt = getopt(argc, argv, "hab:e:H:s:")) != EOF) { + while ((opt = getopt(argc, argv, "hab:e:H:s:v")) != EOF) { switch (opt) { case 'b': basedn = optarg; @@ -323,6 +349,10 @@ static void usage(void) expression = "(|(objectclass=*)(dn=*))"; break; + case 'v': + verbose++; + break; + case 'h': default: usage(); |