summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Common/Backends/Makefile.am4
-rw-r--r--src/Common/Backends/Makefile.in52
-rw-r--r--src/Makefile.am4
-rw-r--r--src/Makefile.in4
-rw-r--r--src/mad-core.cpp3
-rw-r--r--src/mad.cpp3
-rw-r--r--src/modules/Makefile.am9
-rw-r--r--src/modules/Makefile.in24
-rw-r--r--src/modules/SystemBackendProc.cpp (renamed from src/Common/Backends/SystemBackendProc.cpp)20
-rw-r--r--src/modules/SystemBackendProc.h (renamed from src/Common/Backends/SystemBackendProc.h)38
10 files changed, 81 insertions, 80 deletions
diff --git a/src/Common/Backends/Makefile.am b/src/Common/Backends/Makefile.am
index 83e5b2f..ab20072 100644
--- a/src/Common/Backends/Makefile.am
+++ b/src/Common/Backends/Makefile.am
@@ -1,4 +1,4 @@
noinst_LTLIBRARIES = libbackends.la
-libbackends_la_SOURCES = SystemBackendProc.cpp
+libbackends_la_SOURCES =
-noinst_HEADERS = ConsoleLogger.h FileLogger.h SystemBackendProc.h
+noinst_HEADERS = ConsoleLogger.h FileLogger.h
diff --git a/src/Common/Backends/Makefile.in b/src/Common/Backends/Makefile.in
index fd44c4d..e57b0e2 100644
--- a/src/Common/Backends/Makefile.in
+++ b/src/Common/Backends/Makefile.in
@@ -49,19 +49,17 @@ CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libbackends_la_LIBADD =
-am_libbackends_la_OBJECTS = SystemBackendProc.lo
+am_libbackends_la_OBJECTS =
libbackends_la_OBJECTS = $(am_libbackends_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/config/depcomp
-am__depfiles_maybe = depfiles
-CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
- --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
- --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libbackends_la_SOURCES)
DIST_SOURCES = $(libbackends_la_SOURCES)
@@ -207,12 +205,11 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = libbackends.la
-libbackends_la_SOURCES = SystemBackendProc.cpp
-noinst_HEADERS = ConsoleLogger.h FileLogger.h SystemBackendProc.h
+libbackends_la_SOURCES =
+noinst_HEADERS = ConsoleLogger.h FileLogger.h
all: all-am
.SUFFIXES:
-.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -252,7 +249,7 @@ clean-noinstLTLIBRARIES:
rm -f "$${dir}/so_locations"; \
done
libbackends.la: $(libbackends_la_OBJECTS) $(libbackends_la_DEPENDENCIES)
- $(CXXLINK) $(libbackends_la_OBJECTS) $(libbackends_la_LIBADD) $(LIBS)
+ $(LINK) $(libbackends_la_OBJECTS) $(libbackends_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -260,29 +257,6 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemBackendProc.Plo@am__quote@
-
-.cpp.o:
-@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
-
-.cpp.obj:
-@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-.cpp.lo:
-@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
-
mostlyclean-libtool:
-rm -f *.lo
@@ -396,7 +370,6 @@ clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
- -rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
@@ -430,7 +403,6 @@ install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
- -rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
diff --git a/src/Makefile.am b/src/Makefile.am
index 8819a06..36dddfb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,7 @@ bin_PROGRAMS = mad madc mad-core
mad_SOURCES = mad.cpp
mad_LDADD = Daemon/libdaemon.la Common/libcommon.la Net/libnet.la \
$(sigc_LIBS) $(GnuTLS_LIBS) @LIBLTDL@
-mad_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la
+mad_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la -dlopen modules/SystemBackendProc.la
madc_SOURCES = madc.cpp
madc_LDADD = Client/libclient.la Common/libcommon.la Net/libnet.la \
@@ -14,4 +14,4 @@ madc_LDADD = Client/libclient.la Common/libcommon.la Net/libnet.la \
mad_core_SOURCES = mad-core.cpp
mad_core_LDADD = Core/libcore.la Common/libcommon.la Net/libnet.la \
$(sigc_LIBS) $(GnuTLS_LIBS) $(GSSAPI_LIBS) @LIBLTDL@
-mad_core_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la
+mad_core_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la -dlopen modules/SystemBackendProc.la
diff --git a/src/Makefile.in b/src/Makefile.in
index 841e70c..22d0c21 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -239,7 +239,7 @@ mad_SOURCES = mad.cpp
mad_LDADD = Daemon/libdaemon.la Common/libcommon.la Net/libnet.la \
$(sigc_LIBS) $(GnuTLS_LIBS) @LIBLTDL@
-mad_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la
+mad_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la -dlopen modules/SystemBackendProc.la
madc_SOURCES = madc.cpp
madc_LDADD = Client/libclient.la Common/libcommon.la Net/libnet.la \
$(sigc_LIBS) $(GnuTLS_LIBS) $(READLINE_LIBS)
@@ -248,7 +248,7 @@ mad_core_SOURCES = mad-core.cpp
mad_core_LDADD = Core/libcore.la Common/libcommon.la Net/libnet.la \
$(sigc_LIBS) $(GnuTLS_LIBS) $(GSSAPI_LIBS) @LIBLTDL@
-mad_core_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la
+mad_core_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la -dlopen modules/SystemBackendProc.la
all: all-recursive
.SUFFIXES:
diff --git a/src/mad-core.cpp b/src/mad-core.cpp
index 96c511f..c5627cb 100644
--- a/src/mad-core.cpp
+++ b/src/mad-core.cpp
@@ -20,7 +20,6 @@
#include "Common/ConfigManager.h"
#include "Common/LogManager.h"
#include "Common/Logger.h"
-#include "Common/Backends/SystemBackendProc.h"
#include "Common/ModuleManager.h"
#include "Core/ConnectionManager.h"
@@ -41,8 +40,8 @@ int main() {
Common::ConfigManager::get()->loadFile("mad-core.conf");
Common::ConfigManager::get()->finish();
- Common::Backends::SystemBackendProc::registerBackend();
Common::ModuleManager::get()->loadModule("SystemBackendPosix.la");
+ Common::ModuleManager::get()->loadModule("SystemBackendProc.la");
while(true)
Core::ConnectionManager::get()->run();
diff --git a/src/mad.cpp b/src/mad.cpp
index 6500258..1fed06d 100644
--- a/src/mad.cpp
+++ b/src/mad.cpp
@@ -20,7 +20,6 @@
#include "Net/ClientConnection.h"
#include "Net/FdManager.h"
#include "Net/IPAddress.h"
-#include "Common/Backends/SystemBackendProc.h"
#include "Common/ConfigManager.h"
#include "Common/LogManager.h"
#include "Common/Logger.h"
@@ -52,8 +51,8 @@ int main() {
Common::RequestManager::get()->registerPacketType<Daemon::RequestHandlers::CommandRequestHandler>(Net::Packet::COMMAND_REBOOT);
Common::RequestManager::get()->registerPacketType<Daemon::RequestHandlers::CommandRequestHandler>(Net::Packet::COMMAND_SHUTDOWN);
- Common::Backends::SystemBackendProc::registerBackend();
Common::ModuleManager::get()->loadModule("SystemBackendPosix.la");
+ Common::ModuleManager::get()->loadModule("SystemBackendProc.la");
Net::ClientConnection *connection = new Net::ClientConnection;
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
index d94701f..18d8ad6 100644
--- a/src/modules/Makefile.am
+++ b/src/modules/Makefile.am
@@ -1,9 +1,12 @@
madlibdir = ${libdir}/mad
moddir = ${madlibdir}/modules
-mod_LTLIBRARIES = SystemBackendPosix.la
+mod_LTLIBRARIES = SystemBackendPosix.la SystemBackendProc.la
+AM_LDFLAGS = -module -avoid-version -export-dynamic
+
SystemBackendPosix_la_SOURCES = SystemBackendPosix.cpp
SystemBackendPosix_la_LIBADD = $(sigc_LIBS)
-SystemBackendPosix_la_LDFLAGS = -module -avoid-version -export-dynamic
-noinst_HEADERS = SystemBackendPosix.h
+SystemBackendProc_la_SOURCES = SystemBackendProc.cpp
+
+noinst_HEADERS = SystemBackendPosix.h SystemBackendProc.h
diff --git a/src/modules/Makefile.in b/src/modules/Makefile.in
index 876828a..538ace6 100644
--- a/src/modules/Makefile.in
+++ b/src/modules/Makefile.in
@@ -60,9 +60,9 @@ am__DEPENDENCIES_1 =
SystemBackendPosix_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am_SystemBackendPosix_la_OBJECTS = SystemBackendPosix.lo
SystemBackendPosix_la_OBJECTS = $(am_SystemBackendPosix_la_OBJECTS)
-SystemBackendPosix_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
- $(CXXFLAGS) $(SystemBackendPosix_la_LDFLAGS) $(LDFLAGS) -o $@
+SystemBackendProc_la_LIBADD =
+am_SystemBackendProc_la_OBJECTS = SystemBackendProc.lo
+SystemBackendProc_la_OBJECTS = $(am_SystemBackendProc_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
@@ -75,8 +75,10 @@ CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
-SOURCES = $(SystemBackendPosix_la_SOURCES)
-DIST_SOURCES = $(SystemBackendPosix_la_SOURCES)
+SOURCES = $(SystemBackendPosix_la_SOURCES) \
+ $(SystemBackendProc_la_SOURCES)
+DIST_SOURCES = $(SystemBackendPosix_la_SOURCES) \
+ $(SystemBackendProc_la_SOURCES)
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
@@ -220,11 +222,12 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
madlibdir = ${libdir}/mad
moddir = ${madlibdir}/modules
-mod_LTLIBRARIES = SystemBackendPosix.la
+mod_LTLIBRARIES = SystemBackendPosix.la SystemBackendProc.la
+AM_LDFLAGS = -module -avoid-version -export-dynamic
SystemBackendPosix_la_SOURCES = SystemBackendPosix.cpp
SystemBackendPosix_la_LIBADD = $(sigc_LIBS)
-SystemBackendPosix_la_LDFLAGS = -module -avoid-version -export-dynamic
-noinst_HEADERS = SystemBackendPosix.h
+SystemBackendProc_la_SOURCES = SystemBackendProc.cpp
+noinst_HEADERS = SystemBackendPosix.h SystemBackendProc.h
all: all-am
.SUFFIXES:
@@ -286,7 +289,9 @@ clean-modLTLIBRARIES:
rm -f "$${dir}/so_locations"; \
done
SystemBackendPosix.la: $(SystemBackendPosix_la_OBJECTS) $(SystemBackendPosix_la_DEPENDENCIES)
- $(SystemBackendPosix_la_LINK) -rpath $(moddir) $(SystemBackendPosix_la_OBJECTS) $(SystemBackendPosix_la_LIBADD) $(LIBS)
+ $(CXXLINK) -rpath $(moddir) $(SystemBackendPosix_la_OBJECTS) $(SystemBackendPosix_la_LIBADD) $(LIBS)
+SystemBackendProc.la: $(SystemBackendProc_la_OBJECTS) $(SystemBackendProc_la_DEPENDENCIES)
+ $(CXXLINK) -rpath $(moddir) $(SystemBackendProc_la_OBJECTS) $(SystemBackendProc_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -295,6 +300,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemBackendPosix.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemBackendProc.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/src/Common/Backends/SystemBackendProc.cpp b/src/modules/SystemBackendProc.cpp
index 134998f..1af2f28 100644
--- a/src/Common/Backends/SystemBackendProc.cpp
+++ b/src/modules/SystemBackendProc.cpp
@@ -22,11 +22,13 @@
#include <cstdio>
#include <cstring>
+#define init SystemBackendProc_LTX_init
+#define deinit SystemBackendProc_LTX_deinit
+
namespace Mad {
-namespace Common {
-namespace Backends {
+namespace Modules {
-SystemBackendProc SystemBackendProc::backend;
+SystemBackendProc *SystemBackendProc::backend = 0;
bool SystemBackendProc::uptimeInfo(const sigc::slot<void, unsigned long, unsigned long> &callback) {
unsigned long uptime = 0, idleTime = 0;
@@ -113,4 +115,16 @@ bool SystemBackendProc::loadInfo(const sigc::slot<void, unsigned long, unsigned
}
}
+
+
+extern "C" {
+
+void init() {
+ Mad::Modules::SystemBackendProc::registerBackend();
+}
+
+void deinit() {
+ Mad::Modules::SystemBackendProc::unregisterBackend();
+}
+
}
diff --git a/src/Common/Backends/SystemBackendProc.h b/src/modules/SystemBackendProc.h
index 79ff6c5..db3c743 100644
--- a/src/Common/Backends/SystemBackendProc.h
+++ b/src/modules/SystemBackendProc.h
@@ -17,20 +17,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_COMMON_BACKENDS_SYSTEMBACKENDPROC_H_
-#define MAD_COMMON_BACKENDS_SYSTEMBACKENDPROC_H_
+#ifndef MAD_MODULE_SYSTEMBACKENDPROC_H_
+#define MAD_MODULE_SYSTEMBACKENDPROC_H_
-#include "../SystemBackend.h"
+#include <Common/SystemBackend.h>
#include <fstream>
namespace Mad {
-namespace Common {
-namespace Backends {
+namespace Modules {
-class SystemBackendProc : public SystemBackend {
+class SystemBackendProc : public Common::SystemBackend {
private:
- static SystemBackendProc backend;
+ static SystemBackendProc *backend;
std::ifstream uptimeFile;
std::ifstream meminfoFile;
@@ -38,22 +37,31 @@ class SystemBackendProc : public SystemBackend {
SystemBackendProc() : uptimeFile("/proc/uptime"), meminfoFile("/proc/meminfo"), loadFile("/proc/loadavg") {}
+ protected:
+ virtual bool uptimeInfo(const sigc::slot<void, unsigned long, unsigned long> &callback);
+ virtual bool memoryInfo(const sigc::slot<void, unsigned long, unsigned long, unsigned long, unsigned long> &callback);
+ virtual bool loadInfo(const sigc::slot<void, unsigned long, unsigned long, float, float, float> &callback);
+
public:
static void registerBackend() {
- SystemBackend::registerBackend(&backend);
+ if(backend)
+ return;
+
+ backend = new SystemBackendProc();
+ SystemBackend::registerBackend(backend);
}
static void unregisterBackend() {
- SystemBackend::unregisterBackend(&backend);
- }
+ if(!backend)
+ return;
- virtual bool uptimeInfo(const sigc::slot<void, unsigned long, unsigned long> &callback);
- virtual bool memoryInfo(const sigc::slot<void, unsigned long, unsigned long, unsigned long, unsigned long> &callback);
- virtual bool loadInfo(const sigc::slot<void, unsigned long, unsigned long, float, float, float> &callback);
+ SystemBackend::unregisterBackend(backend);
+ delete backend;
+ backend = 0;
+ }
};
}
}
-}
-#endif /* MAD_COMMON_BACKENDS_SYSTEMBACKENDPROC_H_ */
+#endif /* MAD_MODULE_SYSTEMBACKENDPROC_H_ */