diff options
-rw-r--r-- | source/tdb/tdbtool.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/source/tdb/tdbtool.c b/source/tdb/tdbtool.c index 0e2104f3b04..4400f5d8e03 100644 --- a/source/tdb/tdbtool.c +++ b/source/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; |