/*********************************************************************/
/*                                                                   */
/* (c) Copyright IBM Corp. 1998                                      */
/* All Rights Reserved                                               */
/* Licensed Materials - Property of IBM                              */
/*                                                                   */
/* DISCLAIMER OF WARRANTIES.                                         */
/*                                                                   */
/* The following [enclosed] code is generated by a software product  */
/* of IBM Corporation.                                               */
/* This generated code is provided to you solely for the purpose of  */
/* assisting you in the development of your applications.            */
/* The code is provided "AS IS." IBM MAKES NO WARRANTIES, EXPRESS    */
/* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES   */
/* OF NONINFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR  */
/* PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF THIS CODE.      */
/* IBM shall not be liable for any damages arising out of your use   */
/* of the generated code, even if it has been advised of the         */
/* possibility of such damages.                                      */
/*                                                                   */
/* DISTRIBUTION.                                                     */
/*                                                                   */
/* This generated code can be freely distributed, copied, altered,   */
/* and incorporated into other software, provided that:              */
/*   - It bears the above Copyright notice and DISCLAIMER intact     */
/*   - The software is not offered for resale                        */
/*                                                                   */
/*********************************************************************/

/************************************************************************/
/* Generated by IMS Web Studio 2.1.1     1998.252 10:18:13 */
/* Userid:  pglezen                                     */
/* Project: test5                                 */
/************************************************************************/

#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <process.h>
#include "hwsutil.hpp"
#include "HTMParse.hpp"
#include "HWSLPG01.hpp"
#include "HWSLPG00.hpp"

/*********************************************************/
/*                                                       */
/*  IMS Web generated CGI-Bin executable source code.    */
/*                                                       */
/*  INPUT : string generated by input HTML from STDIN    */
/*  OUTPUT: generated HTML to STDOUT                     */
/*                                                       */
/*  This routine :                                       */
/*                                                       */
/*   - parses the input for associated IMS transaction   */
/*     by using the constructor of HTML parsing class,   */
/*   - invokes the transaction by calling the execute    */
/*     method of the transaction input class,            */
/*   - and generates the output HTML from the output of  */
/*     the IMS transaction by using the transaction      */
/*     output class.                                     */
/*                                                       */
/*********************************************************/

/********************/
/*   MAIN PROGRAM   */
/********************/

