summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2000-03-13 01:32:48 +0000
committerTim Potter <tpot@samba.org>2000-03-13 01:32:48 +0000
commit74261cbab05c2fff7b5248338538b52d8b58d991 (patch)
treea2adc5c32c1f820f7ee0ef00f2bdd0eeb21d77fe
parent2fac7ee8856536564f415e69ba5d01ddd4d21bff (diff)
downloadsamba-74261cbab05c2fff7b5248338538b52d8b58d991.tar.gz
samba-74261cbab05c2fff7b5248338538b52d8b58d991.tar.xz
samba-74261cbab05c2fff7b5248338538b52d8b58d991.zip
Added standard shell command thing using '!' as first character.
-rw-r--r--source/tdb/tdbtool.c90
1 files changed, 49 insertions, 41 deletions
diff --git a/source/tdb/tdbtool.c b/source/tdb/tdbtool.c
index 317ad9b4fc5..55a58c1d5d4 100644
--- a/source/tdb/tdbtool.c
+++ b/source/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;
}