diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-08-18 15:58:17 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-08-18 15:58:17 +0200 |
commit | db5ad2e09a6b38e841463dbe7eb076492b62c948 (patch) | |
tree | 5907f6416e35cbd25432a5f1f6dc9664d36aa73c /src/modules | |
parent | 5da7b0847bac2a5abec95b9ac1701b74baae8964 (diff) | |
download | mad-db5ad2e09a6b38e841463dbe7eb076492b62c948.tar mad-db5ad2e09a6b38e841463dbe7eb076492b62c948.zip |
Mad funktioniert jetzt unter Windows
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/CMakeLists.txt | 11 | ||||
-rw-r--r-- | src/modules/FileLogger/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/modules/FileLogger/FileLogger.h | 4 | ||||
-rw-r--r-- | src/modules/FileLogger/Module.cpp | 6 | ||||
-rw-r--r-- | src/modules/SystemBackendPosix/Module.cpp | 4 | ||||
-rw-r--r-- | src/modules/SystemBackendProc/Module.cpp | 4 | ||||
-rw-r--r-- | src/modules/UserConfigBackendHome/Module.cpp | 4 | ||||
-rw-r--r-- | src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp | 2 | ||||
-rw-r--r-- | src/modules/UserConfigBackendKrb5/Module.cpp | 4 | ||||
-rw-r--r-- | src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp | 22 | ||||
-rw-r--r-- | src/modules/UserDBBackendMysql/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/modules/UserDBBackendMysql/Module.cpp | 4 | ||||
-rw-r--r-- | src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp | 4 | ||||
-rw-r--r-- | src/modules/export.h | 11 | ||||
-rw-r--r-- | src/modules/modules.cpp.in | 7 |
15 files changed, 60 insertions, 29 deletions
diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 1d036c9..13ad209 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -20,6 +20,8 @@ macro(mad_module name) add_library(${name} MODULE ${ARGN}) set_property(TARGET ${name} PROPERTY PREFIX "") endif(WITH_STATIC_${upper_name}) + + set_target_properties(${name} PROPERTIES DEFINE_SYMBOL "MAD_MODULE_EXPORTS") endif(WITH_${upper_name}) endmacro(mad_module) @@ -32,9 +34,12 @@ macro(mad_module_libraries name) endmacro(mad_module_libraries) add_subdirectory(FileLogger) + +if(UNIX) add_subdirectory(SystemBackendPosix) add_subdirectory(SystemBackendProc) add_subdirectory(UserConfigBackendHome) +endif(UNIX) if(MYSQL_FOUND) add_subdirectory(UserDBBackendMysql) @@ -49,12 +54,14 @@ SET(STATIC_MODULE_LIST "") foreach(module ${STATIC_MODULES}) SET(STATIC_MODULE_LOADERS "${STATIC_MODULE_LOADERS}Mad::Common::Module* ${module}_create(Mad::Common::Application *application);\n") - SET(STATIC_MODULE_LIST "${STATIC_MODULE_LIST}std::make_pair(\"${module}\", &${module}_create),\n") + SET(STATIC_MODULE_LIST "${STATIC_MODULE_LIST}std::pair<const std::string, const ModuleLoadFunc>(0, 0)(\"${module}\", &${module}_create),\n") endforeach(module ${STATIC_MODULES}) configure_file(${MAD_SOURCE_DIR}/src/modules/modules.cpp.in ${MAD_BINARY_DIR}/src/modules/modules.cpp) add_library(modules STATIC - modules.cpp modules.h + export.h + + ${MAD_BINARY_DIR}/src/modules/modules.cpp modules.h ) target_link_libraries(modules ${STATIC_MODULES}) diff --git a/src/modules/FileLogger/CMakeLists.txt b/src/modules/FileLogger/CMakeLists.txt index 2f654e8..ac1deab 100644 --- a/src/modules/FileLogger/CMakeLists.txt +++ b/src/modules/FileLogger/CMakeLists.txt @@ -4,3 +4,4 @@ mad_module(FileLogger FileLogger.h Module.cpp Module.h ) +mad_module_libraries(FileLogger Common) diff --git a/src/modules/FileLogger/FileLogger.h b/src/modules/FileLogger/FileLogger.h index a32003d..0ee9ad7 100644 --- a/src/modules/FileLogger/FileLogger.h +++ b/src/modules/FileLogger/FileLogger.h @@ -34,10 +34,10 @@ class FileLogger : public Core::Logger, public Core::RemoteLogger { std::ofstream file; protected: - virtual void logMessage(MessageCategory, MessageLevel, time_t, const std::string &message) { + virtual void logMessage(MessageCategory /*category*/, MessageLevel /*level*/, boost::posix_time::ptime /*timestamp*/, const std::string &message) { file << message << std::endl; } - virtual void logMessage(MessageCategory, MessageLevel, time_t, const std::string &message, const std::string &messageSource) { + virtual void logMessage(MessageCategory /*category*/, MessageLevel /*level*/, boost::posix_time::ptime /*timestamp*/, const std::string &message, const std::string &messageSource) { file << message << " from "<< messageSource << std::endl; } diff --git a/src/modules/FileLogger/Module.cpp b/src/modules/FileLogger/Module.cpp index b8a6954..e715386 100644 --- a/src/modules/FileLogger/Module.cpp +++ b/src/modules/FileLogger/Module.cpp @@ -17,6 +17,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "../export.h" + #include "Module.h" #include <Core/ConfigEntry.h> @@ -38,7 +40,7 @@ bool Module::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) { application->getLogManager()->registerLogger(boost::static_pointer_cast<Core::Logger>(logger)); } else { - application->logf(Core::LoggerBase::WARNING, "FileLogger: no filename given."); + application->logf(Core::LoggerBase::LOG_WARNING, "FileLogger: no filename given."); } return true; @@ -55,7 +57,7 @@ bool Module::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) { extern "C" { -Mad::Common::Module* FileLogger_create(Mad::Common::Application *application) { +MAD_MODULE_EXPORT Mad::Common::Module* FileLogger_create(Mad::Common::Application *application) { return new Mad::Modules::FileLogger::Module(application); } diff --git a/src/modules/SystemBackendPosix/Module.cpp b/src/modules/SystemBackendPosix/Module.cpp index 2fd5cfe..c43125c 100644 --- a/src/modules/SystemBackendPosix/Module.cpp +++ b/src/modules/SystemBackendPosix/Module.cpp @@ -17,11 +17,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "../export.h" + #include "Module.h" extern "C" { -Mad::Common::Module* SystemBackendPosix_create(Mad::Common::Application *application) { +MAD_MODULE_EXPORT Mad::Common::Module* SystemBackendPosix_create(Mad::Common::Application *application) { return new Mad::Modules::SystemBackendPosix::Module(application); } diff --git a/src/modules/SystemBackendProc/Module.cpp b/src/modules/SystemBackendProc/Module.cpp index 6e45cdb..1781e85 100644 --- a/src/modules/SystemBackendProc/Module.cpp +++ b/src/modules/SystemBackendProc/Module.cpp @@ -17,11 +17,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "../export.h" + #include "Module.h" extern "C" { -Mad::Common::Module* SystemBackendProc_create(Mad::Common::Application *application) { +MAD_MODULE_EXPORT Mad::Common::Module* SystemBackendProc_create(Mad::Common::Application *application) { return new Mad::Modules::SystemBackendProc::Module(application); } diff --git a/src/modules/UserConfigBackendHome/Module.cpp b/src/modules/UserConfigBackendHome/Module.cpp index cab1b80..e431e51 100644 --- a/src/modules/UserConfigBackendHome/Module.cpp +++ b/src/modules/UserConfigBackendHome/Module.cpp @@ -17,11 +17,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "../export.h" + #include "Module.h" extern "C" { -Mad::Common::Module* UserConfigBackendHome_create(Mad::Common::Application *application) { +MAD_MODULE_EXPORT Mad::Common::Module* UserConfigBackendHome_create(Mad::Common::Application *application) { return new Mad::Modules::UserConfigBackendHome::Module(application); } diff --git a/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp b/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp index b68268b..1a2a5c4 100644 --- a/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp +++ b/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp @@ -50,7 +50,7 @@ bool UserConfigBackendHome::handleConfigEntry(const Core::ConfigEntry &entry, bo char *endptr; unsigned long val = std::strtoul(entry[1][0].c_str(), &endptr, 8); if(*endptr || val > 07777) { - application->logf(Core::LoggerBase::WARNING, "UserBackendHome: Invalid configuration: DirMode '%s'", entry[1][0].c_str()); + application->logf(Core::LoggerBase::LOG_WARNING, "UserBackendHome: Invalid configuration: DirMode '%s'", entry[1][0].c_str()); } else { dirMode = val; diff --git a/src/modules/UserConfigBackendKrb5/Module.cpp b/src/modules/UserConfigBackendKrb5/Module.cpp index ecfec56..3ef9b88 100644 --- a/src/modules/UserConfigBackendKrb5/Module.cpp +++ b/src/modules/UserConfigBackendKrb5/Module.cpp @@ -17,11 +17,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "../export.h" + #include "Module.h" extern "C" { -Mad::Common::Module* UserConfigBackendKrb5_create(Mad::Common::Application *application) { +MAD_MODULE_EXPORT Mad::Common::Module* UserConfigBackendKrb5_create(Mad::Common::Application *application) { return new Mad::Modules::UserConfigBackendKrb5::Module(application); } diff --git a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp index beedbae..35d65ae 100644 --- a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp +++ b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp @@ -29,12 +29,12 @@ namespace UserConfigBackendKrb5 { void UserConfigBackendKrb5::connect() { if(principal.empty()) { - application->log(Core::LoggerBase::USER, Core::LoggerBase::ERROR, "UserConfigBackendKrb5: no principal given"); + application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_ERROR, "UserConfigBackendKrb5: no principal given"); return; } if(realm.empty()) { - application->log(Core::LoggerBase::USER, Core::LoggerBase::ERROR, "UserConfigBackendKrb5: no realm given and no default realm available"); + application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_ERROR, "UserConfigBackendKrb5: no realm given and no default realm available"); return; } @@ -64,7 +64,7 @@ void UserConfigBackendKrb5::connect() { const_cast<char*>(KADM5_ADMIN_SERVICE), ¶ms, KADM5_STRUCT_VERSION, KADM5_API_VERSION_2, 0, &handle); if(err) { - application->logf(Core::LoggerBase::USER, Core::LoggerBase::ERROR, "kadm5_init_with_password: %s", krb5_get_error_message(context, err)); + application->logf(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_ERROR, "kadm5_init_with_password: %s", krb5_get_error_message(context, err)); return; } } @@ -77,12 +77,12 @@ void UserConfigBackendKrb5::connect() { const_cast<char*>(KADM5_ADMIN_SERVICE), ¶ms, KADM5_STRUCT_VERSION, KADM5_API_VERSION_2, 0, &handle); if(err) { - application->logf(Core::LoggerBase::USER, Core::LoggerBase::ERROR, "kadm5_init_with_skey: %s", krb5_get_error_message(context, err)); + application->logf(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_ERROR, "kadm5_init_with_skey: %s", krb5_get_error_message(context, err)); return; } } - application->log(Core::LoggerBase::USER, Core::LoggerBase::VERBOSE, "Connected to kerberos admin server."); + application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_VERBOSE, "Connected to kerberos admin server."); return; } @@ -153,7 +153,7 @@ void UserConfigBackendKrb5::addUser(const Common::UserInfo &userInfo) throw(Core do { err = kadm5_create_principal(handle, &princ, KADM5_PRINCIPAL|KADM5_ATTRIBUTES, dummybuf); if(err == KADM5_RPC_ERROR && retryCount > 0) { - application->log(Core::LoggerBase::USER, Core::LoggerBase::VERBOSE, "Connection to kerberos admin server lost. Reconnecting..."); + application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_VERBOSE, "Connection to kerberos admin server lost. Reconnecting..."); connect(); --retryCount; } @@ -166,7 +166,7 @@ void UserConfigBackendKrb5::addUser(const Common::UserInfo &userInfo) throw(Core do { err = kadm5_randkey_principal(handle, princ.principal, 0, 0); if(err == KADM5_RPC_ERROR && retryCount > 0) { - application->log(Core::LoggerBase::USER, Core::LoggerBase::VERBOSE, "Connection to kerberos admin server lost. Reconnecting..."); + application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_VERBOSE, "Connection to kerberos admin server lost. Reconnecting..."); connect(); --retryCount; } @@ -180,7 +180,7 @@ void UserConfigBackendKrb5::addUser(const Common::UserInfo &userInfo) throw(Core do { err = kadm5_modify_principal(handle, &princ, KADM5_ATTRIBUTES); if(err == KADM5_RPC_ERROR && retryCount > 0) { - application->log(Core::LoggerBase::USER, Core::LoggerBase::VERBOSE, "Connection to kerberos admin server lost. Reconnecting..."); + application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_VERBOSE, "Connection to kerberos admin server lost. Reconnecting..."); connect(); --retryCount; } @@ -222,7 +222,7 @@ void UserConfigBackendKrb5::deleteUser(const Common::UserInfo &userInfo) throw(C do { err = kadm5_delete_principal(handle, princ); if(err == KADM5_RPC_ERROR && retryCount > 0) { - application->log(Core::LoggerBase::USER, Core::LoggerBase::VERBOSE, "Connection to kerberos admin server lost. Reconnecting..."); + application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_VERBOSE, "Connection to kerberos admin server lost. Reconnecting..."); connect(); --retryCount; } @@ -231,7 +231,7 @@ void UserConfigBackendKrb5::deleteUser(const Common::UserInfo &userInfo) throw(C krb5_free_principal(context, princ); if(err) - application->logf(Core::LoggerBase::USER, Core::LoggerBase::WARNING, "kadm5_delete_principal: %s", krb5_get_error_message(context, err)); + application->logf(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_WARNING, "kadm5_delete_principal: %s", krb5_get_error_message(context, err)); } void UserConfigBackendKrb5::setPassword(const Common::UserInfo &userInfo, const std::string &password) throw(Core::Exception) { @@ -252,7 +252,7 @@ void UserConfigBackendKrb5::setPassword(const Common::UserInfo &userInfo, const do { err = kadm5_chpass_principal(handle, princ, const_cast<char*>(password.c_str())); if(err == KADM5_RPC_ERROR && retryCount > 0) { - application->log(Core::LoggerBase::USER, Core::LoggerBase::VERBOSE, "Connection to kerberos admin server lost. Reconnecting..."); + application->log(Core::LoggerBase::LOG_USER, Core::LoggerBase::LOG_VERBOSE, "Connection to kerberos admin server lost. Reconnecting..."); connect(); --retryCount; } diff --git a/src/modules/UserDBBackendMysql/CMakeLists.txt b/src/modules/UserDBBackendMysql/CMakeLists.txt index 8c4f079..80b83d1 100644 --- a/src/modules/UserDBBackendMysql/CMakeLists.txt +++ b/src/modules/UserDBBackendMysql/CMakeLists.txt @@ -4,5 +4,4 @@ mad_module(UserDBBackendMysql Module.cpp Module.h UserDBBackendMysql.cpp UserDBBackendMysql.h ) - mad_module_libraries(UserDBBackendMysql ${MYSQL_LIBRARIES})
\ No newline at end of file diff --git a/src/modules/UserDBBackendMysql/Module.cpp b/src/modules/UserDBBackendMysql/Module.cpp index a4b51c4..6fcbda2 100644 --- a/src/modules/UserDBBackendMysql/Module.cpp +++ b/src/modules/UserDBBackendMysql/Module.cpp @@ -17,11 +17,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "../export.h" + #include "Module.h" extern "C" { -Mad::Common::Module* UserDBBackendMysql_create(Mad::Common::Application *application) { +MAD_MODULE_EXPORT Mad::Common::Module* UserDBBackendMysql_create(Mad::Common::Application *application) { return new Mad::Modules::UserDBBackendMysql::Module(application); } diff --git a/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp b/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp index 7ca3db2..bf087f2 100644 --- a/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp +++ b/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp @@ -70,7 +70,7 @@ bool UserDBBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool val = strtol(entry[2][0].c_str(), &endptr, 10); if(endptr != 0 || val < 0 || val > 65535) - application->log(Core::LoggerBase::WARNING, "UserDBBackendMysql: Invalid port"); + application->log(Core::LoggerBase::LOG_WARNING, "UserDBBackendMysql: Invalid port"); else port = val; } @@ -159,7 +159,7 @@ bool UserDBBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool void UserDBBackendMysql::configFinished() { if(db.empty()) { - application->log(Core::LoggerBase::ERROR, "UserDBBackendMysql: No database name given"); + application->log(Core::LoggerBase::LOG_ERROR, "UserDBBackendMysql: No database name given"); return; } diff --git a/src/modules/export.h b/src/modules/export.h new file mode 100644 index 0000000..8222a36 --- /dev/null +++ b/src/modules/export.h @@ -0,0 +1,11 @@ +#ifndef MAD_MODULE_EXPORT +# ifdef _WIN32 +# ifdef MAD_MODULE_EXPORTS +# define MAD_MODULE_EXPORT _declspec(dllexport) +# else +# define MAD_MODULE_EXPORT +# endif +# else +# define MAD_MODULE_EXPORT +# endif +#endif diff --git a/src/modules/modules.cpp.in b/src/modules/modules.cpp.in index e3feba1..a6a2147 100644 --- a/src/modules/modules.cpp.in +++ b/src/modules/modules.cpp.in @@ -17,7 +17,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "modules.h" +#include <modules/modules.h> #include <map> @@ -30,11 +30,12 @@ namespace Modules { typedef Common::Module *(*ModuleLoadFunc)(Common::Application*); -static const std::pair<const char*, const ModuleLoadFunc> modules[] = { +static const std::pair<const std::string, const ModuleLoadFunc> modules[] = { @STATIC_MODULE_LIST@ +std::pair<const std::string, const ModuleLoadFunc>("", 0) }; -static const std::map<const std::string, const ModuleLoadFunc> moduleMap(modules, modules+sizeof(modules)); +static const std::map<const std::string, const ModuleLoadFunc> moduleMap(modules, modules + sizeof(modules)/sizeof(modules[0])); Common::Module* loadStaticModule(Common::Application *application, const std::string &name) { std::map<const std::string, const ModuleLoadFunc>::const_iterator it = moduleMap.find(name); |