root/hydranode/hnbase/test/test-resolver.cpp

Revision 2613, 1.7 kB (checked in by madcat, 3 years ago)

Copyright notice update for 2006.

Line 
1 /*
2  *  Copyright (C) 2005-2006 Alo Sarv <madcat_@users.sourceforge.net>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 /**
20  * \file test-resolver.cpp Resolver test
21  */
22
23 #include <iostream>
24 #include <hnbase/hostinfo.h>
25 #include <hnbase/timed_callback.h>
26
27 //class IMPORT HostInfo;
28 //void IMPORT lookup(const std::string&, HostInfo::HandlerType);
29
30 int pending = 0;
31 void foo(HostInfo info) {
32         --pending;
33         logMsg(boost::format("Name: %s") % info.getName());
34         logMsg(boost::format("ErrorState: %s (%s)") % info.error() % info.errorMsg());
35         for (HostInfo::Iter it = info.begin(); it != info.end(); ++it) {
36                 logMsg(boost::format("Address: %s") % (*it).getAddrStr());
37         }
38         std::vector<std::string> aliases = info.getAliases();
39         for (uint32_t i = 0; i < aliases.size(); ++i) {
40                 logMsg(boost::format("Alias: %s") % aliases[i]);
41         }
42 }
43
44 int main(int argc, char *argv[]) {
45         Utils::TimedCallback::instance();
46         for (int i = 1; i < argc; ++i) {
47                 ++pending;
48                 DNS::lookup(argv[i], boost::bind(&foo, _1));
49         }
50         while (pending) {
51                 EventMain::instance().process();
52         }
53         return 0;
54 }
Note: See TracBrowser for help on using the browser.