From 43b38f5a8543c3fe29c9c9070449fcae2fad12ea Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 1 Apr 2012 09:48:52 +0200 Subject: [PATCH] Fixed compilation errors with automake/gcc --- Makefile.am | 5 +++-- base/confighive.cpp | 4 ++-- base/confighive.h | 2 +- base/configobject.cpp | 14 +++++++------- base/configobject.h | 6 +++--- base/i2-base.h | 10 ++++++---- base/mutex.cpp | 10 +++++----- base/thread.h | 2 -- base/unix.h | 3 +++ configfilecomponent/Makefile.am | 4 +++- configfilecomponent/configfilecomponent.cpp | 2 +- configrpccomponent/Makefile.am | 4 +++- configrpccomponent/configrpccomponent.cpp | 8 ++++---- configure.ac | 6 +++++- icinga/Makefile.am | 6 +++--- icinga/icingaapplication.cpp | 8 ++++---- 16 files changed, 53 insertions(+), 41 deletions(-) diff --git a/Makefile.am b/Makefile.am index b9c1b3f55..dd469cf65 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,11 +1,12 @@ ## Process this file with automake to produce Makefile.in ## Created by Anjuta -SUBDIRS = base \ +SUBDIRS = ltdl \ + base \ + jsonrpc \ configfilecomponent \ configrpccomponent \ icinga \ - jsonrpc \ miniapp icinga2docdir = ${prefix}/doc/icinga2 diff --git a/base/confighive.cpp b/base/confighive.cpp index 7c454a1f1..1aaf740ff 100644 --- a/base/confighive.cpp +++ b/base/confighive.cpp @@ -19,7 +19,7 @@ void ConfigHive::AddObject(ConfigObject::RefType object) ConfigHiveEventArgs::RefType ea = new_object(); ea->Source = shared_from_this(); - ea->ConfigObject = object; + ea->Object = object; OnObjectCreated(ea); } @@ -35,7 +35,7 @@ void ConfigHive::RemoveObject(ConfigObject::RefType object) ConfigHiveEventArgs::RefType ea = new_object(); ea->Source = shared_from_this(); - ea->ConfigObject = object; + ea->Object = object; OnObjectRemoved(ea); } diff --git a/base/confighive.h b/base/confighive.h index 5286077e9..bd0c3523e 100644 --- a/base/confighive.h +++ b/base/confighive.h @@ -13,7 +13,7 @@ struct ConfigHiveEventArgs : public EventArgs typedef shared_ptr RefType; typedef weak_ptr WeakRefType; - ConfigObject::RefType ConfigObject; + ConfigObject::RefType Object; string Property; string OldValue; }; diff --git a/base/configobject.cpp b/base/configobject.cpp index 94834f0e1..838d19a9e 100644 --- a/base/configobject.cpp +++ b/base/configobject.cpp @@ -42,33 +42,33 @@ void ConfigObject::SetProperty(const string& name, const string& value) if (hive.get() != NULL) { ConfigHiveEventArgs::RefType ea = new_object(); ea->Source = hive; - ea->ConfigObject = static_pointer_cast(shared_from_this()); + ea->Object = static_pointer_cast(shared_from_this()); ea->Property = name; ea->OldValue = oldValue; hive->OnPropertyChanged(ea); } } -string ConfigObject::GetProperty(const string& name, const string& default) const +string ConfigObject::GetProperty(const string& name, const string& defaultValue) const { map::const_iterator vi = Properties.find(name); if (vi == Properties.end()) - return default; + return defaultValue; return vi->second; } -int ConfigObject::GetPropertyInteger(const string& name, int default) const +int ConfigObject::GetPropertyInteger(const string& name, int defaultValue) const { string value = GetProperty(name); if (value == string()) - return default; + return defaultValue; return strtol(value.c_str(), NULL, 10); } -double ConfigObject::GetPropertyDouble(const string& name, double default) const +double ConfigObject::GetPropertyDouble(const string& name, double defaultValue) const { string value = GetProperty(name); if (value == string()) - return default; + return defaultValue; return strtod(value.c_str(), NULL); } diff --git a/base/configobject.h b/base/configobject.h index 939af74d0..78bfc8c31 100644 --- a/base/configobject.h +++ b/base/configobject.h @@ -39,9 +39,9 @@ public: void SetPropertyInteger(const string& name, int value); void SetPropertyDouble(const string& name, double value); - string GetProperty(const string& name, const string& default = string()) const; - int GetPropertyInteger(const string& name, int default = 0) const; - double GetPropertyDouble(const string& name, double default = 0.0f) const; + string GetProperty(const string& name, const string& defaultValue = string()) const; + int GetPropertyInteger(const string& name, int defaultValue = 0) const; + double GetPropertyDouble(const string& name, double defaultValue = 0.0f) const; }; } diff --git a/base/i2-base.h b/base/i2-base.h index d26671604..e655fcdf5 100644 --- a/base/i2-base.h +++ b/base/i2-base.h @@ -1,10 +1,12 @@ #ifndef I2_BASE_H #define I2_BASE_H -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/base/mutex.cpp b/base/mutex.cpp index ce706cdaa..5a3b59601 100644 --- a/base/mutex.cpp +++ b/base/mutex.cpp @@ -7,7 +7,7 @@ mutex::mutex(void) #ifdef _WIN32 InitializeCriticalSection(&m_Mutex); #else /* _WIN32 */ - pthread_mutex_init(&m_Mutex); + pthread_mutex_init(&m_Mutex, NULL); #endif /* _WIN32 */ } @@ -16,7 +16,7 @@ mutex::~mutex(void) #ifdef _WIN32 DeleteCriticalSection(&m_Mutex); #else /* _WIN32 */ - pthread_mutex_init(&m_Mutex); + pthread_mutex_destroy(&m_Mutex); #endif /* _WIN32 */ } @@ -25,7 +25,7 @@ bool mutex::tryenter(void) #ifdef _WIN32 return (TryEnterCriticalSection(&m_Mutex) == TRUE); #else /* _WIN32 */ - return pthread_mutex_tryenter(&m_Mutex); + return pthread_mutex_trylock(&m_Mutex); #endif /* _WIN32 */ } @@ -34,7 +34,7 @@ void mutex::enter(void) #ifdef _WIN32 EnterCriticalSection(&m_Mutex); #else /* _WIN32 */ - pthread_mutex_enter(&m_Mutex); + pthread_mutex_lock(&m_Mutex); #endif /* _WIN32 */ } @@ -43,7 +43,7 @@ void mutex::exit(void) #ifdef _WIN32 LeaveCriticalSection(&m_Mutex); #else /* _WIN32 */ - pthread_mutex_exit(&m_Mutex); + pthread_mutex_unlock(&m_Mutex); #endif /* _WIN32 */ } diff --git a/base/thread.h b/base/thread.h index 39d7c9721..8306942da 100644 --- a/base/thread.h +++ b/base/thread.h @@ -4,8 +4,6 @@ namespace icinga { -using std::function; - class thread { private: diff --git a/base/unix.h b/base/unix.h index f9d9e88b0..cde7fdb1a 100644 --- a/base/unix.h +++ b/base/unix.h @@ -4,10 +4,13 @@ #include #include #include +#include +#include #include #include #include #include +#include typedef int SOCKET; diff --git a/configfilecomponent/Makefile.am b/configfilecomponent/Makefile.am index 332c0b115..9b0e8bedf 100644 --- a/configfilecomponent/Makefile.am +++ b/configfilecomponent/Makefile.am @@ -1,9 +1,11 @@ ## Process this file with automake to produce Makefile.in +pkglib_LTLIBRARIES = \ + libconfigfilecomponent.la libconfigfilecomponent_la_SOURCES = \ configfilecomponent.cpp \ configfilecomponent.h \ i2-configfilecomponent.h -libconfigfilecomponent_la_CXXFLAGS = -I${top_srcdir}/base +libconfigfilecomponent_la_CXXFLAGS = -I${top_srcdir}/base -I${top_srcdir}/jsonrpc diff --git a/configfilecomponent/configfilecomponent.cpp b/configfilecomponent/configfilecomponent.cpp index dbdea10f5..4c10c0d25 100644 --- a/configfilecomponent/configfilecomponent.cpp +++ b/configfilecomponent/configfilecomponent.cpp @@ -16,7 +16,7 @@ void ConfigFileComponent::Start(void) ifstream fp; FIFO::RefType fifo = new_object(); - fp.open(GetConfig()->GetProperty("filename"), ifstream::in); + fp.open(GetConfig()->GetProperty("filename").c_str(), ifstream::in); if (fp.fail()) throw exception(/*"Could not open config file"*/); diff --git a/configrpccomponent/Makefile.am b/configrpccomponent/Makefile.am index 35340f2ac..35ffe934d 100644 --- a/configrpccomponent/Makefile.am +++ b/configrpccomponent/Makefile.am @@ -1,9 +1,11 @@ ## Process this file with automake to produce Makefile.in +pkglib_LTLIBRARIES = \ + libconfigrpccomponent.la libconfigrpccomponent_la_SOURCES = \ configrpccomponent.cpp \ configrpccomponent.h \ i2-configrpccomponent.h -libconfigrpccomponent_la_CXXFLAGS = -I${top_srcdir}/base +libconfigrpccomponent_la_CXXFLAGS = -I${top_srcdir}/base -I${top_srcdir}/jsonrpc -I${top_srcdir}/icinga diff --git a/configrpccomponent/configrpccomponent.cpp b/configrpccomponent/configrpccomponent.cpp index ce741692f..efb651af1 100644 --- a/configrpccomponent/configrpccomponent.cpp +++ b/configrpccomponent/configrpccomponent.cpp @@ -81,7 +81,7 @@ int ConfigRpcComponent::FetchObjectsHandler(NewMessageEventArgs::RefType ea) int ConfigRpcComponent::LocalObjectCreatedHandler(ConfigHiveEventArgs::RefType ea) { ConnectionManager::RefType connectionManager = GetIcingaApplication()->GetConnectionManager(); - connectionManager->SendMessage(MakeObjectMessage(ea->ConfigObject, "config::ObjectCreated", true)); + connectionManager->SendMessage(MakeObjectMessage(ea->Object, "config::ObjectCreated", true)); return 0; } @@ -89,17 +89,17 @@ int ConfigRpcComponent::LocalObjectCreatedHandler(ConfigHiveEventArgs::RefType e int ConfigRpcComponent::LocalObjectRemovedHandler(ConfigHiveEventArgs::RefType ea) { ConnectionManager::RefType connectionManager = GetIcingaApplication()->GetConnectionManager(); - connectionManager->SendMessage(MakeObjectMessage(ea->ConfigObject, "config::ObjectRemoved", false)); + connectionManager->SendMessage(MakeObjectMessage(ea->Object, "config::ObjectRemoved", false)); return 0; } int ConfigRpcComponent::LocalPropertyChangedHandler(ConfigHiveEventArgs::RefType ea) { - JsonRpcMessage::RefType msg = MakeObjectMessage(ea->ConfigObject, "config::ObjectRemoved", false); + JsonRpcMessage::RefType msg = MakeObjectMessage(ea->Object, "config::ObjectRemoved", false); cJSON *params = msg->GetParams(); cJSON_AddStringToObject(params, "property", ea->Property.c_str()); - string value = ea->ConfigObject->GetProperty(ea->Property); + string value = ea->Object->GetProperty(ea->Property); cJSON_AddStringToObject(params, "value", value.c_str()); ConnectionManager::RefType connectionManager = GetIcingaApplication()->GetConnectionManager(); diff --git a/configure.ac b/configure.ac index fd8c81a1e..af7ade1b3 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,8 @@ AC_PROG_CXX LT_INIT - +LT_CONFIG_LTDL_DIR([ltdl]) +LTDL_INIT @@ -26,6 +27,9 @@ LT_INIT AC_OUTPUT([ Makefile base/Makefile +configfilecomponent/Makefile +configrpccomponent/Makefile +icinga/Makefile jsonrpc/Makefile miniapp/Makefile diff --git a/icinga/Makefile.am b/icinga/Makefile.am index e4c115720..ead535022 100644 --- a/icinga/Makefile.am +++ b/icinga/Makefile.am @@ -4,12 +4,12 @@ bin_PROGRAMS = \ icinga -miniapp_SOURCES = \ +icinga_SOURCES = \ icingaapplication.cpp \ icingaapplication.h -miniapp_CXXFLAGS = -I${top_srcdir}/base \ +icinga_CXXFLAGS = -I${top_srcdir}/base \ -I${top_srcdir}/jsonrpc -miniapp_LDFLAGS = $(top_builddir)/base/libbase.a \ +icinga_LDFLAGS = $(top_builddir)/base/libbase.a \ $(top_builddir)/jsonrpc/libjsonrpc.a diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp index b7a6c6677..79e383e8b 100644 --- a/icinga/icingaapplication.cpp +++ b/icinga/icingaapplication.cpp @@ -35,8 +35,8 @@ ConnectionManager::RefType IcingaApplication::GetConnectionManager(void) int IcingaApplication::ConfigObjectCreatedHandler(ConfigHiveEventArgs::RefType ea) { - if (ea->ConfigObject->GetType() == "component") { - LoadComponent(ea->ConfigObject->GetName()); + if (ea->Object->GetType() == "component") { + LoadComponent(ea->Object->GetName()); } return 0; @@ -44,8 +44,8 @@ int IcingaApplication::ConfigObjectCreatedHandler(ConfigHiveEventArgs::RefType e int IcingaApplication::ConfigObjectRemovedHandler(ConfigHiveEventArgs::RefType ea) { - if (ea->ConfigObject->GetType() == "component") { - UnloadComponent(ea->ConfigObject->GetName()); + if (ea->Object->GetType() == "component") { + UnloadComponent(ea->Object->GetName()); } return 0; -- 2.40.0