3
;;; An interactive command loop for testing the GNU gdbm extension.
4
;;; Contributed by Martin Stut.
9
(let ((gf (gdbm-open 'test.gdbm 1024 'create)) (last "nothing"))
11
(error 'gdbm-open "cannot open test.gdbm"))
12
(format #t "Type ? for help~%")
13
(let loop ((op (read-char)))
15
(if (not (char=? op #\newline))
16
(read-string)) ; flush rest of line
19
(format #t "c -- count items~%")
20
(format #t "d -- delete item~%")
21
(format #t "f -- fetch item~%")
22
(format #t "s -- store item~%")
23
(format #t "n -- next key~%")
24
(format #t "1 -- first key~%")
25
(format #t "2 -- next key of last n, 1, or 2~%")
26
(format #t "r -- reorganize~%")
27
(format #t "q -- quit~%"))
30
(x (gdbm-firstkey gf) (gdbm-nextkey gf x)))
31
((not x) (format #t "Number of entries: ~s~%" i))))
34
(if (gdbm-delete gf (read-string))
35
(format #t "Deleted.~%")
36
(format #t "Doesn't exist.~%")))
41
(format #t "Data: ~s~%" d)
42
(format #t "Doesn't exist.~%")))
43
(gdbm-fetch gf (read-string))))
48
(if (= 1 (gdbm-store gf k (read-string) 'insert))
49
(format #t "Already there.~%")
50
(format #t "Inserted.~%")))
57
(format #t "Next: ~s Data: ~s~%" r (gdbm-fetch gf r))
60
(gdbm-nextkey gf (read-string))))
65
(format #t "First: ~s Data: ~s~%" r (gdbm-fetch gf r))
73
(format #t "Next: ~s Data: ~s~%" r (gdbm-fetch gf r))
76
(gdbm-nextkey gf last)))
79
(format #t "Reorganized.~%"))