/usr/share/elk/gdbmtest.scm is in elk 3.99.8-4.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | ;;; -*-Scheme-*-
;;;
;;; An interactive command loop for testing the GNU gdbm extension.
;;; Contributed by Martin Stut.
(require 'gdbm.la)
(let ((gf (gdbm-open 'test.gdbm 1024 'create)) (last "nothing"))
(if (not gf)
(error 'gdbm-open "cannot open test.gdbm"))
(format #t "Type ? for help~%")
(let loop ((op (read-char)))
(newline)
(if (not (char=? op #\newline))
(read-string)) ; flush rest of line
(case op
((#\? #\h)
(format #t "c -- count items~%")
(format #t "d -- delete item~%")
(format #t "f -- fetch item~%")
(format #t "s -- store item~%")
(format #t "n -- next key~%")
(format #t "1 -- first key~%")
(format #t "2 -- next key of last n, 1, or 2~%")
(format #t "r -- reorganize~%")
(format #t "q -- quit~%"))
(#\c
(do ((i 0 (1+ i))
(x (gdbm-firstkey gf) (gdbm-nextkey gf x)))
((not x) (format #t "Number of entries: ~s~%" i))))
(#\d
(display "Key: ")
(if (gdbm-delete gf (read-string))
(format #t "Deleted.~%")
(format #t "Doesn't exist.~%")))
(#\f
(display "Key: ")
((lambda (d)
(if d
(format #t "Data: ~s~%" d)
(format #t "Doesn't exist.~%")))
(gdbm-fetch gf (read-string))))
(#\s
(display "Key: ")
((lambda (k)
(display "Data: ")
(if (= 1 (gdbm-store gf k (read-string) 'insert))
(format #t "Already there.~%")
(format #t "Inserted.~%")))
(read-string)))
(#\n
(display "Key: ")
((lambda (r)
(if r
(begin
(format #t "Next: ~s Data: ~s~%" r (gdbm-fetch gf r))
(set! last r))
(print #f)))
(gdbm-nextkey gf (read-string))))
(#\1
((lambda (r)
(if r
(begin
(format #t "First: ~s Data: ~s~%" r (gdbm-fetch gf r))
(set! last r))
(print #f)))
(gdbm-firstkey gf)))
(#\2
((lambda (r)
(if r
(begin
(format #t "Next: ~s Data: ~s~%" r (gdbm-fetch gf r))
(set! last r))
(print #f)))
(gdbm-nextkey gf last)))
(#\r
(gdbm-reorganize gf)
(format #t "Reorganized.~%"))
(#\q
(exit)))
(loop (read-char))))
|