[SLP-Homepage]    [Source Modules]    [Manual]    [Run]    [Examples]
 

CGI POST Input

This module defines a subclass in_cgi_c of the abstract input stream in_c. In case the super logic program comes from a HTML form, it is read via an object of this class. The input is read from the standard input according to the CGI-specification (for the HTTP POST method).

The input is read into a buffer and decoded during the construction of the object. If there should be errors (e.g. with the environment variables), the method is_open will afterwards return BOOL_FALSE. One should check this before calling read.

CGI input is a sequence of name/value pairs. Currently, only the value associated with the name "program" is used. All other name/value pairs are ignored. Later, when options are needed, other name/value pairs will probably be translated into the correct syntax for options. The goal is that there is no difference between CGI input and file input.


Initialisation and Closing:

in_cgi_c:
in_cgi_c(void);
This constructor reads the posted form data into an input buffer and decodes them. In case something wents wrong, an error message is printed by calling the appropriate method from out_c. Afterwards, it is possible to check with is_open whether the input was successfully read.
close:
bool_t close(void);
This method does nothing for CGI input streams, except setting is_open to false. The method always returns BOOL_TRUE.


Function for Getting Input:

read:
int read(char *buf, int size);
This function copies characters from the internal CGI input buffer (of this object) into the buffer with starting address buf and size size. It returns the number of characters actually read. As long as this is greater than zero, everything is ok. If it is zero, the end of input was reached. No errors can occur during the call to this method. Note that the input in the buffer will not be null-terminated.


Diagnosis Functions:

is_open:
bool_t is_open(void);
This method returns BOOL_TRUE iff the CGI input was successfully read and decoded (and close was not called in the meantime). One should check is_open before calling any of the other functions.
filename:
str_t filename(void);
This method currently returns STR_NIL, because there is no real filename. An alternative (still considered) is "cgi".


Implementation:


Stefan Brass (sbrass@sis.pitt.edu), March 18, 2001.    [HTML 3.2 Checked]