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 164 by Douglas Thrift, 2004-06-17T22:12:33-07:00 vs.
Revision 178 by Douglas Thrift, 2004-06-29T13:15:51-07:00

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines