Add expressions for CGI parameter reads
The code for retrieving CGI parameters for both GET and POST is located in src/cgi/cgi_parser.c on the development branch.
cgi_getparams()
will return an array of CgiPairs. CgiPair is defined in inc/cgi/cgi.h (inc/cgi.h is there by mistake and should be removed).
The returned array will always end with one CgiPairs whose key
is null.
For each element in the CGI string, there will be a CgiPair with a value
field pointing to a Data* whose type
field is DATATYPE_STRING.
However, if a CGI string is passed that contains multiple values for a single key, e.g. "?foo=bar&foo=baz," the array of CgiPairs will have a Data* whose type
is DATATYPE_LIST, and each Data* contained by it will be of type DATATYPE_STRING.
We need an expression, probably of the form (cgi "key")
that will return the Data* in the array of CgiPairs that corresponds with the given key. This will be done in an ONPOP function. Instead of passing a pointer directly into the CgiPair, a copy should be made of the CgiPair's value(s). Otherwise, the interpreter may try to free the contents of one of the CgiPairs before runtime has finished, causing a memory bug.