00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <exception>
00025 #include <iostream>
00026 #include <ctime>
00027
00028 #include "cgicc/Cgicc.h"
00029 #include "cgicc/HTTPResponseHeader.h"
00030 #include "cgicc/HTMLClasses.h"
00031
00032 #if HAVE_SYS_TIME_H
00033 # include <sys/time.h>
00034 #endif
00035
00036 using namespace std;
00037 using namespace cgicc;
00038
00039 int
00040 main(int ,
00041 char ** )
00042 {
00043 try {
00044 Cgicc cgi;
00045
00046
00047 char current_date [30];
00048 time_t now = time(&now);
00049 strftime(current_date, 30, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now));
00050
00051
00052 string server_string("GNU cgicc/");
00053 server_string += cgi.getVersion();
00054
00055
00056 cout << HTTPResponseHeader("HTTP/1.1", 200, "OK")
00057 .addHeader("Date", current_date)
00058 .addHeader("Server", server_string)
00059 .addHeader("Content-Language", "en")
00060 .addHeader("Content-Type", "text/html");
00061
00062 cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
00063
00064 cout << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\">" << endl;
00065 cout << "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">" << endl;
00066
00067 cout << "<head>" << endl;
00068
00069
00070 cout << "<style><!-- " << endl;
00071 cout << " body { color: black; background-color: white; }" << endl;
00072 cout << " span.red { color: red; }" << endl;
00073 cout << " --></style>" << endl;
00074
00075 cout << "<title>GNU cgicc v" << cgi.getVersion() << "</title>" << endl;
00076 cout << "</head>" << endl;
00077
00078 cout << "<body>" << endl;
00079 cout << "<h1>Hello, world from GNU cgi<span class=\"red\">cc</span> v";
00080 cout << cgi.getVersion() << "</h1>" << endl;
00081 cout << "</body></html>" << endl;
00082 }
00083
00084 catch(const exception& e) {
00085
00086 }
00087
00088 return 0;
00089 }