Added standard shell command thing using '!' as first character.
authorTim Potter <tpot@samba.org>
Mon, 13 Mar 2000 01:32:48 +0000 (01:32 +0000)
committerTim Potter <tpot@samba.org>
Mon, 13 Mar 2000 01:32:48 +0000 (01:32 +0000)
source/tdb/tdbtool.c

index 317ad9b4fc5a53c69c796e7517671183230c25bb..55a58c1d5d4ac91923aacd96cc5a6625c193cf83 100644 (file)
@@ -178,46 +178,54 @@ static int do_delete_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf,
 
 int main(int argc, char *argv[])
 {
-       char *line;
-       char *tok;
+    char *line;
+    char *tok;
        
-       while ((line=getline("tdb> "))) {
-               tok = strtok(line," ");
-               if (strcmp(tok,"create") == 0) {
-                       create_tdb();
-                       continue;
-               } else if (strcmp(tok,"open") == 0) {
-                       open_tdb();
-                       continue;
-               }
-
-               /* all the rest require a open database */
-               if (!tdb) {
-                       terror("database not open");
-                       help();
-                       continue;
-               }
-
-               if (strcmp(tok,"insert") == 0) {
-                       insert_tdb();
-               } else if (strcmp(tok,"store") == 0) {
-                       store_tdb();
-               } else if (strcmp(tok,"show") == 0) {
-                       show_tdb();
-               } else if (strcmp(tok,"erase") == 0) {
-                       tdb_traverse(tdb, do_delete_fn, NULL);
-               } else if (strcmp(tok,"delete") == 0) {
-                       delete_tdb();
-               } else if (strcmp(tok,"dump") == 0) {
-                       tdb_traverse(tdb, print_rec, NULL);
-               } else if (strcmp(tok,"info") == 0) {
-                       info_tdb();
-               } else {
-                       help();
-               }
-       }
-
-       if (tdb) tdb_close(tdb);
-
-       return 0;
+    while ((line = getline("tdb> "))) {
+
+        /* Shell command */
+        
+        if (line[0] == '!') {
+            system(line + 1);
+            continue;
+        }
+        
+        tok = strtok(line," ");
+        if (strcmp(tok,"create") == 0) {
+            create_tdb();
+            continue;
+        } else if (strcmp(tok,"open") == 0) {
+            open_tdb();
+            continue;
+        }
+            
+        /* all the rest require a open database */
+        if (!tdb) {
+            terror("database not open");
+            help();
+            continue;
+        }
+            
+        if (strcmp(tok,"insert") == 0) {
+            insert_tdb();
+        } else if (strcmp(tok,"store") == 0) {
+            store_tdb();
+        } else if (strcmp(tok,"show") == 0) {
+            show_tdb();
+        } else if (strcmp(tok,"erase") == 0) {
+            tdb_traverse(tdb, do_delete_fn, NULL);
+        } else if (strcmp(tok,"delete") == 0) {
+            delete_tdb();
+        } else if (strcmp(tok,"dump") == 0) {
+            tdb_traverse(tdb, print_rec, NULL);
+        } else if (strcmp(tok,"info") == 0) {
+            info_tdb();
+        } else {
+            help();
+        }
+    }
+
+    if (tdb) tdb_close(tdb);
+
+    return 0;
 }