#include <iostream>#include <string>#include <vector>#include <map>#include <ctime>#include <cstdlib>#include "cgicc/Cgicc.h"#include "Sflex.hpp"#include "HttpResponseHeader.hpp"Include-Abhängigkeitsdiagramm für exec.cpp:

Funktionen | |
| std::string | getTime (int offset=0) |
| Liefert eine Zeitangabe. Mehr... | |
| int | main (int, char **) |
|
|
Liefert eine Zeitangabe. Die Zeitangabe wird in eine Zeichenkette umgewandelt, die dem Format des RFC 1123 entspricht (Mon, 06 May 1996 04:57:00 GMT).
00109 {
00110 using std::time;
00111 using std::time_t;
00112 using std::tm;
00113 using std::strftime;
00114
00115 char timeC[ 30 ];
00116 time_t time_now = time( 0 );
00117 time_now += offset;
00118 tm *date = localtime( &time_now );
00119 strftime( timeC, 30, "%a, %d %b %Y %X GMT", date );
00120
00121 return timeC;
00122 }
|
|
||||||||||||
|
00035 {
00036 using std::cout;
00037 using std::endl;
00038 using std::string;
00039 using std::vector;
00040 using std::map;
00041 using std::getenv;
00042 using cgicc::Cgicc;
00043 using cgicc::CgiEnvironment;
00044 using cgicc::FormEntry;
00045
00046 Cgicc cgi;
00047 const CgiEnvironment &env = cgi.getEnvironment();
00048 const vector< FormEntry > vFormEntries = cgi.getElements();
00049 vector< FormEntry >::const_iterator i;
00050 vector< FormEntry >::const_iterator iEnd = vFormEntries.end();
00051 map< string, string > cgiValueList;
00052 for ( i = vFormEntries.begin(); i != iEnd; ++i ) {
00053 cgiValueList[ i->getName() ] = i->getValue();
00054 }
00055
00056 string sflexConf;
00057 const char *conf = getenv("SFLEX_CONF");
00058 if ( conf ) {
00059 sflexConf = conf;
00060 }
00061 else {
00062 sflexConf = "";
00063 }
00064
00065 Sflex s( sflexConf );
00066
00067 s.init(
00068 env.getPathInfo(),
00069 env.getScriptName(),
00070 cgiValueList
00071 );
00072
00073 s.makeResult();
00074 const string body = s.getResult();
00075
00076 HttpResponseHeader h( s.getContentType() );
00077 h.addHeader( "Content-Length", body.length() );
00078 h.addHeader( "Status", "200 OK" );
00079 h.addHeader( "Last-Modified", getTime() );
00080 if ( s.isSuccess() ) {
00081 h.addHeader( "Cache-Control", "public, max-age=30000" );
00082 h.addHeader( "Expires", getTime( 3600*24*30 ) );
00083 }
00084 else {
00085 h.addHeader( "Cache-Control", "no-cache" );
00086 h.addHeader( "Expires", getTime() );
00087 }
00088
00089 cout << h.getHeaders()
00090 << endl
00091 << body;
00092
00093 return 0;
00094 }
|
1.2.14 geschrieben von Dimitri van Heesch,
© 1997-2002