1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include <iostream>
#include <bobcat/hostname>
#include <bobcat/exception>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
{
while (true)
{
cout << "Enter name or address:\n";
string str;
if (!getline(cin, str))
return 0;
if (str == "")
break;
try
{
Hostname h(str);
cout << "Official name:\n";
cout << h.hostname() << endl;
cout << "Aliases:\n";
for (size_t idx = 0; idx < h.nAliases(); idx++)
cout << h.alias(idx) << " ";
cout << endl;
cout << "Adresses:\n";
for (size_t idx = 0; idx < h.nAddresses(); idx++)
cout << h.dottedDecimalAddress(idx) << " ";
cout << endl;
}
catch (exception const &err)
{
cout << err.what() << endl;
}
}
}
|