opencgi(), closecgi() - CGI initialization and cleanup

SYNOPSIS

#include "cgi.h"

CGI *opencgi()

CGI *closecgi(cp)
CGI *cp;


DESCRIPTION
The opencgi() function opens and initializes a CGI object. It returns a pointer to a CGI struct, which will be used in subsequent calls to the API. On error, CGIPN is returned.

The CGI struct contains several string variables with information about the current invocation:

char *server_software;    /* httpd server software */
char *server_name;        /* httpd server name */
char *gateway_interface;  /* CGI interface version */
char *server_protocol;    /* HTTP protocol version */
char *server_port;        /* the port this httpd is on */
char *request_method;     /* HTTP request method (GET, POST, etc.) */
char *http_connection;    /* HTTP Connection: header, e.g. Keep-Alive */
char *http_user_agent;    /* HTTP User-Agent: header (browser name) */
char *http_host;          /* HTTP Host: header */
char *http_accept;        /* HTTP Accept: header */
char *http_cookie;        /* HTTP Cookie: header */
char *path_info;          /* path in URL after this script's path */
char *path_translated;    /* path_info as a path in the document tree */
char *script_name;        /* URL path for this CGI program */
char *query_string;       /* the query string in the given URL */
char *remote_host;        /* the remote host (Web client) name */
char *remote_addr;        /* the remote host's IP (decimal string) */
char *remote_user;        /* the remote user, if known */
char *auth_type;          /* authorization type */
char *content_type;       /* HTTP Content-Type: header */
char *content_length;     /* HTTP Content-Length: header */
char *content;            /* `content_length'-size buffer with input */
char *document_root;      /* (file) root of HTML document tree */

These fields are set from the environment (except for content which is read from stdin), as given by the HTTP daemon when invoking the CGI program. Any fields not set by the daemon are set to CHARPN. It is recommended that these fields be checked before the environment is searched (e.g. via getcgi()), as future versions of the API may set these fields in instances where they are not present in the environment.

CGI variables are read and decoded from the URL, content, cookies, etc. during the opencgi() call (and as needed later). The closecgi() function closes the active CGI struct given by cp and frees its associated memory. closecgi() returns CGIPN.


SEE ALSO
getcgi() cgivar()


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.