mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
Documentation update.
Code cleanup.
This commit is contained in:
parent
257988539a
commit
d02dd4eb0a
@ -75,7 +75,8 @@ Application::~Application(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes events (e.g. sockets and timers).
|
||||
* Processes events for registered sockets and timers and calls whatever
|
||||
* handlers have been set up for these events.
|
||||
*/
|
||||
void Application::RunEventLoop(void)
|
||||
{
|
||||
@ -274,18 +275,18 @@ void Application::UnregisterComponent(Component::Ptr component)
|
||||
* @param name The name of the component.
|
||||
* @returns The component or a null pointer if the component could not be found.
|
||||
*/
|
||||
Component::Ptr Application::GetComponent(const string& name)
|
||||
Component::Ptr Application::GetComponent(const string& name) const
|
||||
{
|
||||
map<string, Component::Ptr>::iterator ci = m_Components.find(name);
|
||||
map<string, Component::Ptr>::const_iterator i = m_Components.find(name);
|
||||
|
||||
if (ci == m_Components.end())
|
||||
if (i == m_Components.end())
|
||||
return Component::Ptr();
|
||||
|
||||
return ci->second;
|
||||
return i->second;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message.
|
||||
* Writes a message to the application's log.
|
||||
*
|
||||
* @param message The message.
|
||||
*/
|
||||
@ -408,11 +409,12 @@ bool Application::IsDebugging(void) const
|
||||
|
||||
#ifndef _WIN32
|
||||
/**
|
||||
* Signal handler for SIGINT.
|
||||
* Signal handler for SIGINT. Prepares the application for cleanly
|
||||
* shutting down during the next execution of the event loop.
|
||||
*
|
||||
* @param signum The signal number.
|
||||
*/
|
||||
static void ApplicationSigIntHandler(int signum)
|
||||
void Application::SigIntHandler(int signum)
|
||||
{
|
||||
assert(signum == SIGINT);
|
||||
|
||||
@ -442,7 +444,7 @@ int Application::Run(int argc, char **argv)
|
||||
#ifndef _WIN32
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = ApplicationSigIntHandler;
|
||||
sa.sa_handler = Application::SigIntHandler;
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
|
||||
sa.sa_handler = SIG_IGN;
|
||||
|
@ -41,6 +41,10 @@ private:
|
||||
vector<string> m_Arguments; /**< Command-line arguments */
|
||||
bool m_Debugging; /**< Whether debugging is enabled. */
|
||||
|
||||
#ifndef _WIN32
|
||||
static void SigIntHandler(int signum);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
protected:
|
||||
void RunEventLoop(void);
|
||||
string GetExeDirectory(void) const;
|
||||
@ -68,7 +72,7 @@ public:
|
||||
const ConfigObject::Ptr& componentConfig);
|
||||
void RegisterComponent(shared_ptr<Component> component);
|
||||
void UnregisterComponent(shared_ptr<Component> component);
|
||||
shared_ptr<Component> GetComponent(const string& name);
|
||||
shared_ptr<Component> GetComponent(const string& name) const;
|
||||
void AddComponentSearchDir(const string& componentDirectory);
|
||||
|
||||
bool IsDebugging(void) const;
|
||||
|
@ -13,22 +13,18 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="application.cpp" />
|
||||
<ClCompile Include="component.cpp" />
|
||||
<ClCompile Include="condvar.cpp" />
|
||||
<ClCompile Include="configcollection.cpp" />
|
||||
<ClCompile Include="confighive.cpp" />
|
||||
<ClCompile Include="configobject.cpp" />
|
||||
<ClCompile Include="dictionary.cpp" />
|
||||
<ClCompile Include="exception.cpp" />
|
||||
<ClCompile Include="fifo.cpp" />
|
||||
<ClCompile Include="lock.cpp" />
|
||||
<ClCompile Include="memory.cpp" />
|
||||
<ClCompile Include="mutex.cpp" />
|
||||
<ClCompile Include="object.cpp" />
|
||||
<ClCompile Include="socket.cpp" />
|
||||
<ClCompile Include="tcpclient.cpp" />
|
||||
<ClCompile Include="tcpserver.cpp" />
|
||||
<ClCompile Include="tcpsocket.cpp" />
|
||||
<ClCompile Include="thread.cpp" />
|
||||
<ClCompile Include="timer.cpp" />
|
||||
<ClCompile Include="tlsclient.cpp" />
|
||||
<ClCompile Include="unix.cpp" />
|
||||
@ -39,14 +35,12 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="application.h" />
|
||||
<ClInclude Include="component.h" />
|
||||
<ClInclude Include="condvar.h" />
|
||||
<ClInclude Include="configcollection.h" />
|
||||
<ClInclude Include="confighive.h" />
|
||||
<ClInclude Include="configobject.h" />
|
||||
<ClInclude Include="cxx11-compat.h" />
|
||||
<ClInclude Include="delegate.h" />
|
||||
<ClInclude Include="dictionary.h" />
|
||||
<ClInclude Include="lock.h" />
|
||||
<ClInclude Include="observable.h" />
|
||||
<ClInclude Include="exception.h" />
|
||||
<ClInclude Include="fifo.h" />
|
||||
@ -57,7 +51,6 @@
|
||||
<ClInclude Include="tcpclient.h" />
|
||||
<ClInclude Include="tcpserver.h" />
|
||||
<ClInclude Include="tcpsocket.h" />
|
||||
<ClInclude Include="thread.h" />
|
||||
<ClInclude Include="timer.h" />
|
||||
<ClInclude Include="tlsclient.h" />
|
||||
<ClInclude Include="unix.h" />
|
||||
@ -65,9 +58,6 @@
|
||||
<ClInclude Include="variant.h" />
|
||||
<ClInclude Include="win32.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="mutex.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9C92DA90-FD53-43A9-A244-90F2E8AF9677}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
* Retrieves a value from the dictionary.
|
||||
*
|
||||
* @param key The key.
|
||||
* @param value Pointer to the value.
|
||||
* @param[out] value Pointer to the value.
|
||||
* @returns true if the value was retrieved, false otherwise.
|
||||
*/
|
||||
template<typename T>
|
||||
|
@ -10,6 +10,7 @@ configfile_la_SOURCES = \
|
||||
|
||||
configfile_la_CXXFLAGS = \
|
||||
-I${top_srcdir}/base \
|
||||
-I${top_srcdir}/icinga \
|
||||
-I${top_srcdir}/jsonrpc \
|
||||
-I${top_srcdir}/cJSON
|
||||
|
||||
@ -20,4 +21,5 @@ configfile_la_LDFLAGS = \
|
||||
|
||||
configfile_la_LIBADD = \
|
||||
$(top_builddir)/base/libbase.la \
|
||||
$(top_builddir)/icinga/libicinga.la \
|
||||
$(top_builddir)/cJSON/libcJSON.la
|
||||
|
@ -45,11 +45,11 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(SolutionDir)\base;$(SolutionDir)\cJSON;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)\base;$(SolutionDir)\jsonrpc;$(SolutionDir)\icinga;$(SolutionDir)\cJSON;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(SolutionDir)\base;$(SolutionDir)\cJSON;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)\base;$(SolutionDir)\jsonrpc;$(SolutionDir)\icinga;$(SolutionDir)\cJSON;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
@ -63,7 +63,7 @@
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>
|
||||
@ -86,7 +86,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>$(OutDir)\base.lib;$(OutDir)\jsonrpc.lib</AdditionalDependencies>
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define I2CONFIGFILECOMPONENT_H
|
||||
|
||||
#include <i2-base.h>
|
||||
#include <i2-icinga.h>
|
||||
|
||||
#include "configfilecomponent.h"
|
||||
|
||||
|
@ -11,7 +11,6 @@ configrpc_la_SOURCES = \
|
||||
configrpc_la_CXXFLAGS = \
|
||||
-I${top_srcdir}/base \
|
||||
-I${top_srcdir}/jsonrpc \
|
||||
-I${top_srcdir}/cJSON \
|
||||
-I${top_srcdir}/icinga
|
||||
|
||||
configrpc_la_LDFLAGS = \
|
||||
@ -22,5 +21,4 @@ configrpc_la_LDFLAGS = \
|
||||
configrpc_la_LIBADD = \
|
||||
${top_builddir}/base/libbase.la \
|
||||
${top_builddir}/jsonrpc/libjsonrpc.la \
|
||||
${top_builddir}/cJSON/libcJSON.la \
|
||||
${top_builddir}/icinga/libicinga.la
|
||||
|
@ -21,7 +21,15 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
/* based on https://github.com/PeterScott/netstring-c/blob/master/netstring.c */
|
||||
/**
|
||||
* Reads data from a FIFO in netstring format.
|
||||
*
|
||||
* @param fifo The FIFO to read from.
|
||||
* @param[out] str The string that has been read from the FIFO.
|
||||
* @returns true if a complete string was read from the FIFO, false otherwise.
|
||||
* @exception InvalidNetstringException The input stream is invalid.
|
||||
* @see https://github.com/PeterScott/netstring-c/blob/master/netstring.c
|
||||
*/
|
||||
bool Netstring::ReadStringFromFIFO(FIFO::Ptr fifo, string *str)
|
||||
{
|
||||
size_t buffer_length = fifo->GetSize();
|
||||
@ -66,6 +74,12 @@ bool Netstring::ReadStringFromFIFO(FIFO::Ptr fifo, string *str)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes data into a FIFO using the netstring format.
|
||||
*
|
||||
* @param fifo The FIFO.
|
||||
* @param str The string that is to be written.
|
||||
*/
|
||||
void Netstring::WriteStringToFIFO(FIFO::Ptr fifo, const string& str)
|
||||
{
|
||||
unsigned long len = str.size();
|
||||
|
@ -23,6 +23,11 @@
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
/**
|
||||
* Thrown when an invalid netstring was encountered while reading from a FIFO.
|
||||
*/
|
||||
DEFINE_EXCEPTION_CLASS(InvalidNetstringException);
|
||||
|
||||
/**
|
||||
* Utility functions for reading/writing messages in the netstring format.
|
||||
* See http://cr.yp.to/proto/netstrings.txt for details.
|
||||
|
Loading…
x
Reference in New Issue
Block a user