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

Comparing HostUpdate/Host.cpp (file contents):
Revision 11 by Douglas Thrift, 2003-11-06T20:37:52-08:00 vs.
Revision 13 by Douglas Thrift, 2003-11-07T12:17:57-08:00

# Line 6 | Line 6
6  
7   #include "Host.hpp"
8  
9 < Host::Host(const string& host, const string& name, const string& address)
9 > Host::Host(const string& host, const string& name, const string& address, const
10 >        string& platform)
11   {
12   #ifdef _WIN32
13          if (count == 0)
# Line 26 | Line 27 | Host::Host(const string& host, const str
27          setHost(host);
28          if (name != "") setName(name, address == "");
29          if (address != "") setAddress(address, name == "");
30 +        setPlatform(platform);
31   }
32  
33   Host::~Host()
# Line 74 | Line 76 | void Host::setAddress(const string& addr
76  
77          if (lookup)
78          {
77                cerr << "Here!\n";
79                  struct hostent* ent = gethostbyaddr((char*)(this->address),
80                          sizeof(in_addr), AF_INET);
81  
82 <                name = ent->h_name;
82 >                if (ent != NULL) name = ent->h_name;
83          }
84   }
85  
86 < void Host::operator++()
86 > bool Host::operator==(const Host& host) const
87 > {
88 >        if (this->host == host.host)
89 >        {
90 >                if (name == host.name)
91 >                {
92 >                        if (address == host.address)
93 >                        {
94 >                                return platform == host.platform;
95 >                        }
96 >                        else
97 >                        {
98 >                                return false;
99 >                        }
100 >                }
101 >                else
102 >                {
103 >                        return false;
104 >                }
105 >        }
106 >        else
107 >        {
108 >                return false;
109 >        }
110 > }
111 >
112 > Host Host::operator++()
113   {
114          ifstream fin(host.c_str());
115  
116 <        getline(fin, name);
116 >        if (fin.is_open())
117 >        {
118 >                getline(fin, name);
119 >                fin.read((char*)(address), sizeof(in_addr));
120 >                getline(fin, platform);
121 >                fin.close();
122 >        }
123  
124 <        fin.read((char*)(address), sizeof(in_addr));
92 <        fin.close();
124 >        return *this;
125   }
126  
127 < void Host::operator--()
127 > Host Host::operator++(int)
128 > {
129 >        Host old = *this;
130 >
131 >        ++*this;
132 >
133 >        return old;
134 > }
135 >
136 > Host Host::operator--()
137   {
138          ofstream fout(host.c_str());
139  
140          fout << name << '\n';
141  
142          fout.write((char*)(address), sizeof(in_addr));
143 +
144 +        fout << platform;
145 +
146          fout.close();
147 +
148 +        return *this;
149 + }
150 +
151 + Host Host::operator--(int)
152 + {
153 +        Host old = *this;
154 +
155 +        --*this;
156 +
157 +        return old;
158   }
159  
160   #ifdef _WIN32

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines