summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-05-20 20:04:09 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-05-20 20:04:09 +0200
commit325ee09f8fa61185efd6ec8b64b6432686170ac8 (patch)
tree7380bd046d2582034b44905b2dfe71c77f27c0e4
parent4bbe42a77b6782fd6889e673c10316f7e668eae8 (diff)
downloadmad-325ee09f8fa61185efd6ec8b64b6432686170ac8.tar
mad-325ee09f8fa61185efd6ec8b64b6432686170ac8.zip
Module wieder heil-gebastelt
-rw-r--r--CMakeLists.txt1
-rw-r--r--FindMySQL.cmake50
-rw-r--r--config.h.in2
-rw-r--r--src/Client/Requests/CMakeLists.txt2
-rw-r--r--src/Common/ModuleManager.cpp9
-rw-r--r--src/Common/RequestHandlers/CMakeLists.txt2
-rw-r--r--src/Common/Requests/CMakeLists.txt2
-rw-r--r--src/Daemon/RequestHandlers/CMakeLists.txt2
-rw-r--r--src/Daemon/Requests/CMakeLists.txt2
-rw-r--r--src/modules/CMakeLists.txt10
-rw-r--r--src/modules/FileLogger/CMakeLists.txt5
-rw-r--r--src/modules/FileLogger/FileLogger.cpp7
-rw-r--r--src/modules/FileLogger/FileLogger.h1
-rw-r--r--src/modules/SystemBackendProc/CMakeLists.txt5
-rw-r--r--src/modules/SystemBackendProc/SystemBackendProc.cpp15
-rw-r--r--src/modules/UserBackendMysql/CMakeLists.txt7
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.cpp15
17 files changed, 105 insertions, 32 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4f422f9..c1d5119 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,7 @@ find_package(Readline REQUIRED)
find_package(KRB5 REQUIRED gssapi)
find_package(OpenSSL REQUIRED)
find_package(Boost REQUIRED regex signals system thread)
+find_package(MySQL)
configure_file(config.h.in ${MAD_BINARY_DIR}/config.h)
diff --git a/FindMySQL.cmake b/FindMySQL.cmake
new file mode 100644
index 0000000..53b7062
--- /dev/null
+++ b/FindMySQL.cmake
@@ -0,0 +1,50 @@
+# - Find MySQL
+# Find the MySQL includes and client library
+# This module defines
+# MYSQL_INCLUDE_DIR, where to find mysql.h
+# MYSQL_LIBRARIES, the libraries needed to use MySQL.
+# MYSQL_FOUND, If false, do not try to use MySQL.
+#
+# Copyright (c) 2006, Jaroslaw Staniek, <js@iidea.pl>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
+ set(MYSQL_FOUND TRUE)
+
+else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
+
+ find_path(MYSQL_INCLUDE_DIR mysql.h
+ /usr/include/mysql
+ /usr/local/include/mysql
+ $ENV{ProgramFiles}/MySQL/*/include
+ $ENV{SystemDrive}/MySQL/*/include
+ )
+
+if(WIN32 AND MSVC)
+ find_library(MYSQL_LIBRARIES NAMES libmysql
+ PATHS
+ $ENV{ProgramFiles}/MySQL/*/lib/opt
+ $ENV{SystemDrive}/MySQL/*/lib/opt
+ )
+else(WIN32 AND MSVC)
+ find_library(MYSQL_LIBRARIES NAMES mysqlclient
+ PATHS
+ /usr/lib/mysql
+ /usr/local/lib/mysql
+ )
+endif(WIN32 AND MSVC)
+
+ if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
+ set(MYSQL_FOUND TRUE)
+ message(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}")
+ else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
+ set(MYSQL_FOUND FALSE)
+ message(STATUS "MySQL not found.")
+ endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
+
+ mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES)
+
+endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
+
diff --git a/config.h.in b/config.h.in
index 75f2199..9566af8 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1 +1,3 @@
+#define MODULE_SUFFIX "${CMAKE_SHARED_MODULE_SUFFIX}"
+
#define _UNUSED_PARAMETER_ __attribute__((unused)) \ No newline at end of file
diff --git a/src/Client/Requests/CMakeLists.txt b/src/Client/Requests/CMakeLists.txt
index 8790da2..ef8b275 100644
--- a/src/Client/Requests/CMakeLists.txt
+++ b/src/Client/Requests/CMakeLists.txt
@@ -1,5 +1,5 @@
include_directories(${INCLUDES})
-add_library(ClientRequests
+add_library(ClientRequests STATIC
DaemonCommandRequest.cpp DaemonFSInfoRequest.cpp DaemonStatusRequest.cpp
)
diff --git a/src/Common/ModuleManager.cpp b/src/Common/ModuleManager.cpp
index 569f5aa..05a2b73 100644
--- a/src/Common/ModuleManager.cpp
+++ b/src/Common/ModuleManager.cpp
@@ -17,6 +17,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+#include <config.h>
+
#include "ModuleManager.h"
#include "ConfigEntry.h"
@@ -73,7 +76,7 @@ lt_dlhandle ModuleManager::loadModule(const std::string &name) {
std::map<std::string, std::pair<lt_dlhandle, bool> >::iterator mod = modules.find(name);
if(mod == modules.end()) {
- lt_dlhandle handle = lt_dlopen((name + ".la").c_str());
+ lt_dlhandle handle = lt_dlopen((name + MODULE_SUFFIX).c_str());
if(!handle)
return 0;
@@ -81,7 +84,7 @@ lt_dlhandle ModuleManager::loadModule(const std::string &name) {
mod = modules.insert(std::make_pair(lt_dlgetinfo(handle)->name, std::make_pair(handle, false))).first;
}
if(!mod->second.second) {
- void (*initFun)() = (void(*)())lt_dlsym(mod->second.first, "init");
+ void (*initFun)() = (void(*)())lt_dlsym(mod->second.first, (name + "_init").c_str());
if(initFun)
(*initFun)();
@@ -95,7 +98,7 @@ lt_dlhandle ModuleManager::loadModule(const std::string &name) {
void ModuleManager::unloadModule(const std::string &name) {
void (*deinitFun)();
- deinitFun = (void(*)())lt_dlsym(modules[name].first, "deinit");
+ deinitFun = (void(*)())lt_dlsym(modules[name].first, (name + "_deinit").c_str());
if(deinitFun)
(*deinitFun)();
diff --git a/src/Common/RequestHandlers/CMakeLists.txt b/src/Common/RequestHandlers/CMakeLists.txt
index 49f9079..f774e14 100644
--- a/src/Common/RequestHandlers/CMakeLists.txt
+++ b/src/Common/RequestHandlers/CMakeLists.txt
@@ -1,6 +1,6 @@
include_directories(${INCLUDES})
-add_library(RequestHandlers
+add_library(RequestHandlers STATIC
DisconnectRequestHandler.cpp FSInfoRequestHandler.cpp StatusRequestHandler.cpp
)
target_link_libraries(RequestHandlers Common)
diff --git a/src/Common/Requests/CMakeLists.txt b/src/Common/Requests/CMakeLists.txt
index 1d49f0e..54b14e1 100644
--- a/src/Common/Requests/CMakeLists.txt
+++ b/src/Common/Requests/CMakeLists.txt
@@ -1,6 +1,6 @@
include_directories(${INCLUDES})
-add_library(Requests
+add_library(Requests STATIC
DisconnectRequest.cpp IdentifyRequest.cpp SimpleRequest.cpp UserInfoRequest.cpp
)
target_link_libraries(Requests ${KRB5_LIBRARIES})
diff --git a/src/Daemon/RequestHandlers/CMakeLists.txt b/src/Daemon/RequestHandlers/CMakeLists.txt
index 8732514..4794405 100644
--- a/src/Daemon/RequestHandlers/CMakeLists.txt
+++ b/src/Daemon/RequestHandlers/CMakeLists.txt
@@ -1,5 +1,5 @@
include_directories(${INCLUDES})
-add_library(DaemonRequestHandlers
+add_library(DaemonRequestHandlers STATIC
CommandRequestHandler.cpp
)
diff --git a/src/Daemon/Requests/CMakeLists.txt b/src/Daemon/Requests/CMakeLists.txt
index 74d8072..9bb941f 100644
--- a/src/Daemon/Requests/CMakeLists.txt
+++ b/src/Daemon/Requests/CMakeLists.txt
@@ -1,5 +1,5 @@
include_directories(${INCLUDES})
-add_library(DaemonRequests
+add_library(DaemonRequests STATIC
LogRequest.cpp
)
diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt
new file mode 100644
index 0000000..ea05a95
--- /dev/null
+++ b/src/modules/CMakeLists.txt
@@ -0,0 +1,10 @@
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${MAD_BINARY_DIR}/src/modules)
+set(CMAKE_SHARED_MODULE_PREFIX "")
+
+add_subdirectory(FileLogger)
+add_subdirectory(SystemBackendPosix)
+add_subdirectory(SystemBackendProc)
+
+if(MYSQL_FOUND)
+add_subdirectory(UserBackendMysql)
+endif(MYSQL_FOUND)
diff --git a/src/modules/FileLogger/CMakeLists.txt b/src/modules/FileLogger/CMakeLists.txt
new file mode 100644
index 0000000..39459d3
--- /dev/null
+++ b/src/modules/FileLogger/CMakeLists.txt
@@ -0,0 +1,5 @@
+include_directories(${INCLUDES})
+
+add_library(FileLogger MODULE
+ FileLogger.cpp
+)
diff --git a/src/modules/FileLogger/FileLogger.cpp b/src/modules/FileLogger/FileLogger.cpp
index 5e0c021..4655002 100644
--- a/src/modules/FileLogger/FileLogger.cpp
+++ b/src/modules/FileLogger/FileLogger.cpp
@@ -21,9 +21,6 @@
#include <Common/ConfigEntry.h>
-#define init FileLogger_LTX_init
-#define deinit FileLogger_LTX_deinit
-
namespace Mad {
namespace Modules {
@@ -62,11 +59,11 @@ bool FileLogger::ConfigHelper::handleConfigEntry(const Common::ConfigEntry &entr
extern "C" {
-void init() {
+void FileLogger_init() {
Mad::Modules::FileLogger::registerConfigHelper();
}
-void deinit() {
+void FileLogger_deinit() {
Mad::Modules::FileLogger::unregisterConfigHelper();
}
diff --git a/src/modules/FileLogger/FileLogger.h b/src/modules/FileLogger/FileLogger.h
index 404299b..2def986 100644
--- a/src/modules/FileLogger/FileLogger.h
+++ b/src/modules/FileLogger/FileLogger.h
@@ -58,7 +58,6 @@ class FileLogger : private Common::Logger, private Common::RemoteLogger {
static void registerConfigHelper() {
Common::ConfigManager::get()->registerConfigurable(&configHelper);
- Logger::log("Registered!");
}
static void unregisterConfigHelper() {
diff --git a/src/modules/SystemBackendProc/CMakeLists.txt b/src/modules/SystemBackendProc/CMakeLists.txt
new file mode 100644
index 0000000..b524265
--- /dev/null
+++ b/src/modules/SystemBackendProc/CMakeLists.txt
@@ -0,0 +1,5 @@
+include_directories(${INCLUDES})
+
+add_library(SystemBackendProc MODULE
+ SystemBackendProc.cpp
+)
diff --git a/src/modules/SystemBackendProc/SystemBackendProc.cpp b/src/modules/SystemBackendProc/SystemBackendProc.cpp
index 68f9cec..d238e07 100644
--- a/src/modules/SystemBackendProc/SystemBackendProc.cpp
+++ b/src/modules/SystemBackendProc/SystemBackendProc.cpp
@@ -19,16 +19,13 @@
#include "SystemBackendProc.h"
-#include <Common/ActionManager.h>
+#include <Net/ThreadManager.h>
#include <cstdio>
#include <cstring>
#include <boost/bind.hpp>
-#define init SystemBackendProc_LTX_init
-#define deinit SystemBackendProc_LTX_deinit
-
namespace Mad {
namespace Modules {
@@ -53,7 +50,7 @@ bool SystemBackendProc::getUptimeInfo(const boost::function2<void, unsigned long
if(uptimeFile.good())
idleTime = (unsigned long)f;
- Common::ActionManager::get()->add(boost::bind(callback, uptime, idleTime));
+ Net::ThreadManager::get()->pushWork(boost::bind(callback, uptime, idleTime));
return true;
}
@@ -90,7 +87,7 @@ bool SystemBackendProc::getMemoryInfo(const boost::function4<void, unsigned long
break;
}
- Common::ActionManager::get()->add(boost::bind(callback, totalMem, freeMem, totalSwap, freeSwap));
+ Net::ThreadManager::get()->pushWork(boost::bind(callback, totalMem, freeMem, totalSwap, freeSwap));
return true;
}
@@ -112,7 +109,7 @@ bool SystemBackendProc::getLoadInfo(const boost::function5<void, unsigned long,
std::sscanf(line.c_str(), "%f %f %f %lu/%lu", &loadAvg1, &loadAvg5, &loadAvg15, &currentLoad, &nProcesses);
- Common::ActionManager::get()->add(boost::bind(callback, currentLoad, nProcesses, loadAvg1, loadAvg5, loadAvg15));
+ Net::ThreadManager::get()->pushWork(boost::bind(callback, currentLoad, nProcesses, loadAvg1, loadAvg5, loadAvg15));
return true;
}
@@ -123,11 +120,11 @@ bool SystemBackendProc::getLoadInfo(const boost::function5<void, unsigned long,
extern "C" {
-void init() {
+void SystemBackendProc_init() {
Mad::Modules::SystemBackendProc::registerBackend();
}
-void deinit() {
+void SystemBackendProc_deinit() {
Mad::Modules::SystemBackendProc::unregisterBackend();
}
diff --git a/src/modules/UserBackendMysql/CMakeLists.txt b/src/modules/UserBackendMysql/CMakeLists.txt
new file mode 100644
index 0000000..5af1f1d
--- /dev/null
+++ b/src/modules/UserBackendMysql/CMakeLists.txt
@@ -0,0 +1,7 @@
+include_directories(${INCLUDES} ${MYSQL_INCLUDE_DIR})
+
+add_library(UserBackendMysql MODULE
+ UserBackendMysql.cpp
+)
+
+target_link_libraries(UserBackendMysql ${MYSQL_LIBRARIES}) \ No newline at end of file
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.cpp b/src/modules/UserBackendMysql/UserBackendMysql.cpp
index af25f5b..ebea4dc 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.cpp
+++ b/src/modules/UserBackendMysql/UserBackendMysql.cpp
@@ -20,19 +20,16 @@
#include <config.h>
#include "UserBackendMysql.h"
-#include <Common/ActionManager.h>
#include <Common/ConfigEntry.h>
#include <Common/ConfigManager.h>
#include <Common/Logger.h>
+#include <Net/ThreadManager.h>
#include <sstream>
#include <boost/bind.hpp>
#include <boost/regex.hpp>
-#define init UserBackendMysql_LTX_init
-#define deinit UserBackendMysql_LTX_deinit
-
namespace Mad {
namespace Modules {
@@ -155,7 +152,7 @@ bool UserBackendMysql::getUserList(const boost::function1<void, const std::map<u
users.insert(std::make_pair(user.getUid(), user));
}
- Common::ActionManager::get()->add(boost::bind(callback, users));
+ Net::ThreadManager::get()->pushWork(boost::bind(callback, users));
return true;
}
@@ -186,12 +183,12 @@ bool UserBackendMysql::getUserInfo(unsigned long uid, const boost::function1<voi
user.setGid(strtoul(row[1], 0, 10));
user.setFullName(row[3]);
- Common::ActionManager::get()->add(boost::bind(callback, user));
+ Net::ThreadManager::get()->pushWork(boost::bind(callback, user));
while((row = mysql_fetch_row(result)) != 0) {}
}
else {
- Common::ActionManager::get()->add(boost::bind(callback, Common::UserInfo()));
+ Net::ThreadManager::get()->pushWork(boost::bind(callback, Common::UserInfo()));
}
return true;
@@ -222,11 +219,11 @@ void UserBackendMysql::unregisterBackend() {
extern "C" {
-void init() {
+void UserBackendMysql_init() {
Mad::Modules::UserBackendMysql::registerBackend();
}
-void deinit() {
+void UserBackendMysql_deinit() {
Mad::Modules::UserBackendMysql::unregisterBackend();
}