From a6f31d68777c2b426f99317390c92b2951b4fa6a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 Oct 2000 22:19:34 +0000 Subject: Fixes from Damian at Cisco to tidy up some tdbtool issues. Jeremy. (This used to be commit 623bfa6c935e2e3acb3145bfbd490758b34d2c70) --- source3/tdb/tdbtool.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'source3/tdb') diff --git a/source3/tdb/tdbtool.c b/source3/tdb/tdbtool.c index 0e2104f3b0..4400f5d8e0 100644 --- a/source3/tdb/tdbtool.c +++ b/source3/tdb/tdbtool.c @@ -14,6 +14,7 @@ static TDB_CONTEXT *tdb; +static int print_rec(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state); static void print_asc(unsigned char *buf,int len) { @@ -150,11 +151,12 @@ static void show_tdb(void) } key.dptr = k; - key.dsize = strlen(k); + key.dsize = strlen(k)+1; dbuf = tdb_fetch(tdb, key); if (!dbuf.dptr) terror("fetch failed"); - printf("%s : %*.*s\n", k, (int)dbuf.dsize, (int)dbuf.dsize, dbuf.dptr); + /* printf("%s : %*.*s\n", k, (int)dbuf.dsize, (int)dbuf.dsize, dbuf.dptr); */ + print_rec(tdb, key, dbuf, NULL); } static void delete_tdb(void) @@ -222,7 +224,14 @@ int main(int argc, char *argv[]) { char *line; char *tok; - + + if (argv[1]) { + static char tmp[1024]; + sprintf(tmp, "open %s", argv[1]); + tok=strtok(tmp," "); + open_tdb(); + } + while ((line = getline("tdb> "))) { /* Shell command */ @@ -232,7 +241,9 @@ int main(int argc, char *argv[]) continue; } - tok = strtok(line," "); + if ((tok = strtok(line," "))==NULL) { + continue; + } if (strcmp(tok,"create") == 0) { create_tdb(); continue; -- cgit