CGIDEV2 Library Change History **************************************************** **** Changes made in version 2008-04-16 10:58:00 *** **** by Giovanni B. Perotti *** **************************************************** - Member QRPGLESRC/XXXWRKHTML A new version of this member incorporates a change suggested to the Easy400Group in March 2008 in order to overcome a problem with subprocedure WrtHtmlStmf. The problem was in scanning for a new line character. >>>>The new code operates on the HTML output buffer one byte at a time, >>>>copying each byte to the work buffer unless the byte is a newline character >>>>(x'15') in which case it writes CRLF (x'0D25'). The previous XXXWRKHTML source was saved in file CGIDEV2/QRPGLESRCO. **************************************************** **** Changes made in version 2005-03-10 20:21:21 *** **************************************************** - README,CGIDEV2 - Added information about the WrtNoSection subprocedure, which was added to GGIDEV2 with version 2002-03-31 11:37:00, but inadvertantly was not added to the README. - QRPGLESRC - all sample programs that use ZhbGetInput (DSPENCODE2, TEMPLATE3, TEMPLATE4, TEMPLATE5, TEMPLATE5F, PERSIST, STATE) - added logic that executes the *PSSR subroutine if ZhbGetInput returns with an error in the qusec error data structure - QRPGLESRC,XXXCGIPARS - ZhbGetInput subprocedure - added logic that does the following when the call to QzhbCgiParse fails. - Writes a message into the debbugging file - Sets number of variables to 0 and returns - QRPGLESRC,XXXWRKHTML - Fixed bugs in UpdHtmlVar2 subprocedure - when user requested that arrays be cleared, the variable varallocated was incorrectly being set to 0. - when a variable's value was blanks and the trim request was %trim, one blank was being output. - modified code to initialize elements in the varnm, varP, and varlen arrays to correct intermittent errors including corrupted output HTML, realloc errors, etc. Thanks to Ron Egyed for finding, reporting, and developing the fix for this bug. - Fixed a bug in internal subprocedure setarrays used to set up substitution variables. An externally described HTML record like the following caused the calling CGI program to abort and now is fixed: Your test score is /%score%/% A record like the following will still fail with a message to CGIDEBUG that says the substitution variable delimiters are in the wrong order because the order appears to be /% %/ %/ %/: Your test score is /%score%/%/%somevar%/ To correct it use something like one of the following: Your test score is /%score%/% /%somevar%/ or encode the % sign Your test score is /%score%/%/%somevar%/ Or, use different substitution variable delimiters. **************************************************** **** Changes made in version 2004-09-02 17:40:18 *** **************************************************** New Subprocedures ----------------- - ZhbGetVarPtr returns a pointer to an input variable. Intended to be used when an input variable's length might exceed ZhbGetVar's maximum size of 32767. The maximum length is 64000. See details, below, in QRPGLESRC,XXXCGIPARS - UpdHtmlVar2 provided to support very large substitution variables. See details, below, in QRPGLESRC,XXXWRKHTML - TimerStart and TimeElapsed for timing operations. See details, below, in QRPGLESRC,XXXTIME - Encode2. See details, below, in QRGPLESRC,XXXWRKHTML DONE - ChkIfsObj2. See details, below, in QRPGLESRC,XXXIFS DONE  New Programs ------------ - DSPENCODE2 CGI. See details, below, in QRGPLESRC,XXXWRKHTML. Changes, fixes, additions - details ----------------------------------- - Code is now targeted to and distributed for V5R1M0 and later. - ChkNbr subprocedure documentation in README and QRPGLESRC,PROTOTYPEB - Added text to emphasize that the first indicator (any errors) in the returned data structure is NOT turned on when indicator 7 (value is negative) is turned on. Indicator 7 is used only to condition a message when the value is negative. - Sample programs - Now use the new timing subprocedures, TimerStart and TimerElapsed, to calculate execution times. - HTMLSRC,ENCODE2FIL - This new source member contains the default run time data for the encode2 subprocedure. At install time, it is copied to the IFS as /cgidevexthtml/encode2fil.txt. Details for creating your own version of this file are in the README file and in QRPGLESRC member PROTOTYPEB in the Encode2 prototype. - QRPGLESRC,STATE - Changed to use the new encode2 subprocedure instead of encode. - QRPGLESRC,TEMPLATE5 - Now uses ILE RPG free-form calculations. - QRPGLESRC,XXXCGIPARS - New ZhbGetVarPtr subprocedure. Designed to be used when inputs greater than the maximum 32767 allowed by ZhbGetVar are expected. The maximum variable size captured by ZhbGetInput is 64000. If the variable exists and the data length is greater than 0, ZhbGetVarPtr returns a pointer to the data. Otherwise, it returns a null pointer (*null). The length of the data is returned in a parameter. See the prototype in QRPGLESRC,PROTOTYPEB for details. - ZhbGetInput procedure - Internal changes to support ZhbGetVarPtr. - Increased maximum input variable length from 32767 to 64000. ZhbGetVar and ZhbGetVarUpper, still return only a maximum of 32767 bytes. If you have a longer variable, use the new ZhbGetVarPtr subprocedure. - Increased the maximum number of input variables from 5000 to 32767. - Modified CGIMODE logic so that the request is rejected when the CGI_MODE environment variable is either %%MIXED%% or %%MIXED/MIXED%%. Behavior is the same for both the original HTTP server and the HTTP server powered by Apache. - QRPGLESRC,XXXDATA - Uppify subprocedure - Added an optional CCSID parameter. See the prototype in QRPGLESRC,PROTOTYPEB for details. - QRPGLESRC,XXXERRNO - Corrected error in prototype for strerrno function by adding value keyword to the errno parameter. - QRPGLESRC,XXXIFS (new member) - ChkIfsObj2 subprocedure - Checks for the existence/accessibility of an IFS object - QRPGLESRC,XXXTIME (new member) - TimerStart subprocedure - Retrieves and stores in the CGISRVPGM2 service program, the current software timer's value. - TimerElapsed subprocedure - Returns the number of seconds elapsed since TimerStart was last run. Value returned is a 15p 6 field. - QRPGLESRC,XXXWRKHTML - New Encode2 subprocedure. - Supports a large number of character entities. Default run time data for Encode2 is copied at installation time from HTMLSRC,ENCODE2FIL to IFS file /cgidevexthtml/encode2fil.txt - New UpdHtmlVar2 subprocedure allows very large substitution variables. Accomplished by passing the variable's address and length. See the prototype for details. - UpdHtmlVar subprocedure - modified to use UpdHtmlVar2. - GetHtmlIfsMult subprocedure - removed unused d specification for srcdta variable. - WrtHtmlToStmf subprocedure - Added additional error checking at points following linking of new file from temporary file and unlinking of temporary file. - WrtSection subprocedure - added NoDataString parameter to allow caller to determine what is written to the browser when a substitution variable has no value. - modified to handle large substitution variables supported by UpdHtmlVar2. **************************************************** **** Changes made in version 2003-09-01 14:50:19 *** **************************************************** New items --------- - CrtUsrSpc (Create User Space) subprocedure. See details, below, in QRPGLESRC,XXXUSRSPC. - RtvUsrSpcPtr (Retrieve User Space Pointer) subprocedure. See details, below, in QRPGLESRC,XXXUSRSPC. - RandomString (Create Random String) subprocedure. See details, below, in QRPGLESRC,XXXRANDOM. - Encode (Encode HTML special characters) subprocedure. See details, below, in QRPGLESRC,XXXWRKHTML - EncodeBlanks (Encode blanks) subprocedure. See details, below, in QRPGLESRC,XXXWRKHTML - STATE sample program. See details, below, in QRPGLESRC,STATE Changes, fixes, additions - details ----------------------------------- - Binding directory TEMPLATE2 - Removed incorrect binding directory entry for service program CGIDEV2DEV/CGISRVPGM2 - QRPGLESRC,PERSIST - Modified to use ZhbGetInput, ZhbGetVarCnt, ZhbGetVar, and getHtmlIFSMult subprocedures. - QRPGLESRC,STATE - A new sample program that illustrates storing and retrieving state information into and from a user space. It uses the new CrtUsrSpc and RtvUsrSpcPtr subprocedures. - QRPGLESRC,TEMPLATE through TEMPLATE5, PERSIST, STATE, DSPVERSION - Added Callp ClrHtmlBuffer before first callp WrtSection to ensure that any leftover output from a previous abnormally terminated execution will not be output to the browser (WrtSection *fini) or to a stream file (WrtHtmlToStmf). - QRPGLESRC,TEMPLATE through TEMPLATE5, PERSIST, STATE (sample programs) RANDOMNBRS, CLRDEBUG, DSPVERSION - Modified code and installation procedures so that these programs are created with CRTBNDRPG instead of CRTRPGMOD and CRTPGM. - QRPGLESRC,XXXCOOKIES - Corrected a bug in CrtCookie subprocedure that returned an incorrectly formatted date for the expires part of the cookie. - Corrected incorrectly prototyped parameters for the CEEDAYS API in the CrtCookie subprocedure. It was was causing intermittent failures with the message CEE2507, "insufficient data provided." - QRPGLESRC,XXXDATA - ChkNbr subprocedure - Corrected possible problem with unpassed *nopass variable, maxdigits - Removed extra blanks in messages written by AddMsg when there were too many decimal points or too many minus signs. - QRPGLESRC,XXXDEBUG - WrtDebug subprocedure - Corrected possible problem with unpassed *nopass variable, force - WrtJobDbg subprocedure - Corrected possible problem with unpassed *nopass variable, force - QRPGLESRC,XXXRANDOM - New subprocedure, RandomString, returns a string of up to 1024 random characters. The caller controls the number of characters returned, the contents and case of the first character, and the contents and case of the remaining characters. See the prototype for details. - QRPGLESRC,XXXWRKHTML - New subprocedures - Encode - Converts an input varying field to an output varying field in which any " & < > characters are converted to into their corresponding HTML character entities, " & < > - EncodeBlanks - Converts an input varying field to an output varying field in which any blanks are converted to   - UpdHTMLVar subprocedure - Corrected problems with unpassed *nopass variables, one of which caused corruption resulting in exception message "range of subscript value or character string error." - WrtNoSection subprocedure - Failed when called before a successful execution of GetHtml, GetHtmlIfs, or GetHtmlIfsMult. Added logic to perform necessary initialization. - Global variables SecDelim1 and SecDelim2 were too short. Changed from 10 to 20 characters. - QRPGLESRC,XXXUSRSPC - New module with the following new subprocedures. See the prototypes in QRPGLESRC,PROTOTYPEB for details. - CrtUsrSpc subprocedure - Creates a user space and makes it automatically extendible. - RtvUsrSpcPtr subprocedure - Retrieves a pointer to a user space **************************************************** **** Changes made in version 2003-05-19 00:01:01 *** **************************************************** - QRPGLESRC,XXXCGIPARS - Added logic for ZhbGetInput to tolerate more input - input buffer previously was fixed at 32767 bytes - now it is initialized to 50,000 bytes and can grow dynamically to a maximum of about 16,000,000 bytes (this should NEVER happen). - NOTE: the sum of all the occurrences of any ONE variable still cannot exceed 32767 bytes. - Modified subprocedures ZhbGetVar and ZhbGetVarUpper - Added const keyword to the occurrence parameter, thus allowing literals to be used. Programs using this parameter may have to be recompiled (CRTRPGMOD + CRTPGM or CRTBNDRPG). - QRPGLESRC,XXXRANDOM - Random returns an unsigned integer but the return value was being created with built-in function %int. Changed code to use built-in function %uns. - QRPGLESRC,XXXWRKHTML - Modified GetHtmlIfs and GetHtmlIfsMult to right trim blanks from each record in the same way that GetHtml does. - CGIDEBUG changes These changes require that any CGIDEBUG files in your libraries be deleted and recreated, either with CRTPF using member CGIDEBUG from CGIDEV2/QDDSSRC or with CRTDUPOBJ from a newly installed copy of the CGIDEV2 library. - QDDSSRC,CGIDEBUG - Removed field DBGLEN - Added timestamp field, DBGTIME - QRPGLESRC,XXXDEBUG - Modified WrtDebug subprocedure to write a timestamp instead of debug text length - Modified WrtJobDbg to write a timestamp instead of debug text length and removed logic to get and display time and date. **************************************************** **** Changes made in version 2002-07-30 18:00:00 *** **************************************************** - Corrected bug that caused ZhbGetInput to fail when a variable's name was more than 30 characters in length. The maximum length is now 50 characters. **************************************************** **** Changes made in version 2002-05-16 11:36:11 *** **************************************************** - CGIDEV2 now requires OS/400 V4R4 or later. - Documented the noname section in the README file - QRPGLESRC,XXXCOOKIES - Modified subprocedure CrtCookie so that the output always uses English abbreviations for day of the week and month. The previous version used the CEEDATM API which, being national language version compliant, returned these values in the machine's primary language. - QRPGLESRC,XXXRANDOM - The random subprocedure returns an unsigned integer, but the return value was being created with built-in function %int. Changed the code to use built-in function %uns. - QRPGLESRC,XXXWRKHTML - Added the GetHtmlBytesBuffered subprocedure. **************************************************** **** Changes made in version 2002-03-31 11:37:00 *** **************************************************** - QRPGLESRC,TEMPLATE, TEMPLATE2, TEMPLATE3, TEMPLATE4, TEMPLATE5 - Removed use of %trim in all calls to UpdHtmlVar since UpdHtmlVar trims its inputs. - Changed variable oses to varying length and modified logic that uses it to take advantage of its varying length - QRPGLESRC,PERSIST - Removed use of %trim in all calls to UpdHtmlVar since UpdHtmlVar trims its inputs. - Removed use of %trim in all calls to GetEnv's output is already trimmed. - QRPGLESRC,XXXCOOKIES - Fixed a bug that caused an exception when no cookies were in the HTTP_COOKIE environment variable. - QRPGLESRC,XXXDATA - ChkNbr subprocedure - Indicator 6 is now set on for any of the following conditions - more than 21 digits to the left of the decimal point - more than 9 digits to the right of the decimal point - number of digits to the left of the decimal point exceeds maximum specified in the maxdigits parameter - The changes above also removed the failure that occurred when checking the number of digits to the left of the decimal point and the number of digits exceeded the maximum number of digits supported by built-in function %inth. - QRPGLESRC,XXXWRKHTML - Added subprocedure WrtNoSection which allows data to be written to the browser without using WrtSection. This is useful for writing large blocks of data that exceed the 1000 byte maximum allowed for substitution variables in the UpdHtmlVar subprocedure. - Fixed bug in UpdHtmlVar that ignored the trim parameter when the action parameter was set to '0' (clear the arrays and write the variable as the first element). - Fixed bugs that output incorrect file names into the CGIDEBUG file when duplicate sections were found and sometimes failed with an array index error. - Fixed bug in CrtTagOpt: SELECT was being output when the value was blanks and the optional third parameter used to control SELECT's output was not passed. - Modified CrtTagOpt to right trim the text portion of the generated option tag. It is still up to the user to trim the value portion if desired. - Fixed pointer error in WrtHtmlToStmf subprocedure. - HTMLSRC - Removed IBM disclaimer notice from all members and from html files placed in directory /cgidevexthtml. **************************************************** **** Changes made in version 2001-09-21 09:20:36 *** **************************************************** - QREXSRC source physical file - Expanded record length from 142 to 240 bytes - QREXSRC,CRTOBJECTS - Modified to create IFS directory /CgidevExtHtml and its HTML files Talk2Ifs.html, StdEnd.Html, StdMsg.Html, StdPssr.Html, StdRunTime.Html, StdTop.Html, and Talk2Stuff.Html - QRPGLESRC,PERSIST - Changed all uses of %editw to %editc - QRPGLESRC,TEMPLATE, TEMPLATE2, TEMPLATE3, TEMPLATE4 - Removed protocol and counter variables by nesting the GETENV subprocedure inside the UpdHTMLVar subprocedure. - Added output for the SERVER_SOFTWARE environment variable. Used to quickly determine which server is being used (original or powered by Apache). - Modified corresponding HTML in HTMLSRC members TALK2 and TALK2IFS. - Moved code for updating the protocol, counter, and serversoftware variables closer to where they used. - Explicitly coded callp SetNoDebug(*off) in each program. The user is to change it to callp SetNoDebug(*on) if no debugging output is to be produced. - Changed all uses of %editw to %editc - Changed PGMNAME variable from a constant to a subfield of the program status data structure. - QRGPLESRC,TEMPLATE5 - New sample program that uses GetHtmlIfsMult and six externally described HTML files in the IFS. Distribution includes the six files. - QRPGLESRC,XXXCGIPARS - Added subprocedures ZhbCountAllVars and ZhbGetVarDetails - ZhbCountAllVars returns the number of occurrences of all variables in the CGI input. - ZhbGetVarDetails returns detailed information about the nth variable of all variables counted by ZhbCountAllVars. The information includes the variable's name, value, and occurrence. - Modified subprocedures ZhbGetVarUpper and ZhbGetVarCnt - Changed parameter name from varname to varnamein - ZhbGetInput subprocedure - Fixed bug that caused the last variable input to be omitted. - QRPGLESRC,XXXCOOKIES - New source member contains the following subprocedures - CrtCookie creates a cookie - GetCookieByName gets a cookie's value based on its name and occurrence. _ QRPGLESRC,XXXWRKHTML - New subprocedures - GetHtmlIfsMult subprocedure supports reading multiple externally described HTML files at once. All the sections and records in all the files are read into dynamic storage as though they resided in a single file. If a section name appears more than once, only the first occurrence is used. - ClrHtmlBuffer clears the HTML output buffer. Use this subprocedure to empty the buffer without sending it to either the browser or to a stream file. This is useful when program logic dictates you need to output something other than what has already been buffered. - RtvSubsVarInfo retrieves information about substitution variables. - CrtOptTag subprocedure modified to output the tag which hadn't been output before. - UpdHtmlVar subprocedure modified by adding an optional parameter the caller can use to control trimming. - %trim - trim left and right (default) - %triml - trim left only - %trimr - trim right only - %trim0 - don't trim - GetHtml and GetHtmlIfs subprocedures modified to check substitution variables for matching pairs of correctly sequenced starting and ending delimiters. When a record contains any such errors, the entire record is changed to all asterisks (*) and a message is forced into the CGIDEBUG file. The new subprocedure, GetHtmlIfsMult behaves in the same way. - For all methods of getting HTML, changed the maximum number of section names from 200 to 1000 - QRPGLESRC - WrtDebug subprocedure - Modified all uses of WrtDebug in the sample programs and in the service program to start with the sending program's or subprocedure's name. **************************************************** **** Changes made in version 2001-05-31 17:11:26 *** **************************************************** - Fixed bug in CL program CGIDEBUG that allocated but did not deallocate the CGIDEBUG physical file. - Modified subprocedure CgiVarCnt to use a dynamically allocated array for counting the number of times a variable occurs. As a result, the maximum occurrences is increased from 250 to 8200 (slightly more than can fit in the 32767 byte input buffer). Users are encouraged to use the Zhbxxxxx subprocedures instead of the Cgixxxxx subprocedures. **************************************************** **** Changes made in version 2001-05-18 10:14:02 *** **************************************************** - Miscellaneous changes to comments in the code. **************************************************** **** Changes made in version 2001-05-10 21:12:13 *** **************************************************** - Added subprocedure WrtHtmlToStmf to QRPGLESRC,XXXWRKHTML. This subprocedure is used (instead of WrtSection(*fini)) to direct the accumulated HTML to a stream file. Do not use WrtHtmlToStmf in a CGI program. It should be run from an interactive session or from a batch job to create static HTML files. - Added other objects to demonstrate WrtHTMLtoStmf. - HTMLSRC,RANDOMNBRS externally described HTML - QCMDSRC,RANDOMNBRS to create RANDOMNBRS command to drive RANDOMNBRS program - QRPGLESRC,RANDOMNBRS sample program. Creates an HTML stream file containing random numbers - Added subprocedure RtvHtmlRcd to QRPGLESRC,XXXWRKHTML. This subprocedure is used to retrieve an externally described HTML section one record at a time. - Fixed CL program CGIDEBUG to correct error when attempting to CLRPFM when member is in use. - Fixed bug in subprocedure WrtDebug that caused a loop if file CGIDEBUG could not be opened (does not exist, etc.) - Added subprocedure SetNoDebug which sets a global indicator used by the debugging subprocedures. The indicator's default value is *off, which allows debugging to operate normally. If SetNoDebug sets it *on, all the debugging routines do nothing when called, even if forced output is requested. The debugging routines IsDebug, WrtDebug, WrtJobDbg, and WrtPsds were modified to check the indicator's status. This capability was added to allow the programmer to improve performance by turning all debugging off. **************************************************** **** Changes made in version 2001-04-13 **************************************************** - Added VERSION data area to CGIDEV2 library. Contains this version's date and time (there are no version numbers). To display: DSPDTAARA VERSION or run CGI program DSPVERSION (link in HTMLSRC member MENU). - Added member QRPGLESRC,DSPVERSION to display the current version (CGI program). - Added member HTMLSRC,VERSION, used by DSPVERSION CGI program. - Modified member HTMLSRC,MENU to add an option to run DSPVERSION **************************************************** **** Changes made in version 2001-04-05 **************************************************** - Fixed bug in GetHtmlIfs subprocedure **************************************************** **** Changes made in version 2001-03-05 **************************************************** - Bug fixes and minor documentation changes - Added member TALK2IFS to HTMLSRC source physical file **************************************************** **** Changes made in version 2001-03-02 **************************************************** - Added ability to place externally described HTML in the IFS. - New source members - QRPGLESRC,TEMPLATE4 sample program. Same as TEMPLATE3 but uses IFS file /cgidevexthtml/talk2.html for externally described HTML. - QRPGLESRC,XXXERRNO new source member implements subprocedures - errno - errnotxt - HTMLSRC,TALK14, input for program TEMPLATE4 - Modified source members - QRPGLESRC,PROTOTYPEB. - Added prototypes errno, errnotxt, GetHtmlIfs, stat, open, read, write, close. - Added constants for IFS APIs. - QRPGLESRC,XXXWRKHTML - Restructured existing code for GetHtml subprocedure - Added code for GetHtmlIfs subprocedure - QSRVSRC,CGISRVPGM2 - Added exports for GetHtmlIfs errno, errnotxt, GetHtmlIfs - QREXSRC,CRTOBJECTS - README,CGIDEV2 **************************************************** **** Changes made in version 2001-01-24 **************************************************** - TEMPLATE, TEMPLATE2, TEMPLATE3, and PERSIST sample programs. - Added comments explaining the use of the *on (force) parameter in the WrtJobDbg subprocedure. **************************************************** **** Changes made in version 2001-01-18 **************************************************** - QRPGLESRC,XXXFIXMIX - FixMixed subprocedure modified to fix mixed data if CGI_MODE is either %%MIXED%% or %%MIXED/MIXED%%. - QRPGLESRC,XXXCGIPARS - ZhbGetInput subprocedure. Added code to return number of variables = 0 if (request method = POST and CONTENT_LENGTH = 0) or (request method = GET and QUERY_STRING's length is 0). - README,CHANGES - New member **************************************************** **** Changes made in version 2001-01-10 **************************************************** - QRPGLESRC,XXXCGIPARS - ZhbGetInput subprocedure modified to work correctly with Apache 2.00 Alpha server. **************************************************** **** Changes made in version 2000-12-22 **************************************************** - QRPGLSRC,TEMPLATE, TEMPLATE2, TEMPLATE3 - Modified to open HOURSOP only once and to reposition to the beginning of file each time. - QRPGLSRC,XXXCVTDB - Removed obsolete unused D specs for CEEDOD API. **************************************************** **** Original version 2000-11-21 ****************************************************