From 3848759a5e48a142c3fc96beeedbddc8f582da97 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 13 Mar 2000 01:35:09 +0000 Subject: Added standard shell command thing using '!' as first character. (This used to be commit 829e645f62ffa16041c0cc126174d6fe8f63a2f0) --- source3/tdb/tdbtool.c | 90 ++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/source3/tdb/tdbtool.c b/source3/tdb/tdbtool.c index 317ad9b4fc..55a58c1d5d 100644 --- a/source3/tdb/tdbtool.c +++ b/source3/tdb/tdbtool.c @@ -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; } -- cgit