CGI_NEW.INC (c)2001-2003 Chris Warrington rapidq.basic.c45207@spamgourmet.com Version: 1.5 Date: 25-SEPT-2003 ====== Notes ] ====== 1) Please turn "Word Wrap" or a similar function on in your text editor. 2) Please use a fixed width font when viewing this file. ======== License ] ======== This library is free software. You may use according to the following conditions: 1) USE of this library is free. You may use this library however you wish, whether it is for your own private use or for commercial use or anything else. 2) If you make any modifications to this library, you MUST release those modifications to the RapidQ community. 3) Although you may use this library, it is still copyrighted 2003 Chris Warrington. ======= Update ] ======= 1.5: More performance improvements. The query string is only read once. Hex and space replacements are optional. 1.4: Performance improvements. Now replaces ALL "printable" %xx (between " " and "~"). Space replacement is more intelligent. "C+++Help" is turned into "C++ Help" NOT "C Help" 1.3: Removed the LGPL because it was too restricting on use due to the way RapidQ compiles. 1.2: There is more error checking. A maximum input value has been specified and can be defined. There is the option to turn off automatic conversions of +, %24, %25, and %3D into their respective characters. 1.1: I was able to figure out how to get POST to work! ==== Use ] ==== The use of this is exactly like CGI.INC, except the functions SendFooter(), SendB(), and SendHeader() have been omitted. You need to provide these yourself. If you are not familiar with the use of CGI.INC, read on: First, you need to include the file cgi_new.inc in your program. EX: : $INCLUDE "cgi_new.inc" Then, you can use any of the following the variables: CGI_Accept CGI_AuthType CGI_ContentLength * CGI_ContentType CGI_Cookie CGI_GatewayInterface CGI_PathInfo CGI_PathTranslated CGI_QueryString CGI_Referer CGI_RemoteAddr CGI_RemoteHost CGI_RemoteIdent CGI_RemoteUser CGI_RequestMethod CGI_ScriptName CGI_ServerSoftware CGI_ServerName CGI_ServerPort CGI_ServerProtocol CGI_UserAgent * CGI_ContentLength is the only number (It is an integer). The rest are strings. The CGI_QueryString can be parsed for you. To use this function, first you must call InitCgi(). EXAMPLE: : CALL InitCgi() Then you can call GetCgiValue() with an id and get the value of that id. EXAMPLE: : var$ = GetCgiValue("your id here") Pulling it all together, the following sample program can be made: : 'Begin Rapid-Q code. : $APPTYPE CGI : $INCLUDE "cgi_new.inc" : $ESCAPECHARS ON : DIM name$ AS STRING : CALL InitCgi() : name$ = GetCgiValue("name") : PRINT "Content-type: test/html\n\n" : PRINT "" : PRINT "" : PRINT "Test" : PRINT "" : PRINT "" : PRINT "

Hello, " + name$ + "!

" : PRINT "" : PRINT "" : 'End Rapid-Q Then, if you upload this program to a server, and access it as so: http://myserver.com/cgi-bin/prgm.exe?name=John+Doe the program will display Hello, John Doe! ================== Advanced Features ] ================== To set a maximum input value for both POST and GET, define the preprocessor symbol CGI_MAX_INPUT as the maximum value. If it is not defined, it defaults to 32767 (that is 2^15-1). EXAMPLE: : $DEFINE CGI_MAX_INPUT 45 : $INCLUDE "cgi_new.inc" You can disable the conversion of %xx into is ASCII character equivalent. To do this, define the preprocessor symbol CGI_NO_CONVERT. EXAMPLE: : $DEFINE CGI_NO_CONVERT : $INCLUDE "cgi_new.inc" You can also disable space replacement. This allows values like "(a+b)*c" to be interpreted correctly. To do this, define the preprocessor symbol CGI_NO_SPACE_CONVERT. EXAMPLE: : $DEFINE CGI_NO_SPACE_CONVERT : $INCLUDE "cgi_new.inc" NB: Space conversion does not take place if CGI_NO_CONVERT is defined. Therefore, you have three conversion options: convert all, convert only %xx, and convert none. The CGI_HexRelace() and CGI_StringReplace() functions from 1.4 are still included in case they are needed. ======= Sample ] ======= Please see the included cgi_test.rqb for a sample CGI program. This program will accept a file name and then display the file, if it exists and can be opened in the current directory. ===== Bugs ] ===== Please report any and all bug, comments, suggestions, etc. to the e-mail address at the top of this document.