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

Comparing FeepingCreaturism/FeepingCreaturism.cpp (file contents):
Revision 194 by Douglas Thrift, 2004-08-27T01:21:18-07:00 vs.
Revision 198 by Douglas Thrift, 2004-08-30T18:09:53-07:00

# Line 6 | Line 6
6  
7   #include "Environment.hpp"
8   #include "Matcher.hpp"
9 + #include "Jargon.hpp"
10  
11   extern "C"
12   {
# Line 28 | Line 29 | FeepingCreaturism::FeepingCreaturism()
29          std::string path(env.get("PATH_INFO"));
30          Matcher matcher;
31  
32 <        if (path.empty()) daily(); else if (path == "/random")
32 >        if (path == "/daily/") daily(); else if (path == "/random/")
33          {
34                  random();
35          }
# Line 36 | Line 37 | FeepingCreaturism::FeepingCreaturism()
37          {
38                  select(matcher[1], true);
39          }
40 <        else daily();
40 >        else
41 >        {
42 >                cout << "Status: 301\r\n";
43 >        }
44   }
45  
46   void FeepingCreaturism::initialize()
# Line 54 | Line 58 | void FeepingCreaturism::initialize()
58          ::FTS* traversal(::fts_open(path, FTS_LOGICAL, NULL));
59          Matcher matcher('^' + this->path + "/(" + this->matcher + ")$");
60  
61 +        if (traversal == NULL)
62 +        {
63 +                cerr << "FeepingCreaturism: Horrible Failure!\n";
64 +
65 +                std::exit(1);
66 +        }
67 +
68          for (::FTSENT* entity(::fts_read(traversal)); entity != NULL;
69                  entity = ::fts_read(traversal))
70          {
# Line 98 | Line 109 | void FeepingCreaturism::select(const std
109   {
110          if (!validate || jargon.find(selection) != jargon.end())
111          {
112 <                cout << "Content-Type: text/html; charset=UTF-8\r\n\r\n" << selection
113 <                        << "\r\n";
112 >                cout << "Content-Type: text/html; charset=UTF-8\r\n\r\n";
113 >
114 >                Jargon jargon(path + '/' + selection);
115 >
116 >                cout << jargon;
117 >        }
118 >        else
119 >        {
120 >                cout << "Status: 404\r\nContent-Type: text/html; charset=ISO-8859-1\r\n"
121 >                        << "\r\n<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
122 >                        << "<html><head>\n<title>404 Not Found</title>\n</head><body>\n"
123 >                        << "<h1>Not Found</h1>\n<p>The requested URL "
124 >                        << env.get("PATH_INFO") << " was not found on this server.</p>\n"
125 >                        << "<hr />\n" << env.get("SERVER_SIGNATURE") << "</body></html>\n";
126          }
104        else cout << "Status: 404\r\n\r\n";
127   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines