/*=========================================================================== * * File: DL_CGI.H * Author: Dave Humphrey (uesp@m0use.net) * Created On: Wednesday, May 09, 2001 * * Contains definitions for general CGI related functions. * *=========================================================================*/ #ifndef __DL_CGI_H #define __DL_CGI_H /*=========================================================================== * * Begin Required Includes * *=========================================================================*/ #include "dl_base.h" #include "dl_mem.h" #include "dl_err.h" #include "goutput.h" /*=========================================================================== * End of Required Includes *=========================================================================*/ /*=========================================================================== * * Begin Definitions * *=========================================================================*/ /* HTTP related environment variable names */ #define HTTP_REFERER_ENV "HTTP_REFERER" #define HTTP_CONTENTTYPE_ENV "CONTENT_TYPE" #define HTTP_CONTENTLENGTH_ENV "CONTENT_LENGTH" #define HTTP_QUERYSTRING_ENV "QUERY_STRING" /* HTTP related environment variable values */ #define HTTP_POST_CONTENTTYPE_VALUE "application/x-www-form-urlencoded" /*=========================================================================== * End of Definitions *=========================================================================*/ /*=========================================================================== * * Begin Type and Structure Definitions * *=========================================================================*/ /* Return values for the cgiCheckReferer() function */ typedef enum { CGI_REFERER_BAD = -1, CGI_REFERER_OK = 0, CGI_REFERER_ERROR = 1 } cgireferer_t; /* Structure used by the cgiErrorOutputFunc() */ typedef struct { const char* pString; va_list Args; } erroroutput_userdata_t; /*=========================================================================== * End of Type and Structure Definitions *=========================================================================*/ /*=========================================================================== * * Begin Function Prototypes * *=========================================================================*/ /* Check the referers environment variable */ cgireferer_t cgiCheckReferers (const char* pValidReferersFile); /* User output function for outputting formatted error pages */ boolean cgiErrorOutputFunc (const COutputFormat& Format, FILE* pOutputFile, void* pUserData); /* Outputs an error page to stdout */ void cgiOutputError (const char* pFilename, const char* pString, ...); /* Outputs a simple HTML page with error message */ void cgiOutputErrorPage (const char* pString, ...); void cgiOutputErrorPageV (const char* pString, va_list Args); /* Outputs an HTML page to stdout, parsing any '%' variables */ boolean cgiOutputHTML (const char* pFilename, PUSER_OUTPUT_FUNC UserFunction, void* pUserData); /* Outputs a HTML header to stdout */ void cgiOutputHTMLHeader (void); /* Outputs a redirect request to stdout */ void cgiOutputRedirect (const char* pWebSite); /* Parse a Hex code from form output */ boolean cgiParseFormHexCode (char& OutputChar, char** ppString); /* Unwebifies output from CGI forms to a regular ASCII string */ boolean cgiUnWebFormOutput (char* pString); /*=========================================================================== * End of Function Prototypes *=========================================================================*/ /*=========================================================================== * * Begin Test Function Prototypes * *=========================================================================*/ #if defined(_DEBUG) void Test_cgiOutputHTML (void); void Test_cgiParseFormHexCode (void); void Test_cgiUnWebFormOutput (void); void Test_DL_Cgi (void); #endif /*=========================================================================== * End of Test Function Prototypes *=========================================================================*/ #endif /*=========================================================================== * End of File DL_CGI.H *=========================================================================*/