main.cpp

00001
00002 /***************************************************************************
00003  *  main.cpp - Fawkes plugin tool main
00004  *
00005  *  Created: Tue Nov 22 00:25:26 2006
00006  *  Copyright  2006  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
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 <cstdlib>
00031
00032 using namespace fawkes;
00033
00034 int
00035 main(int argc, char **argv)
00036 {
00037   ArgumentParser argp(argc, argv, "hl:u:r:waL");
00038
00039   if ( argp.has_arg("h") ) {
00040     PluginTool::print_usage(argp.program_name());
00041     exit(0);
00042   }
00043
00044   Thread::init_main();
00045
00046   FawkesNetworkClient *c = new FawkesNetworkClient("localhost", 1910);
00047   c->connect();
00048
00049   PluginTool *pt = new PluginTool(&argp, c);
00050   SignalManager::register_handler(SIGINT, pt);
00051   pt->run();
00052   SignalManager::finalize();
00053   delete pt;
00054
00055   c->disconnect();
00056   delete c;
00057
00058   Thread::destroy_main();
00059
00060   return 0;
00061 }