$! This is an example DCL procedure for WASD RTE processing. $! --------------------------------------------------------- $! $! It dispatches RTE request to the corresponding CGI script $! (.COM or .EXE) changing the script environment from CGIPLUS/RTE $! to standard CGI. $! There is no real use for it - it does the same as httpd does. $! This is only an example of how to use RTE/CGIPLUS environment $! from DCL and where is their difference. $! To use it add the following mapping rule into HTTPD$MAP.CONF $! exec /dclrte/* (@CGI-BIN:[000000]DCLRTE.COM)/cgi-bin/* $! and any .COM or .EXE CGI script in CGI-BIN: will be available via $! /dclrte/script_name.ext $! For example try /dclrte/cgi_symbols.com $! N.B. In the new secure WASD configuration You should enable access $! to that file from the HTTP$SERVER or HTTP$NOBODY account. $! $! Let's begin... $! $! Define error handler and disable direct error messages. $! $ ON ERROR THEN GOTO ERROR_HANDLER $ SET MESSAGE/NOFACILITY/NOSEVERITY/NOIDENTIFICATION/NOTEXT $! $! Rename our process according to RTEset convention $! and remember the old name. $! Now it will be DCL... instead of HTTP... $! $ PRCNAM=F$PROCESS() $ LINE="DCL"+(PRCNAM-"HTTP") $ SET PROC/NAME="''LINE'" $! $! Check for CGIPLUSEOF logical. $! If not - report non-RTE environment and exit. $! Else remember it and undefine to make the scripts $! sure they are running in classic CGI environment. $! $ IF F$TRNLNM("CGIPLUSEOF","LNM$PROCESS") .EQS. "" THEN GOTO NOTRTE $ CGIEOF=F$TRNLNM("CGIPLUSEOF","LNM$PROCESS") $ DEAS/PROCESS CGIPLUSEOF $! $! Open CGI variables read channel to CGIPLUSIN: mailbox. $! If there is no CGIPLUSIN: - report non-RTE environment and exit. $! $ OPEN/READ/ERROR=NOTRTE CGIPLUSIN CGIPLUSIN: $! $! Begin request loop. $! $ REQUEST_LOOP: $! $! DELETE all global DCL symbols $! remaining from the previous request. $! $ DELETE/SYMBOL/GLOBAL/ALL $! $! Define special RTE symbols. $! $ RTE_ident=="DCLrte V1.1C" $ RTE_input=="HTTP$INPUT:" $ RTE_output=="SYS$OUTPUT:" $ RTE_root==F$ENVIRONMENT("PROCEDURE") $ RTE_root==- F$PARSE(RTE_root,,,"NODE")+- F$PARSE(RTE_root,,,"DEVICE")+- F$PARSE(RTE_root,,,"DIRECTORY") $ RTE_script_control=="" $ RTE_prefix=="WWW_" $! $! Wait for and skip the first request line. $! $ READ/ERROR=DONE/END=DONE CGIPLUSIN LINE $! $! Begin reading CGI variables in the form $! NAME=VALUE $! $! Clear CGI variables counter. $! $ RTE_cnt=0 $! $ CGI_VARS_LOOP: $! $! Read next line $! $ READ/ERROR=DONE/END=DONE CGIPLUSIN LINE $! $! If the line is empty - all CGI variables are read. $! $ IF LINE .EQS. "" THEN GOTO CGI_VARS_END $! $! Extract the CGI variable name. $! $ CGI_VAR_NAME=F$ELEMENT(0,"=",LINE) $! $! All the rest of line is the CGI variable value. $! $ CGI_VAR_VALUE=LINE-(CGI_VAR_NAME+"=") $! $! Assign the value to the global DCL symbol. $! $ 'CGI_VAR_NAME'=="''CGI_VAR_VALUE'" $! $! Count CGI variables. $! $ RTE_cnt=RTE_cnt+1 $! $! Loop for the next line. $! $ GOTO CGI_VARS_LOOP $! $! All CGI variables are read. $! $ CGI_VARS_END: $! $! If there were no CGI variables - this is the exit request. $! $ IF RTE_cnt .EQ. 0 THEN GOTO DONE $! $! Determine the CGI prefix used (default is "WWW_"). $! If GATEWAY_INTERFACE variable is present instead of $! WWW_GATEWAY_INTERFACE then the empty ("") CGI prefix $! will be used by RTE. $! $ IF F$TYPE(GATEWAY_INTERFACE) .NES. "" THEN RTE_prefix=="" $! $! If there is no script filename (WWW_SCRIPT_FILENAME) $! or there is no script RTE (WWW_SCRIPT_RTE) $! - report non-RTE request and finish request processing. $! If You are writing CGI+ script - You don't need the $! script filename, so You can process it here instead of $! the following script dispatch. We have pure CGI $! environment now - see later. $! $ IF (F$TYPE('RTE_prefix'SCRIPT_FILENAME) .EQS. "") - OR (F$TYPE('RTE_prefix'SCRIPT_RTE) .EQS. "") $ THEN $ CALL RTE_ERROR_REPORT 500 "non-RTE request" RTE_ident $ GOTO END_REQUEST $ ENDIF $! $! Script filename is present. $! Execute it as we have the pure CGI environment now - $! CGI variables are stored in WWW_* global DCL symbols, $! SYS$OUTPUT: and HTTP$INPUT: are not changed and point to $! where they should point to in CGI. $! $! If WWW_RTE_MIME variable present (set script=params=(RTE_MIME=...)) $! report the corresponding CGI header instead if script. $! $ IF F$TYPE('RTE_prefix'RTE_MIME) .NES. "" $ THEN $ WRITE SYS$OUTPUT "Content-type: ",'RTE_prefix'RTE_MIME $ WRITE SYS$OUTPUT RTE_script_control $ ENDIF $! $! Define the script file name. $! $ LINE='RTE_prefix'SCRIPT_FILENAME $! $! If script file type is .COM $! execute the corresponding DCL procedure. $! $ IF F$PARSE(LINE,,,"TYPE") .EQS. ".COM" $ THEN $ @'LINE' $ GOTO END_REQUEST $ ENDIF $! $! If script file type is .EXE $! execute the corresponding image. $! $ IF F$PARSE(LINE,,,"TYPE") .EQS. ".EXE" $ THEN $ RUN 'LINE' $ GOTO END_REQUEST $ ENDIF $! $! If You know how to start the scripts with other file types $! - You can add them there... $! $! ... $! $! Unknown script type stub. $! Report error and continue with the next request. $! $ CALL RTE_ERROR_REPORT 501 "Unknown script type" RTE_ident $ END_REQUEST: $! $! The script is done. $! All the output was produced by the script. $! Close the request output by sending CGIPLUSEOF string $! to httpd via SYS$OUTPUT. $! $ WRITE SYS$OUTPUT CGIEOF $! $! The request is over. $! Let's go for the next request. $! $ GOTO REQUEST_LOOP $! $! The request loop is infinite. $! If httpd wants - it will abort us. $! $! $! Close CGI variables read channel, restore process name and exit. $! $ DONE: $ CLOSE CGIPLUSIN $ SET PROC/NAME="''PRCNAM'" $ DELETE/SYMBOL/GLOBAL/ALL $ EXIT $! $! Report non-RTE environment and exit. $! $ NOTRTE: $ CALL RTE_ERROR_REPORT 500 "non-RTE environment" RTE_ident $ GOTO DONE $! $! Error report subroutine. $! P1 - HTTP status (required) $! P2 - error text (required) $! P3 - module name (optional) $! P4 - line number (optional) $! Uses WASD Script-control: X-error-... extensions. $! If the current version doesn't support them, $! Then it will be a simple error report. $! $ RTE_ERROR_REPORT: SUBROUTINE $ WRITE SYS$OUTPUT "Status: ",P1 $ WRITE SYS$OUTPUT "Script-control: X-error-text=""",P2,"""" $ IF P3 .NES. "" THEN - WRITE SYS$OUTPUT "Script-control: X-error-module=""",P3,"""" $ IF P4 .NES. "" THEN - WRITE SYS$OUTPUT "Script-control: X-error-line=",P4 $ WRITE SYS$OUTPUT RTE_script_control $ WRITE SYS$OUTPUT P1,": ",P2 $ EXIT $ ENDSUBROUTINE $! $! Error handler $! $ ERROR_HANDLER: $ CALL RTE_ERROR_REPORT 500 "''F$FAO(F$MESSAGE($STATUS),"","","","")'" RTE_ident $ GOTO DONE