summaryrefslogtreecommitdiff
path: root/source3/tdb
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2000-03-13 01:35:09 +0000
committerTim Potter <tpot@samba.org>2000-03-13 01:35:09 +0000
commit3848759a5e48a142c3fc96beeedbddc8f582da97 (patch)
tree0567876dd23f57b0a4a936b16f602769d421b96d /source3/tdb
parent741dfefd565dbcd9ec8a861ebe3a7e6c0e80eac1 (diff)
downloadsamba-3848759a5e48a142c3fc96beeedbddc8f582da97.tar.gz
samba-3848759a5e48a142c3fc96beeedbddc8f582da97.tar.bz2
samba-3848759a5e48a142c3fc96beeedbddc8f582da97.zip
Added standard shell command thing using '!' as first character.
(This used to be commit 829e645f62ffa16041c0cc126174d6fe8f63a2f0)
Diffstat (limited to 'source3/tdb')
-rw-r--r--source3/tdb/tdbtool.c90
1 files 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;
}