home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 10 / amigaformatcd10.iso / -in_the_mag- / html_tutorial / mas_try.cpp < prev    next >
C/C++ Source or Header  |  1996-09-03  |  2KB  |  77 lines

  1. // (C) M.A.Smith University of Brighton
  2. //
  3. // Permission is granted to use this code
  4. //   provided this declaration and copyright notice remains intact.
  5. //
  6. // 15 September 1995
  7. // Last modified 10 February 1996
  8.  
  9. #define NO_MAP
  10.  
  11. #include "iostream.h"
  12. //#include <fstream.h>
  13. //#include <iomanip.h>
  14. #include <stdlib.h>
  15. //#include <time.h>
  16. #include <string.h>
  17.  
  18.  
  19. #define SERVER  "http://snowwhite.it.brighton.ac.uk/"
  20. #define TRY_PROG "cgi-bin/mas/mas_try"
  21.  
  22. #include "parse.h"
  23. #include "parse.cpp"
  24.  
  25. void process_script( char [], bool );
  26.  
  27. inline void html( char str[] ) { cout << str << "\n"; }
  28.  
  29. inline void html_( char str[] ) { cout << str; }
  30.  
  31. inline void html_( char c ) { cout << c; }
  32.  
  33. // Main program
  34. //
  35.  
  36. int main()
  37. {
  38.   char *query_str = getenv("QUERY_STRING");
  39.   Parse list( query_str == 0 ? "feedback=xxx&nowrap" : query_str );
  40.  
  41.   process_script( list.get_item( "feedback" ), 
  42.                   list.get_item("nowrap")==NULL );
  43.   return 0;
  44. }
  45.  
  46.  
  47. void process_script( char mes[], bool wrap )
  48. {
  49.   html( "Content-type: text/html" );
  50.   html( "" ); html( "" );
  51.  
  52.   if( wrap )
  53.   {
  54.     html("<HTML>");
  55.   
  56.     html("<HEAD>");
  57.     html("<TITLE>Example of HTML</TITLE>");
  58.     html("</HEAD>");
  59.   
  60.     html("<BODY>");
  61.   
  62.     html("<H2>Result of processing the HTML</H2>");
  63.     html("<P>");
  64.     html("This before text allows you to see the effect "
  65.          "of the HTML in context.");
  66.   }
  67.   html( mes );
  68.   if ( wrap )
  69.   {
  70.     html("This after text allows you to see the effect "
  71.          "of the HTML in context.");
  72.   
  73.     html("</BODY>");
  74.     html("</HTML>");
  75.   }
  76. }
  77.