iTP Secure WebServer System Administrators Guide (Version 7.5+)

Table 21 CGI Procedures (continued)
DescriptionProcedure
Only a single alarm signal can be in effect for a process.
If you need to implement a customized alarm function and
still use the fflush timer, write an alarm signal handler that
calls CGI_fflush() when appropriate.
This procedure gets a character from the CGI input stream.
It is the same as the Posix function getc(), but returns the
CGI_getc()
next byte from the CGI input stream specified and moves
the file pointer, if defined, ahead 1 byte in the stream.
This procedure writes a string to the CGI output stream. It
operates in the same way as its Posix equivalent.
CGI_puts()
This stub procedure is called whenever the connection
between the CGI server and the httpd program is broken;
CGI_connection_abort
usually, when the end user at the Web client stops an active
data transfer prior to receiving all the data being sent, or
when there is an internal timeout within the httpd server
itself, in the case where a single connection has existed
longer than its configured lifetime. An internal timeout might
occur if the ScriptTimeout / InputTimeout /OutputTimeout
values are configured. When an internal timeout occurs,
httpd cancels the request, closes the connection, and sends
a termination signal to the CGI process. The CGI library
invokes the CGI_connection_abort procedure to handle
the termination signal.
The intent of a user-coded connection abort routine is to
allow for graceful cleanup of transactions in progress.
This stub procedure is called each time the server comes
up to allow user-written initialization code (such as opening
CGI_initialize()
database files) to be executed at startup time. You must
use this function in order to read environment variables.
(See “Design Guidelines” (page 162).)
This stub procedure is called before the server stops to
allow user-written cleanup code to be executed prior to
process termination.
CGI_terminate
Pathway CGI Coding Considerations
The considerations for coding a Pathway CGI application include requirements for including the
CGI library and design guidelines for the NonStop TS/MP execution environment.
Including the CGI Library
Your application must include the cgilib.h file, illustrated in “Sample cgilib.h File” (page 161). If the
application consists of multiple modules, all except the CGI_main module should precede the
include using this define:
#define _CGI_NO_EXTERNALS
Table 22 Sample cgilib.h File
#ifndef _CGILIB
#define _CGILIB
#ifndef _CGI_NO_EXTERNALS
extern void _MAIN (void);
int *DummyMainPTR = (int *) _MAIN
#endif
size_t CGI_fwrite(const void *buffer,size_t size,size_t num_items,FILE
*stream);
size_t CGI_fread (void *buf, size_t size,size_t num_items,FILE *stream);
char *CGI_fgets(char *, int, FILE * stream);
Pathway CGI Coding Considerations 161