contents

intro
overview
requirements
cgi basics

dyno cgi
cgi headers
cgi parameters
accessing files
pipe basics
substitution basics
more substitution
table substitution

Dyno CGI: Accessing Parameters

Probably the very first thing you'll need to do in a CGI is access the parameters that the browser sent to the CGI. As discussed earlier, Dyno CGI handles GET and POST method types the same way. It gets the input data from the correct location, parses and decodes it, and builds a list of input variables for you.

You simply need to create a VariableList object and initialize it from the CGI input. You can create the object on the stack as an automatic variable, or you can use new to create it on the heap. On the stack:

VariableList variables;
variables.LoadFromCGIInput();

On the heap:

VariableList* variables = new VariableList();
variables->LoadFromCGIInput();

Voila. The input has been parsed and broken into variables.

Actually, if you find it more convenient, you can use the Dyno CGI function ParseInput() to create a heap based VariableList and load it from input all in one step, i.e.,

VariableList* variables = ParseInput();

If you want to get the value of a parameter, just call char* VariableList::GetVariablePtr(char* variableName), for example:

char* somevalue = variables.GetVariableData("somevariable");

If an input variable named "somevariable" exists, your string pointer will point to its value. If it does not exist, it will be an empty string (not null). This usually just makes life easier since you don't have to keep checking for a null string pointer.

If you really need to differentiate between an empty string and a non-existent parameter, you can call VariableList::GetVariablePtr(char* variableName) instead of VariableList::GetVariableData(char* variableName). It will return null if the parameter does not exist, or a pointer to its object if it does. The object is of type Variable.

Example

See the Example01 program. It simply gets the variables and calls VariableList::PrintVariables() to print them out.