| |||||||||||
| |||||||||||
|
Sample input string: cgiinp01=George&cgiinp02=Brown
Once a CGI has read the input string sent from the remote
browser, it must understand what the request is.
To do this there must be some routine that scans
the input (query) string for all the possible keywords
and saves their values into program variables,
so that the program may then test them and process the
user request. This scan_and_break operation
is commonly referrred to as "parsing".
In Mel's service program there are three ways you can perform parsing:
1. "cvtDB" parsing procedure
(for input string read via
getInput procedure)
Parsing procedure CvtDb
uses QtmhCvtDb API.
This API moves the values of the input string keywords
into omonymous fields of an externally defined data structure.
Basically, what you have to do is
For a complete example see the source of program
TEMPLATE.
However you do not have to type in this code. To read the input string and parse it into the externally described data structure, just include our prolog1 member as follow:
For a complete example, please see the source of the
hello1 program.
Important to be read We have some tips for optimum use of an external DS.
2. cgiVarVal parsing procedure
(for input string read via
getInput procedure)
Parsing procedure cgivarval
lets you retrieve fields from the input string
one at a time into program-defined fields.
Example:
For a complete example see the source of program
TEMPLATE2.
3. "zhbGetVar" parsing procedure
(for input string read via
ZhbGetInput procedure)
Parsing procedure zhbgetvar
lets you retrieve fields from the input string
one at a time into program-defined fields.If you want to uppercase a field while retrieving it from the input string, you may use the parsing procedure zhbgetvarupper. Example:
For a complete example see the source of program
TEMPLATE3.
3. "zhbGetVarPtr" parsing procedure
(for input string read via
ZhbGetInput procedure)
Parsing procedure zhbgetvarptr
returns a pointer to an input variable.
This is useful when an input variable's length might exceed
ZhbGetVar's maximum size of 32767.The maximum length of such a variable is 64000. If the input variable is not found or length is 0, returns *null . Example:
Note. Do not use this subprocedure for reading a file being uploaded from the browser. Instead, use Giovanni Perotti's FUPLOAD utility (see http://www-922.ibm.com/easy400h/fupload.htm)
|