Fixes from Damian at Cisco to tidy up some tdbtool issues.
authorJeremy Allison <jra@samba.org>
Thu, 5 Oct 2000 22:19:34 +0000 (22:19 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 5 Oct 2000 22:19:34 +0000 (22:19 +0000)
Jeremy.
(This used to be commit 623bfa6c935e2e3acb3145bfbd490758b34d2c70)

source3/tdb/tdbtool.c

index 0e2104f3b04310aedd3546bc57adcb32e338a84d..4400f5d8e0339f9515e109d5980f9ae5b230318e 100644 (file)
@@ -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;