6 |
|
|
7 |
|
#include "Host.hpp" |
8 |
|
|
9 |
– |
#ifndef _WIN32 |
10 |
– |
|
11 |
– |
static char slash = '/'; |
12 |
– |
|
13 |
– |
#else |
14 |
– |
|
15 |
– |
static char slash = '\\'; |
16 |
– |
|
17 |
– |
#endif |
18 |
– |
|
9 |
|
Host::Host(const string& host, const string& name, const string& address, const |
10 |
|
string& platform) |
11 |
|
{ |
12 |
+ |
memset(&this->address, 0, sizeof(in_addr)); |
13 |
+ |
|
14 |
|
#ifdef _WIN32 |
15 |
|
if (count == 0) |
16 |
|
{ |
65 |
|
if (value == INADDR_NONE) |
66 |
|
{ |
67 |
|
cerr << "Host.setAddress(): INADDR_NONE\n"; |
76 |
– |
exit(1); |
68 |
|
} |
69 |
|
else |
70 |
|
{ |
117 |
|
getline(fin, name); |
118 |
|
|
119 |
|
string address; |
120 |
< |
|
120 |
> |
|
121 |
|
getline(fin, address); |
122 |
|
|
123 |
|
in_addr_t value = inet_addr(address.c_str()); |
125 |
|
if (value == INADDR_NONE) |
126 |
|
{ |
127 |
|
cerr << "Host.operator++(): INADDR_NONE\n"; |
137 |
– |
exit(1); |
128 |
|
} |
129 |
|
else |
130 |
|
{ |
150 |
|
Host Host::operator--() |
151 |
|
{ |
152 |
|
string file = string("hosts") + slash + host; |
153 |
< |
|
153 |
> |
|
154 |
|
ofstream fout(file.c_str()); |
155 |
|
|
156 |
|
fout << name << '\n' |