Listing of show.cgi

#! ../bin/wisp -ce
Content-type: text/html; charset=UTF-8
    ;;;; show.cgi - show a script to a web client
    ;; Copyleft © 2002 by Andres Soolo (
    ;; This file is licensed under the GNU GPL v2.  If you
    ;; don't know what that means, please do read the GPL.
    ;;;; @(#) $Id: show.cgi,v 1.14 2002/08/26 15:34:10 digg Exp $

      cgi unix)

    (define source-name (dict-ref *cgi-query* 'file "show.cgi"))
    (define errors? (make-box #f))
<title>Listing of [: (html-encode source-name) :]</title>
<link rel="stylesheet" href="../wisp.css" type="text/css">
<h1>Listing of [: (html-encode source-name) :]</h1>
|: (if (or (absolute-path? source-name)
           (path-contains-dotdot? source-name))
       (print "<div class=err>Sorry, I can't let you \
              see this file.</div>\n")
       (set! (box-ref errors?) #t))
     (my source-file (try (open-input-file source-name)
                       (except ()
       (if source-file
           (print "<pre class=listing><tt>\n")
           (let (loop)
             (my source-line (read-line source-file)
               (if (not (eof-object? source-line))
                   (print "$,(html-encode source-line)\n")
           (print "</tt></pre>"))
           (print "<div class=err>Sorry, I couldn't \
                  open this file.</div>")
           (set! (box-ref errors?) #t)))))
|: (define identity (if (box-ref errors?) "error message" "listing")) :|
<p>This [: identity :] was generated by a
<a href="">Wisp</a> script. <br>
[: ; It could be done in a better way.
   (if (string=? source-name "show.cgi")
    "See the <a href=\"show.cgi?file=show.cgi\">\
    listing of the lister</a>.<br>") :]
<a href="">Validate</a> this [: identity :].</p>
|: #| vim: set ft=ewisp

This listing was generated by a Wisp script.
Validate this listing.