Changeset 220
- Timestamp:
- 11/22/09 23:09:39 (2 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
-
CMakeLists.txt (modified) (2 diffs)
-
build.cmake (modified) (1 diff)
-
include/nrpe/nrpepacket.hpp (modified) (5 diffs)
-
include/nsc_module_wrapper.hpp (modified) (2 diffs)
-
include/program_options_ex.hpp (modified) (1 diff)
-
include/types.hpp (modified) (1 diff)
-
modules/NRPEClient/NRPEClient.cpp (modified) (15 diffs)
-
modules/NRPEClient/NRPEClient.h (modified) (6 diffs)
-
modules/NRPEClient/stdafx.h (modified) (2 diffs)
-
service/NSCPlugin.cpp (modified) (1 diff)
-
service/NSCPlugin.h (modified) (2 diffs)
-
service/NSClient++.cpp (modified) (5 diffs)
-
service/NSClient++.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CMakeLists.txt
r217 r220 128 128 ADD_SUBDIRECTORY("service") 129 129 130 SET(ALL_MODULE_NAMES) 130 131 FILE(GLOB ALL_MODULES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "modules/*/CMakeLists.txt") 131 132 foreach(CURRENT_MODULE ${ALL_MODULES}) 132 133 get_filename_component(CURRENT_MODULE_PATH ${CURRENT_MODULE} PATH) 133 message(STATUS "Adding module: ${CURRENT_MODULE_PATH}") 134 get_filename_component(CURRENT_MODULE_NAME ${CURRENT_MODULE_PATH} NAME) 135 message(STATUS "Adding module: ${CURRENT_MODULE_PATH} (${CURRENT_MODULE_NAME})") 134 136 ADD_SUBDIRECTORY("${CURRENT_MODULE_PATH}") 137 SET(ALL_MODULE_NAMES ${ALL_MODULE_NAMES} ${CURRENT_MODULE_NAME}) 135 138 endforeach(CURRENT_MODULE ${ALL_MODULES}) 136 139 137 140 138 SET_TARGET_PROPERTIES("nsclient++" "CheckHelpers"PROPERTIES141 SET_TARGET_PROPERTIES("nsclient++" ${ALL_MODULE_NAMES} PROPERTIES 139 142 RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" 140 143 LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/modules" … … 145 148 if (MSVC_IDE) 146 149 # hack to get around the "Debug" and "Release" directories cmake tries to add on Windows 147 set_target_properties ("nsclient++" "CheckHelpers"PROPERTIES PREFIX "../")150 set_target_properties ("nsclient++" ${ALL_MODULE_NAMES} PROPERTIES PREFIX "../") 148 151 endif() -
trunk/build.cmake
r218 r220 4 4 set(BOOST_USE_MULTITHREADED ON) 5 5 6 SET(BOOST_INCLUDEDIR c:/src/include/boost-1_39/)7 SET(BOOST_LIBRARYDIR c:/src/lib/x86/)6 SET(BOOST_INCLUDEDIR D:/source/include/boost-1_40) 7 SET(BOOST_LIBRARYDIR d:/source/lib/x86/) 8 8 SET(BOOST_LIB_SUFFIX vc80-mt) 9 SET(BOOST_LIB_VERSION 1. 39)9 SET(BOOST_LIB_VERSION 1.40) -
trunk/include/nrpe/nrpepacket.hpp
r207 r220 21 21 #pragma once 22 22 23 #include <types.hpp> 23 24 24 typedef short int16_t;25 typedef unsigned long u_int32_t;26 25 27 26 class NRPEPacket { … … 79 78 { 80 79 } 81 NRPEPacket( NRPEPacket &other) : tmpBuffer(NULL) {80 NRPEPacket(const NRPEPacket &other) : tmpBuffer(NULL) { 82 81 payload_ = other.payload_; 83 82 type_ = other.type_; … … 88 87 buffer_length_ = other.buffer_length_; 89 88 } 89 NRPEPacket& operator=(NRPEPacket const& other) { 90 tmpBuffer=NULL; 91 payload_ = other.payload_; 92 type_ = other.type_; 93 version_ = other.version_; 94 result_ = other.result_; 95 crc32_ = other.crc32_; 96 calculatedCRC32_ = other.calculatedCRC32_; 97 buffer_length_ = other.buffer_length_; 98 return *this; 99 } 100 90 101 ~NRPEPacket() { 91 102 delete [] tmpBuffer; … … 98 109 delete [] tmpBuffer; 99 110 tmpBuffer = new char[getBufferLength()+1]; 100 ZeroMemory(tmpBuffer, getBufferLength()+1);111 //TODO readd this ZeroMemory(tmpBuffer, getBufferLength()+1); 101 112 packet *p = reinterpret_cast<packet*>(tmpBuffer); 102 113 p->result_code = htons(NSCHelper::nagios2int(result_)); … … 106 117 throw NRPEPacketException(_T("To much data cant create return packet (truncate datat)")); 107 118 //ZeroMemory(p->buffer, buffer_length_-1); 108 strncpy _s(p->buffer, buffer_length_-1, strEx::wstring_to_string(payload_).c_str(), payload_.length());119 strncpy(p->buffer, to_string(payload_).c_str(), payload_.length()); 109 120 p->buffer[payload_.length()] = 0; 110 121 p->crc32_value = 0; -
trunk/include/nsc_module_wrapper.hpp
r219 r220 44 44 45 45 #define NSC_WRAPPERS_CLI() \ 46 extern "C" int NSCommandLineExec(const wchar_t*,constunsigned int,wchar_t**)46 extern "C" int NSCommandLineExec(const unsigned int,wchar_t**) 47 47 48 48 #ifdef DEBUG … … 193 193 194 194 #define NSC_WRAPPERS_CLI_DEF(toObject) \ 195 extern int NSCommandLineExec(const wchar_t* command,constunsigned int argLen,wchar_t** args) { \196 try { \ 197 return toObject.commandLineExec( command,argLen, args); \195 extern int NSCommandLineExec(const unsigned int argLen,wchar_t** args) { \ 196 try { \ 197 return toObject.commandLineExec(argLen, args); \ 198 198 } catch (...) { \ 199 199 NSC_LOG_CRITICAL(_T("Unknown exception in: commandLineExec(...)")); \ -
trunk/include/program_options_ex.hpp
r115 r220 7 7 class basic_command_line_parser_ex : public boost::program_options::basic_command_line_parser<charT> { 8 8 public: 9 static boost::program_options::basic_parsed_options<charT> parse_command_line( const charT* arg0,int argc, charT* argv[], const boost::program_options::options_description& desc,9 static boost::program_options::basic_parsed_options<charT> parse_command_line(int argc, charT* argv[], const boost::program_options::options_description& desc, 10 10 int style = 0, boost::function1<std::pair<std::string, std::string>, const std::string&> ext = boost::program_options::ext_parser()) 11 11 { 12 return basic_command_line_parser_ex<charT>(arg 0, argc, argv).options(desc).style(style).extra_parser(ext).run();12 return basic_command_line_parser_ex<charT>(argc, argv).options(desc).style(style).extra_parser(ext).run(); 13 13 } 14 14 15 template<class charT , class Iterator>16 std::vector<std::basic_string<charT > >17 make_vector( const charT *a0,Iterator i, Iterator e)15 template<class charTx, class Iterator> 16 std::vector<std::basic_string<charTx> > 17 make_vector(Iterator i, Iterator e) 18 18 { 19 std::vector<std::basic_string<charT > > result;19 std::vector<std::basic_string<charTx> > result; 20 20 // Some compilers don't have templated constructor for 21 21 // vector, so we can't create vector from (argv+1, argv+argc) range 22 if (a0 != NULL)23 result.push_back(a0);22 //if (a0 != NULL) 23 // result.push_back(a0); 24 24 for(; i != e; ++i) 25 25 result.push_back(*i); 26 26 return result; 27 27 } 28 basic_command_line_parser_ex( const charT* arg0,int argc, charT* argv[])28 basic_command_line_parser_ex(int argc, charT* argv[]) 29 29 : boost::program_options::basic_command_line_parser<charT>( 30 make_vector<charT, charT**>(arg 0, argv, argv+argc)30 make_vector<charT, charT**>(argv, argv+argc) 31 31 ) 32 32 {} 33 /* 34 #ifdef _WIN32 33 35 basic_command_line_parser_ex(const std::wstring args) 34 36 : boost::program_options::basic_command_line_parser<charT>(boost::program_options::split_winmain(args)) 35 37 {} 38 #endif 39 */ 36 40 37 41 }; -
trunk/include/types.hpp
r219 r220 8 8 typedef void* LPVOID; 9 9 typedef int BOOL; 10 #endif 11 #ifdef WIN32 12 typedef short int16_t; 13 typedef unsigned long u_int32_t; 10 14 #endif 11 15 -
trunk/modules/NRPEClient/NRPEClient.cpp
r207 r220 25 25 #include <config.h> 26 26 #include <msvc_wrappers.h> 27 #include <execute_process.hpp> 28 #ifdef USE_BOOST 27 //#include <execute_process.hpp> 29 28 #include <program_options_ex.hpp> 30 #endif31 29 #include <strEx.h> 32 30 33 31 NRPEClient gNRPEClient; 34 32 33 #ifdef WIN32 35 34 BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) 36 35 { … … 38 37 return TRUE; 39 38 } 39 #endif 40 40 41 41 NRPEClient::NRPEClient() : buffer_length_(0), bInitSSL(false) { … … 77 77 78 78 void NRPEClient::addCommand(strEx::blindstr key, std::wstring args) { 79 #ifndef USE_BOOST80 NSC_LOG_ERROR_STD(_T("Could not parse: ") + key.c_str() + _T(" boost not avalible!"));81 #else82 79 try { 80 /* 81 TODO: reimplem,ent this! 83 82 boost::program_options::options_description desc = get_optionDesc(); 84 83 boost::program_options::positional_options_description p = get_optionsPositional(); … … 86 85 boost::program_options::variables_map vm; 87 86 boost::program_options::store( 88 basic_command_line_parser_ex< TCHAR>(args).options(desc).positional(p).run()87 basic_command_line_parser_ex<wchar_t>(args).options(desc).positional(p).run() 89 88 , vm); 90 89 boost::program_options::notify(vm); … … 92 91 NSC_DEBUG_MSG_STD(_T("Added NRPE Client: ") + key.c_str() + _T(" = ") + cd.toString()); 93 92 commands[key] = cd; 93 */ 94 94 } catch (boost::program_options::validation_error &e) { 95 95 NSC_LOG_ERROR_STD(_T("Could not parse: ") + key.c_str() + strEx::string_to_wstring(e.what())); … … 97 97 NSC_LOG_ERROR_STD(_T("Could not parse: ") + key.c_str()); 98 98 } 99 #endif100 99 } 101 100 … … 139 138 } 140 139 141 #ifdef USE_BOOST142 140 boost::program_options::options_description NRPEClient::get_optionDesc() { 143 141 boost::program_options::options_description desc("Allowed options"); … … 151 149 ("buffer-length,l", boost::program_options::value<int>(), std::string("Length of payload (has to be same as on the server (default=" + strEx::s::itos(buffer_length_) + ")").c_str()) 152 150 ("no-ssl,n", "Do not initial an ssl handshake with the server, talk in plaintext.") 153 ("arguments,a", boost::program_options::wvalue<std::vector<std::wstring> >(), "list of arguments")151 ("arguments,a", boost::program_options::wvalue<std::vector<std::wstring> >(), "list of arguments") 154 152 ; 155 153 return desc; … … 160 158 return p; 161 159 } 162 NRPEClient::nrpe_connection_data NRPEClient::get_ConectionData(boost::program_options::variables_map &vm) { 163 nrpe_connection_data ret(buffer_length_); 164 if (vm.count("host")) 165 ret.host = vm["host"].as<std::wstring>(); 166 if (vm.count("port")) 167 ret.port = vm["port"].as<int>(); 168 if (vm.count("timeout")) 169 ret.timeout = vm["timeout"].as<int>(); 170 if (vm.count("buffer-length")) 171 ret.buffer_length = vm["buffer-length"].as<int>(); 172 if (vm.count("command")) 173 ret.command = vm["command"].as<std::wstring>(); 174 if (vm.count("arguments")) { 175 std::vector<std::wstring> v = vm["arguments"].as<std::vector<std::wstring>>(); 176 for (std::vector<std::wstring>::const_iterator cit = v.begin(); cit != v.end(); ++cit) { 177 if (!ret.arguments.empty()) 178 ret.arguments += _T("!"); 179 ret.arguments += *cit; 180 } 181 } 182 if (vm.count("no-ssl")) 183 ret.ssl = false; 184 return ret; 185 } 186 #endif 187 188 189 int NRPEClient::commandLineExec(const TCHAR* command, const unsigned int argLen, TCHAR** args) { 190 #ifndef USE_BOOST 191 NSC_LOG_ERROR_STD(_T("Could not execute ") + std::wstring(command) + _T(" boost not avalible!")); 192 return NSCAPI::returnUNKNOWN; 193 #else 160 161 namespace po = boost::program_options; 162 int NRPEClient::commandLineExec(const unsigned int argLen, TCHAR** args) { 194 163 try { 195 boost::program_options::options_description desc = get_optionDesc(); 196 boost::program_options::positional_options_description p = get_optionsPositional(); 197 164 165 NRPEClient::nrpe_connection_data command_data; 198 166 boost::program_options::variables_map vm; 199 boost::program_options::store( 200 basic_command_line_parser_ex<TCHAR>(command, argLen, args).options(desc).positional(p).run() 201 , vm); 202 boost::program_options::notify(vm); 167 168 po::options_description desc("Allowed options"); 169 buffer_length_ = SETTINGS_GET_INT(nrpe::PAYLOAD_LENGTH); 170 desc.add_options() 171 ("help,h", "Show this help message.") 172 ("host,H", po::wvalue<std::wstring>(&command_data.host), "The address of the host running the NRPE daemon") 173 ("port,p", po::value<int>(&command_data.port), "The port on which the daemon is running (default=5666)") 174 ("command,c", po::wvalue<std::wstring>(&command_data.command), "The name of the command that the remote daemon should run") 175 ("timeout,t", po::value<int>(&command_data.timeout), "Number of seconds before connection times out (default=10)") 176 ("buffer-length,l", po::value<unsigned int>(&command_data.buffer_length), std::string("Length of payload (has to be same as on the server (default=" + to_string(buffer_length_) + ")").c_str()) 177 ("no-ssl,n", po::value<bool>(&command_data.no_ssl)->zero_tokens()->default_value(false), "Do not initial an ssl handshake with the server, talk in plaintext.") 178 ("arguments,a", po::wvalue<std::vector<std::wstring> >(&command_data.argument_vector), "list of arguments") 179 ; 180 181 po::positional_options_description p; 182 p.add("arguments", -1); 183 po::wparsed_options parsed = basic_command_line_parser_ex<wchar_t>(argLen, args).options(desc).positional(p).run(); 184 po::store(parsed, vm); 185 po::notify(vm); 186 command_data.parse_arguments(); 187 188 std::wcout << _T("parsed data: ") << command_data.toString()<< std::endl; 203 189 204 190 if (vm.count("help")) { … … 206 192 return 1; 207 193 } 208 209 NRPEClient::nrpe_connection_data command = get_ConectionData(vm); 210 nrpe_result_data result = execute_nrpe_command(command, command.arguments); 194 nrpe_result_data result = execute_nrpe_command(command_data, command_data.arguments); 211 195 std::wcout << result.text << std::endl; 212 196 return result.result; … … 217 201 } 218 202 return NSCAPI::returnUNKNOWN; 219 #endif220 203 } 221 204 NRPEClient::nrpe_result_data NRPEClient::execute_nrpe_command(nrpe_connection_data con, std::wstring arguments) { 222 205 try { 223 206 NRPEPacket packet; 224 if ( con.ssl) {207 if (!con.no_ssl) { 225 208 #ifdef USE_SSL 226 209 packet = send_ssl(con.host, con.port, con.timeout, NRPEPacket::make_request(con.get_cli(arguments), con.buffer_length)); … … 233 216 } catch (NRPEPacket::NRPEPacketException &e) { 234 217 return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("NRPE Packet errro: ") + e.getMessage()); 235 } catch (simpleSocket::SocketException &e) {236 return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("Socket error: ") + e.getMessage());237 218 } catch (std::runtime_error &e) { 238 219 return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("Socket error: ") + boost::lexical_cast<std::wstring>(e.what())); 239 #ifdef USE_SSL240 } catch (simpleSSL::SSLException &e) {241 return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("SSL Socket error: ") + e.getMessage());242 #endif243 220 } catch (...) { 244 221 return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("Unknown error -- REPORT THIS!")); … … 369 346 } 370 347 }; 348 #ifdef USE_SSL 371 349 372 350 class nrpe_ssl_socket { … … 419 397 } 420 398 }; 421 422 NRPEPacket NRPEClient::send_nossl(std::wstring host, int port, int timeout, NRPEPacket packet)423 {424 boost::asio::io_service io_service;425 nrpe_socket socket(io_service, host, port);426 socket.send(packet, boost::posix_time::seconds(timeout));427 return socket.recv(packet, boost::posix_time::seconds(timeout));428 }429 430 399 NRPEPacket NRPEClient::send_ssl(std::wstring host, int port, int timeout, NRPEPacket packet) 431 400 { … … 439 408 return socket.recv(packet, boost::posix_time::seconds(timeout)); 440 409 } 410 #endif 411 412 NRPEPacket NRPEClient::send_nossl(std::wstring host, int port, int timeout, NRPEPacket packet) 413 { 414 boost::asio::io_service io_service; 415 nrpe_socket socket(io_service, host, port); 416 socket.send(packet, boost::posix_time::seconds(timeout)); 417 return socket.recv(packet, boost::posix_time::seconds(timeout)); 418 } 419 441 420 /* 442 421 NRPEPacket NRPEClient::send_nossl(std::wstring host, int port, int timeout, NRPEPacket packet) -
trunk/modules/NRPEClient/NRPEClient.h
r201 r220 21 21 22 22 NSC_WRAPPERS_MAIN(); 23 #include <Socket.h>24 #ifdef USE_SSL25 #include <SSLSocket.h>26 #endif27 23 #include <map> 28 #include <nrpe/NRPEPacket.hpp> 29 #ifdef USE_BOOST 24 #include <nrpe/nrpepacket.hpp> 30 25 #include <boost/program_options.hpp> 31 #endif32 26 33 27 … … 42 36 std::wstring arguments; 43 37 std::wstring command_line; 38 std::vector<std::wstring> argument_vector; 44 39 int port; 45 40 int timeout; 46 41 unsigned int buffer_length; 47 bool ssl;42 bool no_ssl; 48 43 nrpe_connection_data(unsigned int buffer_length_ = 1024) 49 44 : host(_T("127.0.0.1")), 50 45 port(5666), 51 46 timeout(10), 52 ssl(true),47 no_ssl(false), 53 48 buffer_length(buffer_length_) 54 49 {} 50 void parse_arguments() { 51 for (std::vector<std::wstring>::const_iterator cit = argument_vector.begin(); cit != argument_vector.end(); ++cit) { 52 if (!arguments.empty()) 53 arguments += _T("!"); 54 arguments += *cit; 55 } 56 } 55 57 std::wstring get_cli(std::wstring arguments_) { 56 58 if (command_line.empty()) { … … 70 72 ss << _T(", port: ") << port; 71 73 ss << _T(", timeout: ") << timeout; 72 ss << _T(", ssl: ") <<ssl;74 ss << _T(", no_ssl: ") << no_ssl; 73 75 ss << _T(", buffer_length: ") << buffer_length; 74 76 return ss.str(); … … 107 109 std::wstring getModuleDescription() { 108 110 return _T("A simple client for checking remote NRPE servers (think proxy).\n") 109 #ifndef USE_BOOST110 _T("BOOST support is missing (this is probably very bad)!\n")111 #endif112 111 #ifndef USE_SSL 113 112 _T("SSL support is missing (so you cant use encryption)!") … … 119 118 bool hasMessageHandler(); 120 119 NSCAPI::nagiosReturn handleCommand(const strEx::blindstr command, const unsigned int argLen, TCHAR **char_args, std::wstring &message, std::wstring &perf); 121 int commandLineExec(const TCHAR* command,constunsigned int argLen,TCHAR** args);120 int commandLineExec(const unsigned int argLen,TCHAR** args); 122 121 std::wstring getConfigurationMeta(); 123 122 … … 127 126 NRPEPacket send_ssl(std::wstring host, int port, int timeout, NRPEPacket packet); 128 127 void initSSL(); 129 #ifdef USE_BOOST 130 boost::program_options::options_description NRPEClient::get_optionDesc(); 131 boost::program_options::positional_options_description NRPEClient::get_optionsPositional(); 132 nrpe_connection_data NRPEClient::get_ConectionData(boost::program_options::variables_map &vm); 133 #endif 128 boost::program_options::options_description get_optionDesc(); 129 boost::program_options::positional_options_description get_optionsPositional(); 130 nrpe_connection_data get_ConectionData(boost::program_options::variables_map &vm); 134 131 135 132 -
trunk/modules/NRPEClient/stdafx.h
r207 r220 21 21 #pragma once 22 22 23 #ifdef _WIN32 23 24 #define _WIN32_WINNT 0x0400 24 25 25 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 26 26 // Windows Header Files: 27 27 #include <windows.h> 28 28 #include <winsock2.h> 29 #endif 29 30 30 31 #include <string> … … 42 43 #include <boost/optional.hpp> 43 44 #include <boost/bind.hpp> 45 #ifdef USE_SSL 44 46 #include <boost/asio/ssl.hpp> 47 #endif 45 48 46 #ifdef MEMCHECK47 #include <vld.h>48 #endif -
trunk/service/NSCPlugin.cpp
r219 r220 391 391 } 392 392 393 int NSCPlugin::commandLineExec(const wchar_t* command, constunsigned int argLen, wchar_t **arguments) {393 int NSCPlugin::commandLineExec(const unsigned int argLen, wchar_t **arguments) { 394 394 if (fCommandLineExec== NULL) 395 395 throw NSPluginException(module_, _T("Module does not support CommandLineExec")); 396 396 try { 397 return fCommandLineExec( command,argLen, arguments);397 return fCommandLineExec(argLen, arguments); 398 398 } catch (...) { 399 399 throw NSPluginException(module_, _T("Unhandled exception in commandLineExec.")); -
trunk/service/NSCPlugin.h
r219 r220 119 119 typedef int (*lpHasMessageHandler)(); 120 120 typedef NSCAPI::nagiosReturn (*lpHandleCommand)(const wchar_t*,const unsigned int, wchar_t**,wchar_t*,unsigned int,wchar_t *,unsigned int); 121 typedef int (*lpCommandLineExec)(const wchar_t*,constunsigned int,wchar_t**);121 typedef int (*lpCommandLineExec)(const unsigned int,wchar_t**); 122 122 typedef int (*lpHandleMessage)(int,const wchar_t*,const int,const wchar_t*); 123 123 typedef int (*lpUnLoadModule)(); … … 160 160 void unload(void); 161 161 std::wstring getCongifurationMeta(); 162 int commandLineExec(const wchar_t* command, constunsigned int argLen, wchar_t **arguments);162 int commandLineExec(const unsigned int argLen, wchar_t **arguments); 163 163 void showTray(); 164 164 void hideTray(); -
trunk/service/NSClient++.cpp
r219 r220 354 354 mainClient.enableDebug(false); 355 355 mainClient.initCore(false); 356 if (argc>= 4)357 nRetCode = mainClient.commandLineExec(argv[2], arg v[3], argc-4, &argv[4]);356 if (argc>=3) 357 nRetCode = mainClient.commandLineExec(argv[2], argc-3, &argv[3]); 358 358 else 359 nRetCode = mainClient.commandLineExec(argv[2], argv[3],0, NULL);359 nRetCode = mainClient.commandLineExec(argv[2], 0, NULL); 360 360 mainClient.exitCore(true); 361 361 return nRetCode; … … 404 404 } else if (argc > 2) { 405 405 g_bConsoleLog = true; 406 std::wcout << _T(" * * * * * * * ") << std::endl; 406 407 mainClient.initCore(true); 407 408 if (argc>=3) 408 nRetCode = mainClient.commandLineExec(argv[1], arg v[2], argc-3, &argv[3]);409 nRetCode = mainClient.commandLineExec(argv[1], argc-2, &argv[2]); 409 410 else 410 nRetCode = mainClient.commandLineExec(argv[1], argv[2],0, NULL);411 nRetCode = mainClient.commandLineExec(argv[1], 0, NULL); 411 412 mainClient.exitCore(true); 412 413 return nRetCode; … … 888 889 // Member functions 889 890 890 int NSClientT::commandLineExec(const wchar_t* module, const wchar_t* command, constunsigned int argLen, wchar_t** args) {891 int NSClientT::commandLineExec(const wchar_t* module, const unsigned int argLen, wchar_t** args) { 891 892 std::wstring sModule = module; 892 893 std::wstring moduleList = _T(""); … … 906 907 LOG_DEBUG_STD(_T("Found module: ") + p->getName() + _T("...")); 907 908 try { 908 return p->commandLineExec( command,argLen, args);909 return p->commandLineExec(argLen, args); 909 910 } catch (NSPluginException e) { 910 911 LOG_ERROR_CORE_STD(_T("Could not execute command: ") + e.error_ + _T(" in ") + e.file_); … … 919 920 LOG_DEBUG_STD(_T("Loading plugin: ") + plugin->getName() + _T("...")); 920 921 plugin->load_plugin(NSCAPI::dontStart); 921 return plugin->commandLineExec( command,argLen, args);922 return plugin->commandLineExec(argLen, args); 922 923 } catch (NSPluginException e) { 923 924 LOG_MESSAGE_STD(_T("Module (") + e.file_ + _T(") was not found: ") + e.error_); -
trunk/service/NSClient++.h
r219 r220 168 168 std::wstring execute(std::wstring password, std::wstring cmd, std::list<std::wstring> args); 169 169 void reportMessage(int msgType, const wchar_t* file, const int line, std::wstring message); 170 int commandLineExec(const wchar_t* module, const wchar_t* command, constunsigned int argLen, wchar_t** args);170 int commandLineExec(const wchar_t* module, const unsigned int argLen, wchar_t** args); 171 171 172 172 void addPlugins(const std::list<std::wstring> plugins);
Note: See TracChangeset
for help on using the changeset viewer.







