iTP Secure WebServer System Administrator's Guide (iTPWebSvr 6.0+)
Using Common Gateway Interface (CGI) Programs
iTP Secure WebServer System Administrator’s Guide—523346-002
8-33
Pathway CGI Coding Considerations
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 Example 8-2. If the
application consists of multiple modules, all except the CGI_main module should
precede the include using the following define:
#define _CGI_NO_EXTERNALS
CGI_initialize() This stub procedure is called each time the server comes up to
allow user-written initialization code (such as opening database
files) to be executed at startup time. You must use this function in
order to read environment variables. (See Design Guidelines
on
page 8-34.)
CGI_terminate This stub procedure is called before the server stops or aborts to
allow user-written cleanup code to be executed prior to process
termination.
Example 8-2. 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);
int CGI_feof(FILE * stream);
int CGI_printf(const char *format, ...);
int CGI_getc(FILE * stream);
int CGI_puts(const char *buffer);
int CGI_main(int argc, char *argv[]);
void ErrorAbort(void);
void CGI_connection_abort(void);
void CGI_initialize(void);
void CGI_terminate(void);
int CGI_fflush(FILE * stream);
int CGI_set_fflush_timer(int seconds);
void CGI_Capture(void);
#endif /* CGILIB */
Table 8-6. CGI Procedures (page 3 of 3)
Procedure Description