******************************************* * * MODULE NAME OBJSERV.COB * * DESCRIPTIVE NAME CICS for MVS/ESA CWI Graphics Server Sample Program * * Statement: Licensed Materials - Property of IBM * * CA84 SupportPac * (c) Copyright IBM Corp. 1997 * * All rights reserved. * * U.S. Government Users Restricted Rights - use, * duplication or disclosure restricted by GSA * ADP Schedule Contract with IBM Corp. * * Status: Version 1 Release 0 Modification 1 * Last Modified 10 October 1997 * Modified template manager comm-area creation step * to set address of returned data * Author: Steve Wall * * NOTES :- * DEPENDENCIES CICS for MVS/ESA V4.1 * Internet Connection Server for MVS/ESA * * This program is a cobol CWI converter program which implements * one method of delivering graphics through the CWI. * It will serve graphics from a URL * of the form http://your.cics.system/objserv/graphic.gif . * *******************************************
******************************************* * * PROGRAM NAME: OBJSERV * * TITLE: Cobol Sample CWI Graphics Server Converter Program. * * PROGRAM DESCRIPTION: * * This program will show an example of how to code a converter * to send binary objects up to 32K in length over the web. * * SYSTEM LEVEL: CICS 4.1 or higher. * * INPUT: * * The target file is passed in the URL. * * OUTPUT: * * The target file is returned to the browser. If an error occurs * then a 404 is returned. * *****************************************
PROCESS XOPTS(NOLINKAGE) IDENTIFICATIONDIVISION. PROGRAM-ID. OBJSERV. ENVIRONMENTDIVISION. DATADIVISION. WORKING-STORAGESECTION.
COPY DFHWBUCO.
****** * Data items. ****** * Simple data types used for interaction with CICS. ******
77 conv-pointer POINTER.
77 init-val PIC X VALUE LOW-VALUES.
77 resp PIC S9(4).
77 resp2 PIC S9(4).
****** * Specific stuff for the decode function. ******
****** * First part: set up the pointers and structures, perform * sanity checks and the call the decode/encode functions. ****** * Just return if no commarea because there's nowhere to work. ******
IF EIBCALEN = 0 EXECCICSRETURNEND-EXEC END-IF
****** * Set up addressability to the commarea. ******
EXECCICS ADDRESS COMMAREA(conv-pointer) END-EXEC.
SETADDRESSOF CONVERTER-PARMS TO conv-pointer.
****** * Validate the commarea eyecatcher. ******
IF (CONVERTER-EYECATCHER NOT = DECODE-EYECATCHER-INIT) AND (CONVERTER-EYECATCHER NOT = ENCODE-EYECATCHER-INIT) MOVE URP-INVALID TO CONVERTER-RESPONSE MOVE URP-CORRUPT-CLIENT-DATA TO CONVERTER-REASON
EXECCICS RETURN END-EXEC END-IF
IF CONVERTER-RESPONSE NOT = 0 EXECCICS RETURN END-EXEC END-IF
IF CONVERTER-REASON NOT = 0 EXECCICS RETURN END-EXEC END-IF
EVALUATE CONVERTER-FUNCTION
****** * If decode is set then do all the interesting stuff. ******
WHEN URP-DECODE PERFORM DECODE
****** * If encode is set then return. (Encode is a null function) ******
WHEN URP-ENCODE MOVE URP-OK TO CONVERTER-RESPONSE
****** * otherwise there is a problem ******
WHENOTHER MOVE URP-DISASTER TO CONVERTER-RESPONSE MOVE URP-CORRUPT-CLIENT-DATA TO CONVERTER-REASON EXECCICS RETURN END-EXEC END-EVALUATE
****** * Save the filename and extension + convert to upper case. ******
UNSTRING the-url DELIMITEDBY';'OR'?'OR'.'OR' ' INTO file-name extension
PERFORMWITHTESTAFTERVARYING counter FROM 1 BY +1 UNTIL counter = 26 INSPECT file-name REPLACINGALL
lowerc(counter) BY upperc(counter) INSPECT extension REPLACINGALL
lowerc(counter) BY upperc(counter) END-PERFORM
****** * Create the mime type and embed it in the http header * assume a default of 'gif' if the extension isn't recognised. ******
****** * Having found the filename we need to recover the file. ****** * Create the template manager comm-area. ******
SETADDRESSOF returned-data TO DECODE-DATA-PTR
MOVE LOW-VALUES TO DFHWBTL-ARG
****** * Set up and run the template manager. We are using it simply * to copy the binary image data to the data buffer, no * symbol replacements are required. ******
MOVE 0 TO WBTL-VERSION-NO MOVE WBTL-BUILD-HTML-PAGE TO WBTL-FUNCTION MOVE file-name TO WBTL-TEMPLATE-NAME SET WBTL-HTML-BUFFER-PTR TOADDRESSOF the-binary-data MOVELENGTHOF the-binary-data TO WBTL-HTML-BUFFER-LEN
EXECCICS
LINK PROGRAM('DFHWBTL')
COMMAREA(DFHWBTL-ARG) LENGTH(56)
RESP(resp) RESP2(resp2) END-EXEC
****** * If theres an error then handle it. ******
IF resp NOT = WBTL-OK PERFORM CREATE-ERROR-RESPONSE END-IF
****** * Now the binary data is in place we set up the length * fields and add the header. ****** * Calculate the length of the http response. An extra 2 * bytes are deducted to nullify the CRLF character pair * that the template manager automatically adds to the end * of the data. ******
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.