Artifact
0ba1c89f4891f22eae09557ae2b3e6616e1cb67d:
0000: 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 32 30 30 ;; Copyright 200
0010: 36 2d 32 30 31 31 2c 20 4d 61 74 74 68 65 77 20 6-2011, Matthew
0020: 57 65 6c 6c 61 6e 64 2e 0a 3b 3b 20 0a 3b 3b 20 Welland..;; .;;
0030: 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 This program is
0040: 20 6d 61 64 65 20 61 76 61 69 6c 61 62 6c 65 20 made available
0050: 75 6e 64 65 72 20 74 68 65 20 47 4e 55 20 47 50 under the GNU GP
0060: 4c 20 76 65 72 73 69 6f 6e 20 32 2e 30 20 6f 72 L version 2.0 or
0070: 0a 3b 3b 20 20 67 72 65 61 74 65 72 2e 20 53 65 .;; greater. Se
0080: 65 20 74 68 65 20 61 63 63 6f 6d 70 61 6e 79 69 e the accompanyi
0090: 6e 67 20 66 69 6c 65 20 43 4f 50 59 49 4e 47 20 ng file COPYING
00a0: 66 6f 72 20 64 65 74 61 69 6c 73 2e 0a 3b 3b 20 for details..;;
00b0: 0a 3b 3b 20 20 54 68 69 73 20 70 72 6f 67 72 61 .;; This progra
00c0: 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65 64 m is distributed
00d0: 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41 52 WITHOUT ANY WAR
00e0: 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20 65 RANTY; without e
00f0: 76 65 6e 20 74 68 65 0a 3b 3b 20 20 69 6d 70 6c ven the.;; impl
0100: 69 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 20 ied warranty of
0110: 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59 20 MERCHANTABILITY
0120: 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20 41 or FITNESS FOR A
0130: 20 50 41 52 54 49 43 55 4c 41 52 0a 3b 3b 20 20 PARTICULAR.;;
0140: 50 55 52 50 4f 53 45 2e 0a 0a 3b 3b 20 54 68 69 PURPOSE...;; Thi
0150: 73 20 69 73 20 66 72 6f 6d 20 74 68 65 20 70 65 s is from the pe
0160: 72 6c 20 77 6f 72 6c 64 2c 20 61 20 68 61 73 68 rl world, a hash
0170: 20 6f 66 20 68 61 73 68 65 73 20 69 73 20 61 20 of hashes is a
0180: 73 75 70 65 72 20 65 61 73 79 20 77 61 79 20 74 super easy way t
0190: 6f 20 6b 65 65 70 20 61 20 68 61 6e 64 6c 65 20 o keep a handle
01a0: 6f 6e 0a 3b 3b 20 6c 6f 74 73 20 6f 66 20 64 69 on.;; lots of di
01b0: 73 70 61 72 61 74 65 20 64 61 74 61 0a 3b 3b 0a sparate data.;;.
01c0: 0a 28 64 65 63 6c 61 72 65 20 28 75 6e 69 74 20 .(declare (unit
01d0: 6d 74 74 6f 70 29 29 0a 0a 28 6d 6f 64 75 6c 65 mttop))..(module
01e0: 20 6d 74 74 6f 70 0a 20 20 20 20 2a 0a 0a 28 69 mttop. *..(i
01f0: 6d 70 6f 72 74 20 63 68 69 63 6b 65 6e 20 73 63 mport chicken sc
0200: 68 65 6d 65 0a 09 3b 3b 20 64 61 74 61 2d 73 74 heme..;; data-st
0210: 72 75 63 74 75 72 65 73 20 70 6f 73 69 78 0a 09 ructures posix..
0220: 73 72 66 69 2d 31 0a 09 3b 3b 20 73 72 66 69 2d srfi-1..;; srfi-
0230: 31 33 0a 09 73 72 66 69 2d 36 39 0a 09 70 6f 72 13..srfi-69..por
0240: 74 73 0a 09 65 78 74 72 61 73 0a 09 72 65 67 65 ts..extras..rege
0250: 78 0a 09 70 6f 73 69 78 0a 09 64 61 74 61 2d 73 x..posix..data-s
0260: 74 72 75 63 74 75 72 65 73 0a 09 6d 61 74 63 68 tructures..match
0270: 61 62 6c 65 0a 09 29 0a 0a 28 64 65 66 69 6e 65 able..)..(define
0280: 20 28 73 74 72 2d 69 73 2d 63 6d 64 20 63 6d 64 (str-is-cmd cmd
0290: 20 61 6c 6c 2d 63 6d 64 73 29 0a 20 20 28 6c 65 all-cmds). (le
02a0: 74 2a 20 28 28 72 78 20 20 28 72 65 67 65 78 70 t* ((rx (regexp
02b0: 20 28 63 6f 6e 63 20 22 5e 22 20 63 6d 64 20 22 (conc "^" cmd "
02c0: 2e 2a 22 29 29 29 0a 09 20 28 6d 78 20 20 28 66 .*"))).. (mx (f
02d0: 69 6c 74 65 72 20 73 74 72 69 6e 67 3f 20 28 6d ilter string? (m
02e0: 61 70 20 28 6c 61 6d 62 64 61 20 28 78 29 0a 09 ap (lambda (x)..
02f0: 09 09 09 20 20 20 20 20 28 6c 65 74 20 28 28 72 ... (let ((r
0300: 65 73 20 28 73 74 72 69 6e 67 2d 6d 61 74 63 68 es (string-match
0310: 20 72 78 20 78 29 29 29 0a 09 09 09 09 20 20 20 rx x))).....
0320: 20 20 20 20 28 69 66 20 72 65 73 20 28 63 61 72 (if res (car
0330: 20 72 65 73 29 20 23 66 29 29 29 0a 09 09 09 09 res) #f))).....
0340: 20 20 20 61 6c 6c 2d 63 6d 64 73 29 29 29 29 0a all-cmds)))).
0350: 20 20 20 20 28 69 66 20 28 65 71 3f 20 28 6c 65 (if (eq? (le
0360: 6e 67 74 68 20 6d 78 29 20 31 29 20 3b 3b 20 68 ngth mx) 1) ;; h
0370: 61 76 65 20 61 20 63 6f 6d 6d 61 6e 64 0a 09 28 ave a command..(
0380: 63 61 72 20 6d 78 29 0a 09 23 66 29 29 29 0a 0a car mx)..#f)))..
0390: 28 64 65 66 69 6e 65 20 28 6d 74 74 6f 70 2d 72 (define (mttop-r
03a0: 75 6e 20 61 72 67 73 20 61 6c 6c 2d 63 6d 64 73 un args all-cmds
03b0: 29 0a 20 20 3b 3b 20 61 6e 79 20 70 61 74 68 20 ). ;; any path
03c0: 74 68 72 6f 75 67 68 20 74 68 69 73 20 63 61 6c through this cal
03d0: 6c 20 6d 75 73 74 20 65 6e 64 20 69 6e 20 65 78 l must end in ex
03e0: 69 74 20 69 66 20 69 74 20 69 73 20 4e 4f 54 20 it if it is NOT
03f0: 61 6e 20 6f 6c 64 20 4d 65 67 61 74 65 73 74 20 an old Megatest
0400: 63 61 6c 6c 0a 20 20 28 69 66 20 28 6e 75 6c 6c call. (if (null
0410: 3f 20 61 72 67 73 29 0a 20 20 20 20 20 20 23 66 ? args). #f
0420: 20 3b 3b 20 63 6f 6e 74 69 6e 75 65 20 6f 6e 20 ;; continue on
0430: 61 6e 64 20 64 6f 20 74 68 65 20 6f 6c 64 20 4d and do the old M
0440: 65 67 61 74 65 73 74 20 73 74 75 66 66 0a 20 20 egatest stuff.
0450: 20 20 20 20 28 6c 65 74 20 28 28 63 6d 64 20 28 (let ((cmd (
0460: 73 74 72 2d 69 73 2d 63 6d 64 20 28 63 61 72 20 str-is-cmd (car
0470: 61 72 67 73 29 20 61 6c 6c 2d 63 6d 64 73 29 29 args) all-cmds))
0480: 29 0a 09 28 69 66 20 63 6d 64 0a 09 20 20 20 20 )..(if cmd..
0490: 28 62 65 67 69 6e 0a 09 20 20 20 20 20 20 28 63 (begin.. (c
04a0: 61 73 65 20 28 73 74 72 69 6e 67 2d 3e 73 79 6d ase (string->sym
04b0: 62 6f 6c 20 63 6d 64 29 0a 09 09 28 28 68 65 6c bol cmd)...((hel
04c0: 70 29 28 70 72 69 6e 74 20 22 4e 65 77 20 68 65 p)(print "New he
04d0: 6c 70 22 29 29 0a 09 09 28 65 6c 73 65 20 28 70 lp"))...(else (p
04e0: 72 69 6e 74 20 22 43 6f 6d 6d 61 6e 64 20 22 20 rint "Command "
04f0: 63 6d 64 20 22 20 69 73 20 6e 6f 74 20 69 6d 70 cmd " is not imp
0500: 6c 65 6d 65 6e 74 65 64 20 79 65 74 2e 22 29 29 lemented yet."))
0510: 29 0a 09 20 20 20 20 20 20 28 65 78 69 74 29 29 ).. (exit))
0520: 20 3b 3b 20 61 6c 77 61 79 73 20 65 78 69 74 20 ;; always exit
0530: 68 65 72 65 0a 09 20 20 20 20 23 66 29 29 29 29 here.. #f))))
0540: 20 20 20 20 3b 3b 20 6f 72 20 63 6f 6e 74 69 6e ;; or contin
0550: 75 65 20 6f 6e 20 74 6f 20 4d 65 67 61 74 65 73 ue on to Megates
0560: 74 20 6f 6c 64 20 73 74 75 66 66 20 68 65 72 65 t old stuff here
0570: 0a 20 20 0a 29 0a . .).