iTP Secure WebServer System Administrator's Guide (iTPWebSvr 5.1+)

Using Common Gateway Interface (CGI) Programs
iTP Secure WebServer System Administrator’s Guide—522659-001
8-29
Customizing the Standard File Environment
Customizing the Standard File Environment
You can use the Stdin, Stdout, and Stderr options to the Server directive to customize the
standard file environment for your CGI program.
For a Pathway CGI application, the CGI library procedures always use the httpd process
in place of standard files, but the application can use the corresponding C or other
language library functions (for example, printf) for access to the files specified by Stdin,
Stdout, and Stderr. For example, the SSC uses the standard output and error files you
specify for error reporting.
CGI Library
A CGI program to be invoked by the generic-CGI server class uses standard functions,
such as C library functions, for access to the standard file environment.
A Pathway CGI application uses the CGI library for access to standard files. Table 8-6
lists and describes the procedures in the CGI library.
Table 8-6. CGI Procedures (page 1 of 3)
Procedure Description
CGI_Capture() This procedure decodes the name/value pairs encoded in form data
returned by the POST request method or in the QUERY_STRING
returned by the GET request method, creates an environment
variable for each name/value pair and sets the value of the variable.
CGI_Capture() may be called in lieu of placing the Region
directive AddCGI AUTOMATIC_FORM_DECODING ON
command in the server’s configuration file.
CGI_feof() This procedure is analogous to the feof() procedure in the C
library: It tests for the end-of-file condition on a specified stream
and returns a nonzero value if it encounters the end-of-file.
CGI_fgets() This procedure is analogous to the fgets() procedure in the C
library. The CGI_fgets() function reads data from the stream
pointed to by the stream parameter into the array pointed to by the
string parameter. Data is read until n-1 bytes have been read, a
newline character is read, or an end-of-file condition is
encountered. The string represented by the data is then terminated
with a NULL character.
CGI_main() This procedure is used as an entry point into a user-written CGI
server class.
CGI_printf() This procedure is analogous to the printf() procedure in the C
library, with one exception: output is passed back to the CGI client
program through the Pathway CGI interface rather than to the
stdout file descriptor.
The maximum size of the write buffer (including expansion of
elements such as integers) is 32000 bytes. If the printf string
exceeds this size, the application terminates with an error message.