X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=scratchy.git;a=blobdiff_plain;f=burrow.scm;h=afdee1281bfd7ca9c4f543fca54a04fd3161ab66;hp=899edae520427f7e092fdf14e2766aa1db903c8c;hb=80b558dda9342206b8aab33bb7b967bfe9fb0553;hpb=52779888899c967898021f835ede56e8efe3d625 diff --git a/burrow.scm b/burrow.scm index 899edae..afdee12 100644 --- a/burrow.scm +++ b/burrow.scm @@ -8,7 +8,7 @@ (chicken condition) (chicken process) (chicken process-context) - srfi-13 matchable) + srfi-1 srfi-13 matchable) (define gopher-index-file-name "index") @@ -124,10 +124,18 @@ ;;; 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 + (('shell command) (serve-shell-command command)) + (('eval expression) (serve-expression expression)) ((type display-string selector host port) (print type display-string "\t" selector "\t" host "\t" port "\r")) ((type display-string selector host) @@ -141,10 +149,17 @@ (serve-record (list (infer-selector-type selector) display-string selector) path config)) ((selector) - (serve-record (list (infer-selector-type selector) selector) + (serve-record (list (infer-selecto-type selector) selector) 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)))) + +(define (serve-expression expression) + (for-each serve-info-record + (string-split (conc (eval expression)) "\n"))) ;;; main