Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
main.cpp
1
2
/***************************************************************************
3
* main.cpp - Fawkes plugin tool main
4
*
5
* Created: Tue Nov 22 00:25:26 2006
6
* Copyright 2006 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#include "plugin_tool.h"
24
#include <netcomm/fawkes/client.h>
25
26
#include <core/threading/thread.h>
27
#include <utils/system/argparser.h>
28
#include <utils/system/signal.h>
29
30
#include <string>
31
#include <cstdlib>
32
#include <cstdio>
33
34
using namespace
fawkes;
35
36
int
37
main(
int
argc,
char
**argv)
38
{
39
ArgumentParser
argp(argc, argv,
"hl:u:R:waLr:"
);
40
41
if
( argp.has_arg(
"h"
) ) {
42
PluginTool::print_usage
(argp.program_name());
43
exit(0);
44
}
45
46
Thread::init_main
();
47
48
std::string host =
"localhost"
;
49
unsigned
short
int
port = 1910;
50
if
( argp.has_arg(
"r"
) ) {
51
argp.parse_hostport(
"r"
, host, port);
52
}
53
54
FawkesNetworkClient
*c =
new
FawkesNetworkClient
(host.c_str(), port);
55
try
{
56
c->
connect
();
57
}
catch
(
Exception
&e ) {
58
printf(
"Could not connect to host: %s\n"
, host.c_str());
59
exit(1);
60
}
61
62
PluginTool
*pt =
new
PluginTool
(&argp, c);
63
SignalManager::register_handler
(SIGINT, pt);
64
pt->
run
();
65
SignalManager::finalize
();
66
delete
pt;
67
68
c->
disconnect
();
69
delete
c;
70
71
Thread::destroy_main
();
72
73
return
0;
74
}
src
tools
plugin
main.cpp
Generated by
1.8.1.1