summaryrefslogtreecommitdiff
path: root/appl/cmd/dbm/list.b
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
commit37da2899f40661e3e9631e497da8dc59b971cbd0 (patch)
treecbc6d4680e347d906f5fa7fca73214418741df72 /appl/cmd/dbm/list.b
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'appl/cmd/dbm/list.b')
-rwxr-xr-xappl/cmd/dbm/list.b34
1 files changed, 34 insertions, 0 deletions
diff --git a/appl/cmd/dbm/list.b b/appl/cmd/dbm/list.b
new file mode 100755
index 00000000..6c0e71f5
--- /dev/null
+++ b/appl/cmd/dbm/list.b
@@ -0,0 +1,34 @@
+implement Dbmlist;
+
+include "sys.m";
+ sys: Sys;
+
+include "draw.m";
+
+include "dbm.m";
+ dbm: Dbm;
+ Datum, Dbf: import dbm;
+
+Dbmlist: module
+{
+ init: fn(nil: ref Draw->Context, args: list of string);
+};
+
+init(nil: ref Draw->Context, args: list of string)
+{
+ sys = load Sys Sys->PATH;
+ dbm = load Dbm Dbm->PATH;
+
+ dbm->init();
+
+ args = tl args;
+ db := Dbf.open(hd args, Sys->OREAD);
+ if(db == nil){
+ sys->fprint(sys->fildes(2), "dbm/list: %s: %r\n", hd args);
+ raise "fail:open";
+ }
+ for(key := db.firstkey(); key != nil; key = db.nextkey(key)){
+ d := db.fetch(key);
+ sys->print("%s %s\n", string key, string d);
+ }
+}