This module defines basic CGI processing tools for processing
CGI GET and POST requests and cookies.

Include this file at the beginning of each file performing CGI processing using
either one of the following lines:

(load "/usr/share/newlisp/cgi.lsp")
; or as a shorter alternative
(module "cgi.lsp")

Overview

On loading cgi.lsp will retrieve GET, POST and cookie
parameters via standard input and the environment variables:
QUERY_STRING and HTTP_COOKIE. These environment variables are set
by the webserver (tested with Apache 1.3). The webserver is receiving information
back from cgi.lsp via std I/O channels.

After having loaded this file all parameters from either GET or POST
method are stored as an association list and in CGI:params
and individual parameters can be accessed using CGI:get.

All cookies can be accessed in an association list CGI:cookies and
are accessed similar to the GET and PUT parameters using CGI:get-cookie.
A function CGI:set-cookie is available for setting cookies.

The function CGI:put-page outputs a HTML page to the webserver after
processing newLISP source embedded in <% and %> tags.

CGI:params and CGI:cookies contain the empty list () when no
parameters or cookies are present

The function CGI:put-page can be used to output web pages containing
newLISP source embedded in <%, %> tags. Inside these tags are newLISP
statements printing output/HTML to the webpage.

CGI:url-translate

Translates all URL formatted characters to ASCII. Translates '+' into spaces
and %nn hexdigits into characters. nn is a 2-nibble hex number.

Example:

(CGI:url-translate "What+time+is+it%3f") => "What time is it?"

§

CGI:set-cookie

syntax: (CGI:set-cookiestr-varstr-valuestr-domainstr-path)parameter: str-var - The cookie variable name as a string.parameter: str-value - The cookie value as a string.parameter: str-domain - The domain where to set the cookie.parameter: str-path - The path for the domain.

return: The string sent to standard out by CGI:set-cookie.

This function should be called immedeately before
closing the header with (print "Content-Type: text/html\r\n\r\n"),
which is typically the first statement in a CGI script written in
newLISP after the (module "cgi.lsp") statement.