ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Bender/Bender.cpp
Revision: 114
Committed: 2004-03-16T14:33:08-08:00 (21 years, 3 months ago) by Douglas Thrift
File size: 1696 byte(s)
Log Message:
Stuff!

File Contents

# User Rev Content
1 Douglas Thrift 109 // Bender
2     //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #include "Bender.hpp"
8 Douglas Thrift 113 #include "Matcher.hpp"
9 Douglas Thrift 109
10 Douglas Thrift 113 #include <xalanc/Include/PlatformDefinitions.hpp>
11     #include <xercesc/util/PlatformUtils.hpp>
12     #include <xalanc/XalanTransformer/XalanTransformer.hpp>
13    
14     XALAN_USING_XERCES(XMLPlatformUtils)
15     XALAN_USING_XALAN(XalanTransformer)
16    
17 Douglas Thrift 109 int main(int argc, char* argv[])
18     {
19     XMLPlatformUtils::Initialize();
20     XalanTransformer::initialize();
21    
22     Bender bender;
23    
24     XalanTransformer::terminate();
25     XMLPlatformUtils::Terminate();
26     XalanTransformer::ICUCleanUp();
27    
28     return 0;
29     }
30    
31     Bender::Bender()
32     {
33 Douglas Thrift 111 string path = sgetenv("PATH_TRANSLATED");
34 Douglas Thrift 114 ifstream file(path.c_str());
35 Douglas Thrift 111
36 Douglas Thrift 114 if (path != "" && file.is_open())
37 Douglas Thrift 111 {
38 Douglas Thrift 114 string line;
39 Douglas Thrift 111
40 Douglas Thrift 114 do
41 Douglas Thrift 112 {
42 Douglas Thrift 114 getline(file, line);
43 Douglas Thrift 112
44 Douglas Thrift 114 buffer << line << "\n";
45 Douglas Thrift 112 }
46 Douglas Thrift 114 while (file.good());
47    
48     bend(sgetenv("HTTP_USER_AGENT"));
49 Douglas Thrift 111 }
50 Douglas Thrift 114 else
51     {
52     cout << "Status: 404\n"
53     << "Content-Type: text/html; charset=ISO-8859-1\n\n"
54     << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
55     << "<html><head>\n"
56     << "<title>404 Not Found</title>\n"
57     << "</head><body>\n"
58     << "<h1>Not Found</h1>\n"
59     << "<p>The requested URL " << sgetenv("PATH_INFO") << " was not fo"
60     << "und on this server.</p>\n"
61     << "<hr />\n"
62     << sgetenv("SERVER_SIGNATURE")
63     << "</body></html>\n";
64     }
65 Douglas Thrift 109 }
66 Douglas Thrift 114
67     void Bender::bend(const string& agent)
68     {
69     Matcher matcher;
70    
71     if (agent == matcher("/Opera |\\/(\\d+)\\.(\\d+)/"))
72     {
73     bend();
74     }
75     else if (agent == matcher(
76     "/^Mozilla/4.0 \\(compatible; MSIE (\\d+)\\.(\\d+)(\\w+)?; .*\\)$/"))
77     {
78     //
79     }
80     else if (agent == matcher(
81     "/^Mozilla/5.0 \\(.*; rv:(\\d+)\\.(\\d+)(\\.d+)?(\\w+)?\\) Gecko\\/.*/"
82     ))
83     {
84     //
85     }
86     else
87     {
88     bend();
89     }
90     }
91    
92     void Bender::bend(void)
93     {
94     //
95     }

Properties

Name Value
svn:eol-style native
svn:keywords Id