00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "plugin_tool.h"
00024 #include <netcomm/fawkes/client.h>
00025
00026 #include <core/threading/thread.h>
00027 #include <utils/system/argparser.h>
00028 #include <utils/system/signal.h>
00029
00030 #include <string>
00031 #include <cstdlib>
00032 #include <cstdio>
00033
00034 using namespace fawkes;
00035
00036 int
00037 main(int argc, char **argv)
00038 {
00039 ArgumentParser argp(argc, argv, "hl:u:R:waLr:");
00040
00041 if ( argp.has_arg("h") ) {
00042 PluginTool::print_usage(argp.program_name());
00043 exit(0);
00044 }
00045
00046 Thread::init_main();
00047
00048 std::string host = "localhost";
00049 unsigned short int port = 1910;
00050 if ( argp.has_arg("r") ) {
00051 argp.parse_hostport("r", host, port);
00052 }
00053
00054 FawkesNetworkClient *c = new FawkesNetworkClient(host.c_str(), port);
00055 try {
00056 c->connect();
00057 } catch( Exception &e ) {
00058 printf("Could not connect to host: %s\n", host.c_str());
00059 exit(1);
00060 }
00061
00062 PluginTool *pt = new PluginTool(&argp, c);
00063 SignalManager::register_handler(SIGINT, pt);
00064 pt->run();
00065 SignalManager::finalize();
00066 delete pt;
00067
00068 c->disconnect();
00069 delete c;
00070
00071 Thread::destroy_main();
00072
00073 return 0;
00074 }