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 (digg@users.sf.net)
    ;; 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 $

    (use
      cgi unix)

    (define source-name (dict-ref *cgi-query* 'file "show.cgi"))
    (define errors? (make-box #f))
:|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Listing of [: (html-encode source-name) :]</title>
<link rel="stylesheet" href="../wisp.css" type="text/css">
</head>
<body>
<h1>Listing of [: (html-encode source-name) :]</h1>
<hr>
|: (if (or (absolute-path? source-name)
           (path-contains-dotdot? source-name))
     (begin
       (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 ()
                         '#f))
       (if source-file
         (begin
           (print "<pre class=listing><tt>\n")
           (let (loop)
             (my source-line (read-line source-file)
               (if (not (eof-object? source-line))
                 (begin
                   (print "$,(html-encode source-line)\n")
                   (loop)))))
           (print "</tt></pre>"))
         (begin
           (print "<div class=err>Sorry, I couldn't \
                  open this file.</div>")
           (set! (box-ref errors?) #t)))))
:|
<hr>
|: (define identity (if (box-ref errors?) "error message" "listing")) :|
<p>This [: identity :] was generated by a
<a href="http://wisp.sourceforge.net/">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="http://validator.w3.org/check/referer">Validate</a> this [: identity :].</p>
</body>
</html>
|: #| vim: set ft=ewisp

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