// Bender // // Douglas Thrift // // $Id$ #include "Bender.hpp" #include "Matcher.hpp" #include #include #include XALAN_USING_XERCES(XMLPlatformUtils) XALAN_USING_XALAN(XalanTransformer) int main(int argc, char* argv[]) { XMLPlatformUtils::Initialize(); XalanTransformer::initialize(); Bender bender; XalanTransformer::terminate(); XMLPlatformUtils::Terminate(); XalanTransformer::ICUCleanUp(); return 0; } Bender::Bender() { string path = sgetenv("PATH_TRANSLATED"); ifstream file(path.c_str()); if (path != "" && file.is_open()) { string line; do { getline(file, line); buffer << line << "\n"; } while (file.good()); bend(sgetenv("HTTP_USER_AGENT")); } else { cout << "Status: 404\n" << "Content-Type: text/html; charset=ISO-8859-1\n\n" << "\n" << "\n" << "404 Not Found\n" << "\n" << "

Not Found

\n" << "

The requested URL " << sgetenv("PATH_INFO") << " was not fo" << "und on this server.

\n" << "
\n" << sgetenv("SERVER_SIGNATURE") << "\n"; } } void Bender::bend(const string& agent) { Matcher matcher; if (agent == matcher("/Opera |\\/(\\d+)\\.(\\d+)/")) { bend(); } else if (agent == matcher( "/^Mozilla/4.0 \\(compatible; MSIE (\\d+)\\.(\\d+)(\\w+)?; .*\\)$/")) { // } else if (agent == matcher( "/^Mozilla/5.0 \\(.*; rv:(\\d+)\\.(\\d+)(\\.d+)?(\\w+)?\\) Gecko\\/.*/" )) { // } else { bend(); } } void Bender::bend(void) { // }