The Lambda Lab
/
projects
/
scratchy.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5277988
)
Add shell command record type.
author
Tim Vaughan
<tgvaughan@gmail.com>
Fri, 3 May 2019 10:15:17 +0000
(12:15 +0200)
committer
Tim Vaughan
<tgvaughan@gmail.com>
Fri, 3 May 2019 10:15:17 +0000
(12:15 +0200)
burrow.scm
patch
|
blob
|
history
diff --git
a/burrow.scm
b/burrow.scm
index
899edae
..
c258311
100644
(file)
--- a/
burrow.scm
+++ b/
burrow.scm
@@
-8,7
+8,7
@@
(chicken condition)
(chicken process)
(chicken process-context)
(chicken condition)
(chicken process)
(chicken process-context)
- srfi-13 matchable)
+ srfi-1
srfi-1
3 matchable)
(define gopher-index-file-name "index")
(define gopher-index-file-name "index")
@@
-124,10
+124,17
@@
;;; Index rendering
(define (serve-info-record info-string)
;;; Index rendering
(define (serve-info-record info-string)
- (print "i" info-string "\tfake\tfake\t1\r"))
+ (print* "i")
+ (for-each (lambda (char)
+ (print* (if (eq? char #\tab)
+ " "
+ char)))
+ (string->list info-string))
+ (print "\tfake\tfake\t1\r"))
(define (serve-record record path config)
(match record
(define (serve-record record path config)
(match record
+ (('shell command) (serve-shell-command command))
((type display-string selector host port)
(print type display-string "\t" selector "\t" host "\t" port "\r"))
((type display-string selector host)
((type display-string selector host port)
(print type display-string "\t" selector "\t" host "\t" port "\r"))
((type display-string selector host)
@@
-141,10
+148,13
@@
(serve-record (list (infer-selector-type selector) display-string selector)
path config))
((selector)
(serve-record (list (infer-selector-type selector) display-string selector)
path config))
((selector)
- (serve-record (list (infer-selecto
r
-type selector) selector)
+ (serve-record (list (infer-selecto-type selector) selector)
path config))
(else (error "Unknown record type."))))
path config))
(else (error "Unknown record type."))))
+(define (serve-shell-command command)
+ (let-values (((in-port out-port id) (process command)))
+ (for-each serve-info-record (read-lines in-port))))
;;; main
;;; main
@@
-164,9
+174,9
@@
(run-server (make-server-config root hostname port))
(error "Invalid port argument." port))))))
(run-server (make-server-config root hostname port))
(error "Invalid port argument." port))))))
-
;;
(main)
+(main)
-(define (test)
- (run-server (make-server-config "gopher-root" "localhost" 70)))
+
;;
(define (test)
+
;;
(run-server (make-server-config "gopher-root" "localhost" 70)))
;; (test)
;; (test)