int main (int argc, char *argv[])
{
   // The length of the input array must be large enough
   // to hold the input stream generated by the HTML input
   char input[296];
   char ruName[9];

   HtmParse *request;

   HWSUtil *util;

   HWSTranIn * tranObj = NULL;
#ifdef _TRAP
   char *trap = NULL;
   *trap = 'Y';
#endif
   HWSTranOut *pLpg = NULL;
   HWSTranOut *qLpg = NULL;

   /*******************************************************/
   /* input comes from POST action of the input HTML file */
   /*******************************************************/
   cin >> input;

   /*****************************************************************/
   /* Following line instantiates an object of the generated input  */
   /* parsing class. The constructor of the class will parse the    */
   /* input string and populate the attributes.                     */
   /*****************************************************************/
   request = new HtmParse (input);

   util = new HWSUtil;

   /**************************************/
   /* Start generating the HTML header.  */
   /**************************************/
   cout << "Content-type: text/html\n\n";
   cout << "<!-- ********************************************************************* -->\n";
   cout << "<!-- *                                                                   * -->\n";
   cout << "<!-- * (c) Copyright IBM Corp. 1998                                      * -->\n";
   cout << "<!-- * All Rights Reserved                                               * -->\n";
   cout << "<!-- * Licensed Materials - Property of IBM                              * -->\n";
   cout << "<!-- *                                                                   * -->\n";
   cout << "<!-- * DISCLAIMER OF WARRANTIES.                                         * -->\n";
   cout << "<!-- *                                                                   * -->\n";
   cout << "<!-- * The following [enclosed] code is generated by a software product  * -->\n";
   cout << "<!-- * of IBM Corporation.                                               * -->\n";
   cout << "<!-- * This generated code is provided to you solely for the purpose of  * -->\n";
   cout << "<!-- * assisting you in the development of your applications.            * -->\n";
   cout << "<!-- * The code is provided AS IS.  IBM MAKES NO WARRANTIES, EXPRESS     * -->\n";
   cout << "<!-- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES   * -->\n";
   cout << "<!-- * OF NONINFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR  * -->\n";
   cout << "<!-- * PURPOSE, REGARDING THE FUNCTION OR PERFORMANCE OF THIS CODE.      * -->\n";
   cout << "<!-- * IBM shall not be liable for any damages arising out of your use   * -->\n";
   cout << "<!-- * of the generated code, even if it has been advised of the         * -->\n";
   cout << "<!-- * possibility of such damages.                                      * -->\n";
   cout << "<!-- *                                                                   * -->\n";
   cout << "<!-- * DISTRIBUTION.                                                     * -->\n";
   cout << "<!-- *                                                                   * -->\n";
   cout << "<!-- * This generated code can be freely distributed, copied, altered,   * -->\n";
   cout << "<!-- * and incorporated into other software, provided that:              * -->\n";
   cout << "<!-- *   - It bears the above Copyright notice and DISCLAIMER intact     * -->\n";
   cout << "<!-- *   - The software is not offered for resale                        * -->\n";
   cout << "<!-- *                                                                   * -->\n";
   cout << "<!-- ********************************************************************* -->\n";
   cout << "<!-- *************************************************************************** -->\n";
   cout << "<!-- * Generated by IMS Web Studio 2.1.1 1998.252 10:18:13 * -->\n";
   cout << "<!-- * Userid:               pglezen                    * -->\n";
   cout << "<!-- * Project:              test5             * -->\n";
   cout << "<!-- *************************************************************************** -->\n";
   cout << "<html><head><TITLE>IMS Web Project test5</title></head>\n";
   cout << "<BODY TEXT=\"000000\">\n";

   /*********************************************/
   /* Setting up the transaction input object.  */
   /*********************************************/
          tranObj = new HWSLPG01In();

   /* Set the requester unique name which is used as LTERM name. */
   tranObj->setRUname(util->getRUname(ruName));

   /* Set the RACF userid. */
   // tranObj->setUser("USRT001");
   tranObj->setUser("");
   /* Set the RACF groupname. */
   // tranObj->setGroup("SYS1");
   tranObj->setGroup("");
   /* Set the hostname for TCP/IP OTMA Connection. */
   // tranObj->setHost("csdmec13.stl.ibm.com");
   tranObj->setHost("");
   /* Set the port address for TCP/IP OTMA Connection. */
   //tranObj->setPort("9999");
   tranObj->setPort("");
   /* Set the Datastore id. */
   //tranObj->setIMS("SOCKEYE");
   tranObj->setIMS("");
   /* Set the input attributes. */
   tranObj->setAttr("HWSMF009",request->getValue("CMD"));

   tranObj->setAttr("HWSMF00A",request->getValue("NAME1"));

   tranObj->setAttr("HWSMF00B",request->getValue("NAME2"));

   tranObj->setAttr("HWSMF00C",request->getValue("EXT_"));

   tranObj->setAttr("HWSMF00D",request->getValue("ZIP"));

   /************************************************************/
   /* Calling the execute method to send the request to host.  */
   /************************************************************/
   pLpg = tranObj->execute();

   /*********************************/
   /* Processing output from host.  */
   /*********************************/
   if (!pLpg) {
      cout << "Error Occured in the Server CGI-BIN program contact the WEB.Master<p>\n";
   } else {
      while (pLpg) {
         cout << "   " << pLpg->genHTML() << "<p>";
         qLpg = pLpg;
         pLpg = qLpg->getNext();
         free(qLpg);
      } /* end while */
   } /* end if */

   /******************************/
   /* Generating the HTML tail.  */
   /******************************/
   cout << "</body></html>\n";

   delete request;
   return 0;

}
