Main Page | Namespace List | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

Handles capturing CGI data to be used for debugging. More...


Functions

void Initialize (int argc, char *argv[], char *env[], char *inCaptureFile)
 decide if we're using old data or stashing new data
std::string GetEnvironmentVariable (const std::string &inName)
 return an environment variable
std::string GetStandardInput ()
 return the standard input


Detailed Description

Handles capturing CGI data to be used for debugging.

Strategy is to send the CGI request to Monsterwork's echo (the sample program built by the Monsterworks code). This will create a capture file containing data from the request (standard input and environment variables). Then move this file to some test directory (since it will be clobbered the next time echo is run).

Create a debugging build of you CGI application including the NCapture::Initialize() function as the first call in main(). Launch your CGI application from the command line passing the name of the captured data file as the first argument.

After you have debugged your CGI application, remove the call to NCapture::Initialize() or use the preprocessor to eliminate it.

Notice that NCapture does add some extra overhead, if this concerns you, you could write an NCapture.h header that could be used for deployment builds. It should simply provide inline accessors to getenv() and the cin.operator>>() methods.


Function Documentation

std::string monsterworks::cgi::NCapture::GetEnvironmentVariable const std::string &  inName  ) 
 

return an environment variable

This method currently assumes that useOldData = false.

Returns:
the value of the environment variable or the empty string if the variable is not set.
Parameters:
inName  the name of the variable whose value is to be returned
Definition at line 90 of file NCapture.cp.

Referenced by monsterworks::cgi::NEnvironment::GetValue().

std::string monsterworks::cgi::NCapture::GetStandardInput  ) 
 

return the standard input

This method currently assumes that useOldData = false.

Returns:
the value of std::cin in the form of a string.
Definition at line 105 of file NCapture.cp.

References ourStandardInput.

Referenced by NFormInitialize().

void monsterworks::cgi::NCapture::Initialize int  argc,
char *  argv[],
char *  env[],
char *  inCaptureFile
 

decide if we're using old data or stashing new data

Initializes the NCapture namespace. If you intend to either capture CGI information to a file or read CGI information from a file, you will need to call this function in main() before accessing any of the monsterworks::cgi functions or std::cin.

This determines whether we are reading data in or writing data out based on whether the cgi application was launched with an argument (which will be the file to read) or not.

Parameters:
argc  the number of arguments
argv  the arguments
env  the environment variables
inCaptureFile  the file to store the data
Definition at line 61 of file NCapture.cp.

References useOldData, and WriteData().


monsterworks Code by Monsterworks. Made available under the GNU Public License.
Documentation by doxygen.