// (C) M.A.Smith University of Brighton
//
// Permission is granted to use this code
//   provided this declaration and copyright notice remains intact.
//
// 15 September 1995
// Last modified 10 February 1996

#define NO_MAP

#include "iostream.h"
//#include <fstream.h>
//#include <iomanip.h>
#include <stdlib.h>
//#include <time.h>
#include <string.h>


#define SERVER  "http://snowwhite.it.brighton.ac.uk/"
#define TRY_PROG "cgi-bin/mas/mas_try"

#include "parse.h"
#include "parse.cpp"

void process_script( char [], bool );

inline void html( char str[] ) { cout << str << "\n"; }

inline void html_( char str[] ) { cout << str; }

inline void html_( char c ) { cout << c; }

// Main program
//

int main()
{
  char *query_str = getenv("QUERY_STRING");
  Parse list( query_str == 0 ? "feedback=xxx&nowrap" : query_str );

  process_script( list.get_item( "feedback" ), 
                  list.get_item("nowrap")==NULL );
  return 0;
}


void process_script( char mes[], bool wrap )
{
  html( "Content-type: text/html" );
  html( "" ); html( "" );

  if( wrap )
  {
    html("<HTML>");
  
    html("<HEAD>");
    html("<TITLE>Example of HTML</TITLE>");
    html("</HEAD>");
  
    html("<BODY>");
  
    html("<H2>Result of processing the HTML</H2>");
    html("<P>");
    html("This before text allows you to see the effect "
         "of the HTML in context.");
  }
  html( mes );
  if ( wrap )
  {
    html("This after text allows you to see the effect "
         "of the HTML in context.");
  
    html("</BODY>");
    html("</HTML>");
  }
}
