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

Comparing HostUpdate/HostUpdate.cpp (file contents):
Revision 12 by Douglas Thrift, 2003-11-06T23:43:01-08:00 vs.
Revision 14 by Douglas Thrift, 2003-11-07T23:04:39-08:00

# Line 32 | Line 32 | HostUpdate::HostUpdate()
32          string agent = env.getUserAgent();
33          string method = env.getRequestMethod();
34  
35 <        if (agent.find("Host Update/") == 0 && method == "GET" && agent.find(" (")
35 >        if (agent.find("Host Update/") == 0 && method == "POST" && agent.find(" (")
36                  != string::npos && agent.find(") libwww-perl/") != string::npos)
37          {
38                  update(env, agent);
# Line 57 | Line 57 | void HostUpdate::update(CgiEnvironment&
57          if (!cgi.getElement("host", entries)) return;
58          if (entries[0].isEmpty()) return;
59  
60 <        string host = entries[0].getStrippedValue();
61 <        string name = env.getRemoteHost();
62 <        string address = env.getRemoteAddr();
60 >        string host = entries[0].getStrippedValue(), name = env.getRemoteHost(),
61 >                address = env.getRemoteAddr();
62  
63          if (name == address) name = "";
64  
65 <        string::size_type begin = agent.find('(') + 1, end = agent.find(begin, ')');
65 >        string::size_type begin = agent.find('(') + 1, end = agent.find(')',
66 >                begin);
67          string platform = agent.substr(begin, end - begin);
68 +
69 +        cout << "host=" << host << '\n'
70 +                << "name=" << name << '\n'
71 +                << "address=" << address << '\n'
72 +                << "platform=" << platform << '\n';
73 +
74 +        Host client(host, name, address, platform), saved(host);
75 +
76 +        if (client != ++saved) client--;
77   }
78  
79   void HostUpdate::display(CgiEnvironment& env)
80   {
81 <        //
81 >        cout << "Content-Type: text/plain\n\n";
82 >
83 >        set<Host> hosts;
84 >        DIR* dir = opendir(".");
85 >        struct dirent* ent;
86 >
87 >        while ((ent = readdir(dir)) != NULL)
88 >        {
89 >                string file = ent->d_name;
90 >
91 >                cerr << file << '\n';
92 >
93 >                if (file == "." || file == "..") continue;
94 >                
95 >                Host host(file);
96 >
97 >                hosts.insert(++host);
98 >        }
99 >        
100 >        closedir(dir);
101 >
102 >        for (set<Host>::iterator itor = hosts.begin(); itor != hosts.end(); itor++)
103 >        {
104 >                Host host = *itor;
105 >
106 >                cout << "host=" << host.getHost() << '\n'
107 >                        << "name=" << host.getName() << '\n'
108 >                        << "address=" << host.getAddress() << '\n'
109 >                        << "platform=" << host.getPlatform() << "\n\n";
110 >        }
111   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines