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

Comparing Smersh/Daemon.hpp (file contents):
Revision 173 by Douglas Thrift, 2004-06-21T03:15:47-07:00 vs.
Revision 179 by Douglas Thrift, 2004-07-02T21:16:12-07:00

# Line 9 | Line 9
9  
10   #include <menes-api/socket.hpp>
11   #include <menes-api/threads.hpp>
12 + #include <menes-etl/fnbind.hpp>
13 + #include <menes-ios/stdadapters.hpp>
14  
15 + #include "Matcher.hpp"
16   #include "Person.hpp"
17  
18   class Daemon
19   {
20 + protected:
21 +        struct Client { api::TcpSocket socket; api::InternetAddress ip; Client() :
22 +                ip(api::InternetAddress::Any) {} };
23 + private:
24 +        virtual int handle(Client* client);
25 +        void headers(istream& sin, Environment& env);
26 + protected:
27 +        enum Status { ok = 200, found = 302, seeOther, bad = 400, notFound = 404,
28 +                lengthRequired = 411, mediaType = 415, serverError = 500,
29 +                notImplemented, version = 505 };
30   private:
31 <        virtual int handle();
31 >        Status message(istream& sin, Environment& env, ostream& post);
32 >        string reason(Status status);
33   protected:
34 <        Daemon() {}
34 >        static string crlf;
35 >        string log;
36 >        Daemon(const string& log) : log(log) {}
37          void serve(int port, bool fork, Daemon* self);
38 +        istream& getline(istream& sin, string& line) { std::getline(sin, line,
39 +                '\r'); sin.get(); return sin; }
40 +        Status request(istream& sin, Environment& env, ostream& post, ostream& log);
41 +        void response(ostream& sout, Status status);
42 +        string server();
43 +        streamsize error(ostream& sout, Status status);
44 +        string date(bool log = false);
45   public:
46 <        Daemon(int port, bool fork) { Person::configure(); serve(port, fork, this);
47 <        }
46 >        Daemon(int port, bool fork, const string& log) : log(log) {
47 >                Person::configure(); serve(port, fork, this); }
48          virtual ~Daemon() {}
49   };
50  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines