3 #include "Initializer.h"
5 #include "program/ElfAnalyzer.h"
6 #include "network/TcpManager.h"
8 Initializer
*Initializer::m_singleton
= 0;
10 Initializer::Initializer(char *argv
[]) : m_argv(argv
) {
12 m_configuration
= new Misc::Configuration(m_argv
);
13 m_moduleMapper
= new Module::ModuleMapper();
14 m_socketManager
= NULL
;
16 m_socketManager
= NULL
;
19 Initializer::~Initializer() {
20 if(m_launcher
) delete m_launcher
;
21 if(m_socketManager
) delete m_socketManager
;
22 if(m_moduleMapper
) delete m_moduleMapper
;
23 if(m_configuration
) delete m_configuration
;
26 int Initializer::run() {
27 if(m_configuration
->traverse("help")->asBool()) {
31 else if(m_configuration
->launchArguments().size() == 0) {
32 LogSystem::logConfigurationMessage("No filename specified. Displaying usage information.");
37 m_socketManager
= new Network::TcpManager(m_configuration
->traverse("tcpPort")->asInt());
38 m_socketManager
->waitForConnections(m_configuration
->traverse("networkWait")->asInt());
40 m_launcher
= new Program::Launcher();
44 return m_launcher
->returnCode();
47 void Initializer::usage() {
48 std::cout
<< "Aesalon version " << AesalonVersion
<< ". Copyright (C) 2009-2010, strange." << std::endl
;
49 std::cout
<< "This program is released under the GNU GPLv3. " << std::endl
;
50 std::cout
<< "\tFor more legal information, see the included file LICENSE." << std::endl
;
51 std::cout
<< "usage: " << m_argv
[0] << " [options] [--] filename [arguments]" << std::endl
;
53 std::cout
<< "\nOptions:" << std::endl
;
54 std::cout
<< "\t--help: displays this help message." << std::endl
;
55 std::cout
<< "\t--networkWait: amount of network clients to wait for before executing." << std::endl
;
56 std::cout
<< "\t--tcpPort: TCP port to listen on." << std::endl
;
57 std::cout
<< "\t--logFile: optional log file to write collected data to." << std::endl
;
58 std::cout
<< "\t--shmSize: size of the SHM used to communicate." << std::endl
;
60 std::cout
<< "\nEnvironment variables:" << std::endl
;
61 std::cout
<< "\tAesalonSearchPath: a colon-separated path to search for modules." << std::endl
;