diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /appl/cmd/dbm/fetch.b | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'appl/cmd/dbm/fetch.b')
| -rwxr-xr-x | appl/cmd/dbm/fetch.b | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/appl/cmd/dbm/fetch.b b/appl/cmd/dbm/fetch.b new file mode 100755 index 00000000..3ebbc7d6 --- /dev/null +++ b/appl/cmd/dbm/fetch.b @@ -0,0 +1,37 @@ +implement Dbmfetch; + +include "sys.m"; + sys: Sys; + +include "draw.m"; + +include "dbm.m"; + dbm: Dbm; + Datum, Dbf: import dbm; + +Dbmfetch: 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/fetch: %s: %r\n", hd args); + raise "fail:open"; + } + args = tl args; + key := hd args; + data := db.fetch(array of byte key); + if(data == nil) + sys->fprint(sys->fildes(2), "not found\n"); + else + sys->write(sys->fildes(1), data, len data); +} |
