Changeset 87cf3c4 in nscp


Ignore:
Timestamp:
01/08/11 10:35:05 (2 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
58ee653
Parents:
e6792f3
Message:

All builds with CMAKE now (except for installers) but thats for another rainy day

Files:
16 added
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • CMakeLists.txt

    r1ecd26f r87cf3c4  
    33cmake_minimum_required(VERSION 2.6) 
    44 
     5SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build/cmake;${CMAKE_MODULE_PATH}") 
    56   
    67PROJECT(NSCP) 
     
    2324# ### ### ### ### 
    2425# Boost setup 
    25 IF(WIN32 AND MSVC) 
    26 SET(Boost_USE_STATIC_LIBS CACHE BOOL ON "Link boost statically (generally a good idea)") 
    27 ENDIF(WIN32 AND MSVC) 
    2826SET(BOOST_INCLUDEDIR "${INC_BOOST_INCLUDEDIR}" CACHE PATH "Path to boost includes") 
    2927SET(BOOST_LIBRARYDIR "${NSCP_LIBRARYDIR}" CACHE PATH "Path to boost libraries") 
     
    4644# Crypto++ 
    4745SET(CRYPTOPP_DIR "${INC_CRYPTOPP_DIR}" CACHE PATH "Path to crypto++ root folder") 
     46# ### ### ### ### 
     47# Lua 
     48SET(LUA_DIR "${INC_LUA_DIR}" CACHE PATH "Path to Lua installation") 
     49# ### ### ### ### 
     50# Google breakpad 
     51SET(GOOGLE_BREAKPAD_DIR "${INC_GOOGLE_BREAKPAD_DIR}" CACHE PATH "Path to google protocol breakpad root") 
     52IF(WIN32 AND MSVC) 
     53  SET(BREAKPAD_LIBRARY_PREFIX "google-breakpad-") 
     54  SET(BREAKPAD_LIBRARY_PREFIX_DEBUG "debug-google-breakpad-") 
     55  SET(BREAKPAD_INCLUDE_DIR "${GOOGLE_BREAKPAD_DIR}/src") 
     56ELSE(WIN32 AND MSVC) 
     57# TODO 
     58ENDIF(WIN32 AND MSVC) 
     59 
     60 
     61#SET(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES "${INC_GOOGLE_BREAKPAD}/src" CACHE PATH "Path to Google breakpad include folder") 
     62 
    4863# ### ### ### ### 
    4964# Build related paths 
     
    97112SET(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};${OPENSSL_LIBRARY_DIR};${NSCP_LIBRARYDIR};${BOOST_LIBRARYDIR}") 
    98113 
    99  
    100 IF(APPLE) 
    101   SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS "-fPIC -w -DOSX  -DNDEBUG -finline-functions -O3 -DCRYPTOPP_DISABLE_ASM") 
    102 ELSEIF(UNIX AND NOT APPLE) 
    103   IF (ARCH_X86_64 EQUAL 1) 
    104     MESSAGE(STATUS "Adding FPIC") 
    105     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") 
    106   ELSE(ARCH_X86_64 EQUAL 1) 
    107     MESSAGE(STATUS "Adding FPIC (noia64)") 
    108     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") 
    109   ENDIF (ARCH_X86_64 EQUAL 1) 
    110   #SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS "-fPIC -w -pipe -DNDEBUG -DLINUX -finline-functions -O3") 
    111 ELSEIF(WIN32) 
    112   IF(NOT MSVC) 
    113     SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS "-mthreads -w -finline-functions -O3 -DNDEBUG -D__MINGW__ -DWIN32 -D_WIN32_WINNT=0x0501 -D_WIN32") 
    114   ENDIF(NOT MSVC) 
    115 ENDIF(APPLE) 
    116  
    117114SET_MULTITHREAD() 
    118115 
     
    137134  SET(LIB_INSTALL_DIR "lib" CACHE STRING "Default path for libraries within ${CMAKE_INSTALL_PREFIX}") 
    138135  SET(RUNDIR "c:/nscp" CACHE PATH "Not really used in WIN32") 
    139  
    140  
    141   #SET(BOOST_VERSION "1_34_1" CACHE STRING "Use boost version in BOOST_DIR") 
    142   #OPTION(BOOST_DYNAMIC "Link to boost DLLs (OFF means static link)" OFF) 
    143  
    144136ELSE(WIN32) 
    145137  SET(USERLIB_ROOT /usr CACHE PATH "Other installation prefix for dependent libraries") 
     
    151143ENDIF(WIN32) 
    152144 
     145FIND_PACKAGE(GoogleBreakpad COMPONENTS common exception_handler crash_report_sender) 
     146if(BREAKPAD_FOUND) 
     147  MESSAGE(STATUS "Found google breakpad") 
     148  SET(NSCP_GLOBAL_DEFINES ${NSCP_GLOBAL_DEFINES} -DUSE_BREAK_PAD) 
     149else(BREAKPAD_FOUND) 
     150  MESSAGE(WARNING "Breakpad was not found in: ${BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR}/${BREAKPAD_EXCEPTION_HANDLER_LIBRARIES}") 
     151endif(BREAKPAD_FOUND) 
    153152 
    154153FIND_PACKAGE(OpenSSL) 
     
    167166  #LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) 
    168167  IF(WIN32) 
    169     IF(BOOST_DYNAMIC) 
     168    #IF(BOOST_DYNAMIC) 
    170169    #ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK) 
    171     ENDIF(BOOST_DYNAMIC) 
     170    #ENDIF(BOOST_DYNAMIC) 
    172171    SET(EXTRA_LIBS ${EXTRA_LIBS} Userenv ole32) 
    173172  ENDIF(WIN32) 
    174  
    175173else(Boost_FOUND) 
    176174  MESSAGE(FATAL_ERROR, "boost NOT fround: ${Boost_ERROR_REASON}") 
     
    297295MESSAGE(STATUS "Build path: ${PROJECT_BINARY_DIR}") 
    298296ADD_SUBDIRECTORY("service") 
    299 SET(MAIN_NSCP_TARGET ${TARGET}) 
     297SET(MAIN_NSCP_TARGET "nscp") 
     298MESSAGE(STATUS "NSCP Target: ${MAIN_NSCP_TARGET}") 
     299 
     300ADD_SUBDIRECTORY("scripts") 
    300301 
    301302SET(ALL_MODULE_NAMES) 
     
    311312    message(STATUS "+ Module ${CURRENT_MODULE_NAME}: Added") 
    312313    ADD_SUBDIRECTORY("${CURRENT_MODULE_PATH}") 
    313     #SET_TARGET_PROPERTIES(${TARGET} PROPERTIES FOLDER "modules") 
    314314    SET(ALL_MODULE_NAMES ${ALL_MODULE_NAMES} ${CURRENT_MODULE_NAME}) 
    315315  ELSE(BUILD_MODULE) 
    316316    message(STATUS "- Module ${CURRENT_MODULE_NAME}: Skipped ${BUILD_MODULE_SKIP_REASON}") 
    317317  ENDIF(BUILD_MODULE) 
    318    
    319   #ADD_SUBDIRECTORY("${CURRENT_MODULE_PATH}") 
    320   #SET(ALL_MODULE_NAMES ${ALL_MODULE_NAMES} ${CURRENT_MODULE_NAME}) 
    321318endforeach(CURRENT_MODULE ${ALL_MODULES}) 
    322319 
    323  
    324 SET_TARGET_PROPERTIES(${MAIN_NSCP_TARGET} ${ALL_MODULE_NAMES} PROPERTIES  
     320SET(ALL_TOOL_NAMES) 
     321FILE(GLOB ALL_TOOLS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "tools/*/module.cmake") 
     322foreach(CURRENT_MODULE ${ALL_TOOLS}) 
     323  get_filename_component(CURRENT_MODULE_PATH ${CURRENT_MODULE} PATH) 
     324  get_filename_component(CURRENT_MODULE_NAME ${CURRENT_MODULE_PATH} NAME) 
     325  SET (BUILD_MODULE 0) 
     326  include(${CURRENT_MODULE}) 
     327  IF(BUILD_MODULE) 
     328    message(STATUS "+ Tool ${CURRENT_MODULE_NAME}: Added") 
     329    ADD_SUBDIRECTORY("${CURRENT_MODULE_PATH}") 
     330    SET(ALL_TOOL_NAMES ${ALL_TOOL_NAMES} ${CURRENT_MODULE_NAME}) 
     331  ELSE(BUILD_MODULE) 
     332    message(STATUS "- Tool ${CURRENT_MODULE_NAME}: Skipped ${BUILD_MODULE_SKIP_REASON}") 
     333  ENDIF(BUILD_MODULE) 
     334endforeach(CURRENT_MODULE ${ALL_TOOLS}) 
     335 
     336 
     337SET_TARGET_PROPERTIES(${MAIN_NSCP_TARGET} ${ALL_MODULE_NAMES} ${ALL_TOOL_NAMES} PROPERTIES  
    325338        RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" 
    326339    LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/modules" 
     
    331344if (MSVC_IDE) 
    332345    # hack to get around the "Debug" and "Release" directories cmake tries to add on Windows 
    333     set_target_properties(${MAIN_NSCP_TARGET} ${ALL_MODULE_NAMES} PROPERTIES PREFIX "../") 
     346    set_target_properties(${MAIN_NSCP_TARGET} ${ALL_MODULE_NAMES} ${ALL_TOOL_NAMES} PROPERTIES PREFIX "../") 
    334347endif() 
    335348 
  • build.cmake

    rde7ec29 r87cf3c4  
    11IF(WIN32) 
    22 
    3 SET(Boost_DEBUG 1) 
     3  #SET(Boost_DEBUG 1) 
     4  set(Boost_USE_STATIC_LIBS   ON) 
     5  set(Boost_USE_STATIC_RUNTIME  ON) 
     6  set(BOOST_USE_MULTITHREADED   ON) 
     7  SET(NSCP_GLOBAL_DEFINES ${NSCP_GLOBAL_DEFINES} -DBOOST_ALL_NO_LIB)  # THis is used to disable "automatic linking on windows which seems to break since I dont know how to set link dir 
    48 
    5 set(Boost_USE_STATIC_LIBS   ON) 
    6 set(BOOST_USE_MULTITHREADED ON) 
    7 SET(NSCP_GLOBAL_DEFINES ${NSCP_GLOBAL_DEFINES} -DBOOST_ALL_NO_LIB)  # THis is used to disable "automatic linking on windows which seems to break since I dont know how to set link dir 
    8 #SET(BOOST_LIB_SUFFIX vc80-mt) 
    9 #SET(Boost_VERSION 1.40) 
     9  SET(INC_NSCP_LIBRARYDIR C:/source/lib/x64) 
     10  SET(INC_NSCP_INCLUDEDIR C:/source/include) 
    1011 
    11 SET(INC_NSCP_LIBRARYDIR C:/source/lib/x64) 
    12 SET(INC_NSCP_INCLUDEDIR C:/source/include) 
     12  SET(INC_BOOST_INCLUDEDIR "${INC_NSCP_INCLUDEDIR}") 
     13  SET(INC_BOOST_LIBRARYDIR "${INC_NSCP_LIBRARYDIR}") 
    1314 
    14 SET(INC_BOOST_INCLUDEDIR "${INC_NSCP_INCLUDEDIR}") 
    15 SET(INC_BOOST_LIBRARYDIR "${INC_NSCP_LIBRARYDIR}") 
     15  SET(INC_OPENSSL_INCLUDEDIR "${INC_NSCP_INCLUDEDIR}") 
    1616 
     17  SET(INC_PROTOBUF_DIR "c:/source/libraries/protobuf-2.3.0") 
    1718 
    18 SET(INC_OPENSSL_INCLUDEDIR "${INC_NSCP_INCLUDEDIR}") 
     19  SET(INC_CRYPTOPP_DIR "c:/source/libraries/cryptopp-5.6.0") 
    1920 
    20 SET(INC_PROTOBUF_DIR "c:/source/libraries/protobuf-2.3.0") 
    21  
    22 SET(INC_CRYPTOPP_DIR "c:/source/libraries/cryptopp-5.6.0") 
     21  SET(INC_LUA_DIR "C:/source/libraries/lua-5.1.4") 
     22   
     23  SET(INC_GOOGLE_BREAKPAD_DIR "C:/source/google-breakpad/trunk") 
    2324 
    2425ELSE(WIN32) 
    2526 
    26 SET(INC_OPENSSL_INCLUDEDIR "/usr/include/") 
     27  SET(INC_OPENSSL_INCLUDEDIR "/usr/include/") 
    2728 
    2829ENDIF(WIN32) 
  • build/cmake/FindGoogleBreakpad.cmake

    r1ecd26f r87cf3c4  
    1010#  BREAKPAD_EXCEPTION_HANDLER_LIBRARY, where to find the Google BreakPad library. 
    1111 
    12 FIND_PATH(BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR google_breakpad/exception_handler.h) 
    13  
    14 SET(BREAKPAD_EXCEPTION_HANDLER_NAMES ${BREAKPAD_EXCEPTION_HANDLER_NAMES} breakpad_client) 
    15 FIND_LIBRARY(BREAKPAD_EXCEPTION_HANDLER_LIBRARY 
    16   NAMES ${BREAKPAD_EXCEPTION_HANDLER_NAMES} 
    17   ) 
    18  
    19 IF (BREAKPAD_EXCEPTION_HANDLER_LIBRARY AND BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR) 
    20     SET(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES ${BREAKPAD_EXCEPTION_HANDLER_LIBRARY}) 
    21     SET(BREAKPAD_EXCEPTION_HANDLER_FOUND "YES") 
    22 ELSE (BREAKPAD_EXCEPTION_HANDLER_LIBRARY AND BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR) 
    23     SET(BREAKPAD_EXCEPTION_HANDLER_FOUND "NO") 
    24 ENDIF (BREAKPAD_EXCEPTION_HANDLER_LIBRARY AND BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR) 
     12FIND_PATH(BREAKPAD_INCLUDE_DIR google_breakpad/client/breakpad_types.h) 
    2513 
    2614 
    27 IF (BREAKPAD_EXCEPTION_HANDLER_FOUND) 
    28    IF (NOT BREAKPAD_EXCEPTION_HANDLER_FIND_QUIETLY) 
    29       MESSAGE(STATUS "Found Google BreakPad: ${BREAKPAD_EXCEPTION_HANDLER_LIBRARIES}") 
    30    ENDIF (NOT BREAKPAD_EXCEPTION_HANDLER_FIND_QUIETLY) 
    31 ELSE (BREAKPAD_EXCEPTION_HANDLER_FOUND) 
    32    IF (BREAKPAD_EXCEPTION_HANDLER_FIND_REQUIRED) 
    33       MESSAGE(FATAL_ERROR "Could not find Google BreakPad library") 
    34    ENDIF (BREAKPAD_EXCEPTION_HANDLER_FIND_REQUIRED) 
    35 ENDIF (BREAKPAD_EXCEPTION_HANDLER_FOUND) 
     15#google-breakpad-common.lib 
     16#google-breakpad-crash_generation_client.lib 
     17#google-breakpad-crash_generation_server.lib 
     18#google-breakpad-crash_report_sender.lib 
     19#google-breakpad-exception_handler.lib 
     20#google-breakpad-gmock.lib 
     21#google-breakpad-gtest.lib 
    3622 
    37 MARK_AS_ADVANCED( 
    38   BREAKPAD_EXCEPTION_HANDLER_LIBRARY 
    39   BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR 
    40   ) 
     23IF(NOT GoogleBreakpad_FIND_COMPONENTS) 
     24  SET(GoogleBreakpad_FIND_COMPONENTS common exception_handler) 
     25ENDIF(NOT GoogleBreakpad_FIND_COMPONENTS) 
     26IF(NOT BREAKPAD_LIBRARY_PREFIX) 
     27  SET(BREAKPAD_LIBRARY_PREFIX "") 
     28ENDIF(NOT BREAKPAD_LIBRARY_PREFIX) 
     29IF(NOT BREAKPAD_LIBRARY_SUFFIX) 
     30  SET(BREAKPAD_LIBRARY_SUFFIX "") 
     31ENDIF(NOT BREAKPAD_LIBRARY_SUFFIX) 
     32IF(NOT BREAKPAD_LIBRARY_PREFIX_DEBUG) 
     33  SET(BREAKPAD_LIBRARY_PREFIX_DEBUG ${BREAKPAD_LIBRARY_PREFIX}) 
     34ENDIF(NOT BREAKPAD_LIBRARY_PREFIX_DEBUG) 
     35IF(NOT BREAKPAD_LIBRARY_SUFFIX_DEBUG) 
     36  SET(BREAKPAD_LIBRARY_SUFFIX_DEBUG ${BREAKPAD_LIBRARY_SUFFIX}) 
     37ENDIF(NOT BREAKPAD_LIBRARY_SUFFIX_DEBUG) 
     38 
     39MESSAGE(STATUS "Breakpad config: ${BREAKPAD_LIBRARY_PREFIX}...${BREAKPAD_LIBRARY_SUFFIX}, ${BREAKPAD_LIBRARY_PREFIX_DEBUG}...${BREAKPAD_LIBRARY_SUFFIX_DEBUG}" ) 
     40SET(BREAKPAD_FOUND TRUE) 
     41FOREACH(COMPONENT ${GoogleBreakpad_FIND_COMPONENTS}) 
     42    string(TOUPPER ${COMPONENT} UPPERCOMPONENT) 
     43  FIND_LIBRARY(BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE NAMES ${BREAKPAD_LIBRARY_PREFIX}${COMPONENT}${BREAKPAD_LIBRARY_SUFFIX}) 
     44  FIND_LIBRARY(BREAKPAD_${UPPERCOMPONENT}_LIBRARY_DEBUG NAMES ${BREAKPAD_LIBRARY_PREFIX_DEBUG}${COMPONENT}${BREAKPAD_LIBRARY_SUFFIX_DEBUG}) 
     45  IF(BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE AND BREAKPAD_${UPPERCOMPONENT}_LIBRARY_DEBUG) 
     46    SET(BREAKPAD_${UPPERCOMPONENT}_FOUND TRUE) 
     47    SET(BREAKPAD_${UPPERCOMPONENT}_LIBRARY optimized ${BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE} debug ${BREAKPAD_${UPPERCOMPONENT}_LIBRARY_DEBUG}) 
     48    set(BREAKPAD_${UPPERCOMPONENT}_LIBRARY ${BREAKPAD_${UPPERCOMPONENT}_LIBRARY} CACHE FILEPATH "The breakpad ${UPPERCOMPONENT} library") 
     49  ELSE(BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE AND BREAKPAD_${UPPERCOMPONENT}_LIBRARY_DEBUG) 
     50    SET(BREAKPAD_FOUND FALSE) 
     51    SET(BREAKPAD_${UPPERCOMPONENT}_FOUND FALSE) 
     52    SET(BREAKPAD_${UPPERCOMPONENT}_LIBRARY "${BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND}") 
     53  ENDIF(BREAKPAD_${UPPERCOMPONENT}_LIBRARY_RELEASE AND BREAKPAD_${UPPERCOMPONENT}_LIBRARY_DEBUG) 
     54ENDFOREACH(COMPONENT) 
  • build/cmake/SetMultiThread.cmake

    r1ecd26f r87cf3c4  
    1919          CACHE STRING "MSVC MT flags " FORCE 
    2020      ) 
     21    SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) 
    2122   
    2223      SET ( 
     
    2526          CACHE STRING "MSVC MT flags " FORCE 
    2627      ) 
     28    SET(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) 
    2729   
    2830      SET ( 
     
    3133          CACHE STRING "MSVC MT flags " FORCE 
    3234      ) 
     35    SET(CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}) 
    3336   
    3437      SET ( 
     
    3740          CACHE STRING "MSVC MT flags " FORCE 
    3841      ) 
     42    SET(CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) 
    3943       
    4044      # Maybe future CMake versions will implement this 
  • include/strEx.h

    r291548e r87cf3c4  
    812812    }; 
    813813    template<typename T> 
    814     int operator()(const T &s1, const T &s2) 
     814    int operator()(const T &s1, const T &s2) const 
    815815    { 
    816816      if (std::lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end(), CharLessI(m_locE))) 
  • modules/CheckSystem/CheckSystem.cpp

    r1ecd26f r87cf3c4  
    850850  NSPROCDATA__(const NSPROCDATA__ &other) : count(other.count), hung_count(other.hung_count), entry(other.entry), key(other.key) {} 
    851851} NSPROCDATA; 
    852 typedef std::map<std::wstring,NSPROCDATA,strEx::StrICmp> NSPROCLST; 
     852typedef std::map<std::wstring,NSPROCDATA> NSPROCLST; 
    853853 
    854854class NSC_error : public CEnumProcess::error_reporter { 
  • modules/LUAScript/LUAScript.cpp

    r5735dda r87cf3c4  
    3030LUAScript gLUAScript; 
    3131 
    32 BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) 
    33 { 
    34   NSCModuleWrapper::wrapDllMain(hModule, ul_reason_for_call); 
    35   return TRUE; 
    36 } 
    37  
    3832LUAScript::LUAScript() { 
    3933} 
     
    4135} 
    4236 
     37namespace sh = nscapi::settings_helper; 
    4338 
    44 bool LUAScript::loadModule(NSCAPI::moduleLoadMode mode) { 
    45   //LUA Scripts 
     39bool LUAScript::loadModule() { 
     40  return false; 
     41} 
     42bool LUAScript::loadModuleEx(std::wstring alias, NSCAPI::moduleLoadMode mode) { 
     43  //std::wstring appRoot = file_helpers::folders::get_local_appdata_folder(SZAPPNAME); 
    4644  try { 
    47     SETTINGS_REG_PATH(lua::SECTION); 
    48   } catch (NSCModuleHelper::NSCMHExcpetion &e) { 
    49     NSC_LOG_ERROR_STD(_T("Failed to register command: ") + e.msg_); 
     45 
     46    sh::settings_registry settings(nscapi::plugin_singleton->get_core()); 
     47    settings.set_alias(alias, _T("lua")); 
     48 
     49    settings.alias().add_path_to_settings() 
     50      (_T("LUA SCRIPT SECTION"), _T("Section for the LUAScripts module.")) 
     51 
     52      (_T("scripts"), sh::fun_values_path(boost::bind(&LUAScript::loadScript, this, _1)),  
     53      _T("LUA SCRIPTS SECTION"), _T("A list of scripts available to run from the LuaSCript module.")) 
     54      ; 
     55 
     56    settings.register_all(); 
     57    settings.notify(); 
     58 
     59//    if (!scriptDirectory_.empty()) { 
     60//      addAllScriptsFrom(scriptDirectory_); 
     61//    } 
     62    root_ = get_core()->getBasePath(); 
     63 
     64    //  } catch (nrpe::server::nrpe_exception &e) { 
     65    //    NSC_LOG_ERROR_STD(_T("Exception caught: ") + e.what()); 
     66    //    return false; 
    5067  } catch (...) { 
    51     NSC_LOG_ERROR_STD(_T("Failed to register command.")); 
     68    NSC_LOG_ERROR_STD(_T("Exception caught: <UNKNOWN EXCEPTION>")); 
     69    return false; 
    5270  } 
    53   std::list<std::wstring> commands = NSCModuleHelper::getSettingsSection(settings::lua::SECTION_PATH); 
    54   std::list<std::wstring>::const_iterator it; 
    55   for (it = commands.begin(); it != commands.end(); ++it) { 
    56     loadScript((*it)); 
    57   } 
     71  return true; 
     72 
     73//  std::list<std::wstring>::const_iterator it; 
     74//  for (it = commands.begin(); it != commands.end(); ++it) { 
     75//    loadScript((*it)); 
     76//  } 
    5877  return true; 
    5978} 
     
    6180void LUAScript::register_command(script_wrapper::lua_script* script, std::wstring command, std::wstring function) { 
    6281  NSC_LOG_MESSAGE(_T("Script loading: ") + script->get_script() + _T(": ") + command); 
    63   strEx::blindstr bstr = command.c_str(); 
     82  strEx::wci_string bstr = command.c_str(); 
    6483  commands_[bstr] = lua_func(script, function); 
    6584} 
     
    7089 
    7190    if (!file_helpers::checks::exists(file_)) { 
    72       file_ = NSCModuleHelper::getBasePath() + file; 
     91      file_ = root_ + file; 
    7392      if (!file_helpers::checks::exists(file_)) { 
    7493        NSC_LOG_ERROR(_T("Script not found: ") + file + _T(" (") + file_ + _T(")")); 
     
    85104  } catch (...) { 
    86105    NSC_LOG_ERROR_STD(_T("Could not load script: (Unknown exception) ") + file); 
    87     //assert(false); 
    88106  } 
    89107  return false; 
     
    130148 
    131149 
    132 NSCAPI::nagiosReturn LUAScript::handleCommand(const strEx::blindstr command, const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf) { 
     150NSCAPI::nagiosReturn LUAScript::handleCommand(const strEx::wci_string command, std::list<std::wstring> arguments, std::wstring &message, std::wstring &perf) { 
    133151  if (command == _T("LuaReload")) { 
    134     return reload(msg)?NSCAPI::returnOK:NSCAPI::returnCRIT; 
     152    return reload(message)?NSCAPI::returnOK:NSCAPI::returnCRIT; 
    135153  } 
    136154  cmd_list::const_iterator cit = commands_.find(command); 
    137155  if (cit == commands_.end()) 
    138156    return NSCAPI::returnIgnored; 
    139   return (*cit).second.handleCommand(this, command, argLen, char_args, msg, perf); 
     157  return (*cit).second.handleCommand(this, command.c_str(), arguments, message, perf); 
    140158} 
    141159 
    142160 
     161NSC_WRAP_DLL(); 
    143162NSC_WRAPPERS_MAIN_DEF(gLUAScript); 
    144163NSC_WRAPPERS_IGNORE_MSG_DEF(); 
  • modules/LUAScript/LUAScript.h

    r739db5a r87cf3c4  
    2626#include "script_wrapper.hpp" 
    2727 
    28 class LUAScript : script_wrapper::lua_handler { 
     28class LUAScript : public nscapi::impl::SimpleCommand, public script_wrapper::lua_handler, public nscapi::impl::simple_plugin { 
    2929private: 
    3030 
     
    3636    std::wstring function; 
    3737 
    38     NSCAPI::nagiosReturn handleCommand(lua_handler *handler, strEx::blindstr command, const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf) const { 
    39       return script->handleCommand(handler, function, command, argLen, char_args, msg, perf); 
     38    NSCAPI::nagiosReturn handleCommand(lua_handler *handler, std::wstring command, std::list<std::wstring> arguments, std::wstring &msg, std::wstring &perf) const { 
     39      return script->handleCommand(handler, function, command, arguments, msg, perf); 
    4040    } 
    4141  }; 
    4242 
    43   typedef std::map<strEx::blindstr,lua_func> cmd_list; 
     43  typedef std::map<strEx::wci_string,lua_func> cmd_list; 
    4444  typedef std::list<script_wrapper::lua_script*> script_list; 
    4545 
    4646  cmd_list commands_; 
    4747  script_list scripts_; 
     48  std::wstring root_; 
    4849 
    4950public: 
     
    5152  virtual ~LUAScript(); 
    5253  // Module calls 
    53   bool loadModule(NSCAPI::moduleLoadMode mode); 
     54  bool loadModule(); 
     55  bool loadModuleEx(std::wstring alias, NSCAPI::moduleLoadMode mode); 
     56 
    5457  bool unloadModule(); 
    5558  bool reload(std::wstring &msg); 
     
    6164    return _T("LUAScript..."); 
    6265  } 
    63   NSCModuleWrapper::module_version getModuleVersion() { 
    64     NSCModuleWrapper::module_version version = {0, 0, 1 }; 
     66  nscapi::plugin_wrapper::module_version getModuleVersion() { 
     67    nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 
    6568    return version; 
    6669  } 
     
    6972  bool hasMessageHandler(); 
    7073  bool loadScript(const std::wstring script); 
    71   NSCAPI::nagiosReturn handleCommand(const strEx::blindstr command, const unsigned int argLen, TCHAR **char_args, std::wstring &message, std::wstring &perf); 
     74  NSCAPI::nagiosReturn handleCommand(const strEx::wci_string command, std::list<std::wstring> arguments, std::wstring &message, std::wstring &perf); 
    7275  //NSCAPI::nagiosReturn RunLUA(const unsigned int argLen, TCHAR **char_args, std::wstring &message, std::wstring &perf); 
    7376  //NSCAPI::nagiosReturn extract_return(Lua_State &L, int arg_count,  std::wstring &message, std::wstring &perf); 
  • modules/LUAScript/script_wrapper.hpp

    r1ff950c r87cf3c4  
    194194        int nargs = lua_gettop( L ); 
    195195        if (nargs == 0) { 
    196           return luaL_error(L, "nscp.execute requires atleast 1 argument!"); 
     196          return luaL_error(L, "nscp.execute requires at least 1 argument!"); 
    197197        } 
    198198        unsigned int argLen = nargs-1; 
    199         arrayBuffer::arrayBuffer arguments = arrayBuffer::createArrayBuffer(argLen); 
     199        std::list<std::wstring> arguments; 
    200200        for (unsigned int i=argLen;i>0;i--) { 
    201           std::wstring arg = extract_string(L); 
    202           arrayBuffer::set(arguments, argLen, i-1, arg); 
     201          arguments.push_front(extract_string(L)); 
    203202          lua_pop(L, 1); 
    204203        } 
    205204        std::wstring command = extract_string(L); 
    206205        lua_pop(L, 1); 
    207         std::wstring msg; 
     206        std::wstring message; 
    208207        std::wstring perf; 
    209         NSCAPI::nagiosReturn ret = NSCModuleHelper::InjectCommand(command.c_str(), argLen, arguments, msg, perf); 
     208        NSCAPI::nagiosReturn ret = GET_CORE()->InjectSimpleCommand(command, arguments, message, perf); 
    210209        push_code(L, ret); 
    211         lua_pushstring(L, strEx::wstring_to_string(msg).c_str()); 
     210        lua_pushstring(L, strEx::wstring_to_string(message).c_str()); 
    212211        lua_pushstring(L, strEx::wstring_to_string(perf).c_str()); 
    213212        return 3; 
     
    242241      std::wstring k = pop_string(L); 
    243242      std::wstring s = pop_string(L); 
    244       push_string(L, NSCModuleHelper::getSettingsString(s, k, v)); 
     243      push_string(L, GET_CORE()->getSettingsString(s, k, v)); 
    245244      return 1; 
    246245    } 
     
    253252        v = pop_string(L); 
    254253      try { 
    255         std::list<std::wstring> list = NSCModuleHelper::getSettingsSection(v); 
     254        std::list<std::wstring> list = GET_CORE()->getSettingsSection(v); 
    256255        push_array(L, list); 
    257256      } catch (...) { 
     
    273272        str += pop_string(L); 
    274273      } 
    275       NSCModuleHelper::Message(mode, w.first, w.second, str); 
     274      GET_CORE()->Message(mode, to_string(w.first), w.second, str); 
    276275      return 0; 
    277276    } 
     
    362361    } 
    363362 
    364     NSCAPI::nagiosReturn handleCommand(lua_handler *handler, std::wstring function, strEx::blindstr command, const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf) { 
     363    NSCAPI::nagiosReturn handleCommand(lua_handler *handler, std::wstring function, std::wstring cmd, std::list<std::wstring> arguments, std::wstring &msg, std::wstring &perf) { 
    365364      lua_manager::set_handler(L, handler); 
    366365      lua_manager::set_script(L, this); 
     
    371370        throw LUAException(_T("Failed to run script: ") + script_ + _T(": Function not found: handle")); 
    372371      } 
    373       std::wstring cmd = command.c_str(); 
    374372      lua_pushstring(L, w2s(cmd).c_str());  
    375373 
    376       lua_createtable(L, 0, argLen); 
    377       for (unsigned int i=0;i<argLen;i++) { 
    378         lua_pushnumber(L,i+1); 
    379         lua_pushstring(L,strEx::wstring_to_string(char_args[i]).c_str()); 
     374      lua_createtable(L, 0, arguments.size()); 
     375      int i=0; 
     376      BOOST_FOREACH(std::wstring arg, arguments) { 
     377        lua_pushnumber(L,i++); 
     378        lua_pushstring(L,strEx::wstring_to_string(arg).c_str()); 
    380379        lua_settable(L,-3); 
    381380      } 
  • modules/LUAScript/stdafx.h

    r7f9c823 r87cf3c4  
    2121#pragma once 
    2222 
    23 #define WIN32_LEAN_AND_MEAN   // Exclude rarely-used stuff from Windows headers 
    24 // Windows Header Files: 
    25 #include <windows.h> 
    26  
    2723#include <string> 
    2824#include <functional> 
    2925 
     26#include <types.hpp> 
    3027#include <NSCAPI.h> 
    31 #include <NSCHelper.h> 
    32 #include <nsc_module_wrapper.hpp> 
    33  
    34 #ifdef MEMCHECK 
    35 #include <vld.h> 
    36 #endif 
     28#include <nscapi/plugin.hpp> 
  • service/CMakeLists.txt

    r1ecd26f r87cf3c4  
    8888 
    8989ENDIF(WIN32) 
     90IF(BREAKPAD_FOUND) 
     91  SET(EXTRA_LIBS ${BREAKPAD_COMMON_LIBRARY}) 
     92ENDIF(BREAKPAD_FOUND) 
    9093 
    9194 
     
    9699  ${Boost_FILESYSTEM_LIBRARY} 
    97100  ${NSCP_DEF_PLUGIN_LIB} 
     101  ${EXTRA_LIBS} 
    98102) 
    99103SET_TARGET_PROPERTIES(${TARGET} PROPERTIES FOLDER "core") 
  • version.txt

    r1ecd26f r87cf3c4  
    1 version=0.4.1 
     1version=0.4.0 
    22build=33 
    33date=2009-11-01 
Note: See TracChangeset for help on using the changeset viewer.