ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Bender/Bender.cpp
(Generate patch)

Comparing Bender/Bender.cpp (file contents):
Revision 113 by Douglas Thrift, 2004-03-16T12:31:22-08:00 vs.
Revision 114 by Douglas Thrift, 2004-03-16T14:33:08-08:00

# Line 31 | Line 31 | int main(int argc, char* argv[])
31   Bender::Bender()
32   {
33          string path = sgetenv("PATH_TRANSLATED");
34 +        ifstream file(path.c_str());
35  
36 <        if (path != "")
36 >        if (path != "" && file.is_open())
37          {
38 <                cout << "Content-Type: text/html\n\n";
38 >                string line;
39                  
40 <                XalanTransformer transformer;
40 <
41 <                if (transformer.transform(path.c_str(), cout) != 0)
40 >                do
41                  {
42 <                        ifstream fin(path.c_str());
44 <                        string line;
45 <
46 <                        do
47 <                        {
48 <                                getline(fin, line);
42 >                        getline(file, line);
43  
44 <                                cout << line << "\n";
51 <                        }
52 <                        while (fin.good());
44 >                        buffer << line << "\n";
45                  }
46 +                while (file.good());
47 +                
48 +                bend(sgetenv("HTTP_USER_AGENT"));
49 +        }
50 +        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 + }
66 +
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines