Changeset 220


Ignore:
Timestamp:
11/22/09 23:09:39 (2 years ago)
Author:
mickem
Message:

Semi-working NRPEClient (debian boost is broken so need to recompile it myself before I can finish it off) But "should almost work" (from CLI)

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/CMakeLists.txt

    r217 r220  
    128128ADD_SUBDIRECTORY("service") 
    129129 
     130SET(ALL_MODULE_NAMES) 
    130131FILE(GLOB ALL_MODULES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "modules/*/CMakeLists.txt") 
    131132foreach(CURRENT_MODULE ${ALL_MODULES}) 
    132133  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})") 
    134136  ADD_SUBDIRECTORY("${CURRENT_MODULE_PATH}") 
     137  SET(ALL_MODULE_NAMES ${ALL_MODULE_NAMES} ${CURRENT_MODULE_NAME}) 
    135138endforeach(CURRENT_MODULE ${ALL_MODULES}) 
    136139 
    137140 
    138 SET_TARGET_PROPERTIES("nsclient++" "CheckHelpers" PROPERTIES  
     141SET_TARGET_PROPERTIES("nsclient++" ${ALL_MODULE_NAMES} PROPERTIES  
    139142        RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" 
    140143    LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/modules" 
     
    145148if (MSVC_IDE) 
    146149    # 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 "../") 
    148151endif() 
  • trunk/build.cmake

    r218 r220  
    44set(BOOST_USE_MULTITHREADED ON) 
    55 
    6 SET(BOOST_INCLUDEDIR c:/src/include/boost-1_39/) 
    7 SET(BOOST_LIBRARYDIR c:/src/lib/x86/) 
     6SET(BOOST_INCLUDEDIR D:/source/include/boost-1_40) 
     7SET(BOOST_LIBRARYDIR d:/source/lib/x86/) 
    88SET(BOOST_LIB_SUFFIX vc80-mt) 
    9 SET(BOOST_LIB_VERSION 1.39) 
     9SET(BOOST_LIB_VERSION 1.40) 
  • trunk/include/nrpe/nrpepacket.hpp

    r207 r220  
    2121#pragma once 
    2222 
     23#include <types.hpp> 
    2324 
    24 typedef short int16_t; 
    25 typedef unsigned long u_int32_t; 
    2625 
    2726class NRPEPacket { 
     
    7978  { 
    8079  } 
    81   NRPEPacket(NRPEPacket &other) : tmpBuffer(NULL) { 
     80  NRPEPacket(const NRPEPacket &other) : tmpBuffer(NULL) { 
    8281    payload_ = other.payload_; 
    8382    type_ = other.type_; 
     
    8887    buffer_length_ = other.buffer_length_; 
    8988  } 
     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 
    90101  ~NRPEPacket() { 
    91102    delete [] tmpBuffer; 
     
    98109    delete [] tmpBuffer; 
    99110    tmpBuffer = new char[getBufferLength()+1]; 
    100     ZeroMemory(tmpBuffer, getBufferLength()+1); 
     111    //TODO readd this ZeroMemory(tmpBuffer, getBufferLength()+1); 
    101112    packet *p = reinterpret_cast<packet*>(tmpBuffer); 
    102113    p->result_code = htons(NSCHelper::nagios2int(result_)); 
     
    106117      throw NRPEPacketException(_T("To much data cant create return packet (truncate datat)")); 
    107118    //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()); 
    109120    p->buffer[payload_.length()] = 0; 
    110121    p->crc32_value = 0; 
  • trunk/include/nsc_module_wrapper.hpp

    r219 r220  
    4444 
    4545#define NSC_WRAPPERS_CLI() \ 
    46   extern "C" int NSCommandLineExec(const wchar_t*,const unsigned int,wchar_t**) 
     46  extern "C" int NSCommandLineExec(const unsigned int,wchar_t**) 
    4747 
    4848#ifdef DEBUG 
     
    193193 
    194194#define NSC_WRAPPERS_CLI_DEF(toObject) \ 
    195   extern int NSCommandLineExec(const wchar_t* command,const unsigned 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); \ 
    198198    } catch (...) { \ 
    199199      NSC_LOG_CRITICAL(_T("Unknown exception in: commandLineExec(...)")); \ 
  • trunk/include/program_options_ex.hpp

    r115 r220  
    77class basic_command_line_parser_ex : public boost::program_options::basic_command_line_parser<charT> { 
    88public: 
    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, 
    1010    int style = 0, boost::function1<std::pair<std::string, std::string>, const std::string&> ext = boost::program_options::ext_parser()) 
    1111  { 
    12     return basic_command_line_parser_ex<charT>(arg0, 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(); 
    1313  } 
    1414 
    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) 
    1818    { 
    19       std::vector<std::basic_string<charT> > result; 
     19      std::vector<std::basic_string<charTx> > result; 
    2020      // Some compilers don't have templated constructor for  
    2121      // 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); 
    2424      for(; i != e; ++i) 
    2525        result.push_back(*i); 
    2626      return result;             
    2727    } 
    28     basic_command_line_parser_ex(const charT* arg0, int argc, charT* argv[])  
     28    basic_command_line_parser_ex(int argc, charT* argv[])  
    2929      : boost::program_options::basic_command_line_parser<charT>( 
    30       make_vector<charT, charT**>(arg0, argv, argv+argc) 
     30      make_vector<charT, charT**>(argv, argv+argc) 
    3131      ) 
    3232    {} 
     33    /* 
     34#ifdef _WIN32 
    3335    basic_command_line_parser_ex(const std::wstring args)  
    3436      : boost::program_options::basic_command_line_parser<charT>(boost::program_options::split_winmain(args)) 
    3537    {} 
     38#endif 
     39    */ 
    3640 
    3741}; 
  • trunk/include/types.hpp

    r219 r220  
    88typedef void* LPVOID; 
    99typedef int BOOL; 
     10#endif 
     11#ifdef WIN32 
     12typedef short int16_t; 
     13typedef unsigned long u_int32_t; 
    1014#endif 
    1115 
  • trunk/modules/NRPEClient/NRPEClient.cpp

    r207 r220  
    2525#include <config.h> 
    2626#include <msvc_wrappers.h> 
    27 #include <execute_process.hpp> 
    28 #ifdef USE_BOOST 
     27//#include <execute_process.hpp> 
    2928#include <program_options_ex.hpp> 
    30 #endif 
    3129#include <strEx.h> 
    3230 
    3331NRPEClient gNRPEClient; 
    3432 
     33#ifdef WIN32 
    3534BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) 
    3635{ 
     
    3837  return TRUE; 
    3938} 
     39#endif 
    4040 
    4141NRPEClient::NRPEClient() : buffer_length_(0), bInitSSL(false) { 
     
    7777 
    7878void NRPEClient::addCommand(strEx::blindstr key, std::wstring args) { 
    79 #ifndef USE_BOOST 
    80   NSC_LOG_ERROR_STD(_T("Could not parse: ") + key.c_str() + _T(" boost not avalible!")); 
    81 #else 
    8279  try { 
     80    /* 
     81    TODO: reimplem,ent this! 
    8382    boost::program_options::options_description desc = get_optionDesc(); 
    8483    boost::program_options::positional_options_description p = get_optionsPositional(); 
     
    8685    boost::program_options::variables_map vm; 
    8786    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() 
    8988      , vm); 
    9089    boost::program_options::notify(vm);  
     
    9291    NSC_DEBUG_MSG_STD(_T("Added NRPE Client: ") + key.c_str() + _T(" = ") + cd.toString()); 
    9392    commands[key] = cd; 
     93    */ 
    9494  } catch (boost::program_options::validation_error &e) { 
    9595    NSC_LOG_ERROR_STD(_T("Could not parse: ") + key.c_str() + strEx::string_to_wstring(e.what())); 
     
    9797    NSC_LOG_ERROR_STD(_T("Could not parse: ") + key.c_str()); 
    9898  } 
    99 #endif 
    10099} 
    101100 
     
    139138} 
    140139 
    141 #ifdef USE_BOOST 
    142140boost::program_options::options_description NRPEClient::get_optionDesc() { 
    143141  boost::program_options::options_description desc("Allowed options"); 
     
    151149    ("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()) 
    152150    ("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") 
    154152    ; 
    155153  return desc; 
     
    160158  return p; 
    161159} 
    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 
     161namespace po = boost::program_options; 
     162int NRPEClient::commandLineExec(const unsigned int argLen, TCHAR** args) { 
    194163  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; 
    198166    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; 
    203189 
    204190    if (vm.count("help")) { 
     
    206192      return 1; 
    207193    } 
    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); 
    211195    std::wcout << result.text << std::endl; 
    212196    return result.result; 
     
    217201  } 
    218202  return NSCAPI::returnUNKNOWN; 
    219 #endif 
    220203} 
    221204NRPEClient::nrpe_result_data NRPEClient::execute_nrpe_command(nrpe_connection_data con, std::wstring arguments) { 
    222205  try { 
    223206    NRPEPacket packet; 
    224     if (con.ssl) { 
     207    if (!con.no_ssl) { 
    225208#ifdef USE_SSL 
    226209      packet = send_ssl(con.host, con.port, con.timeout, NRPEPacket::make_request(con.get_cli(arguments), con.buffer_length)); 
     
    233216  } catch (NRPEPacket::NRPEPacketException &e) { 
    234217    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()); 
    237218  } catch (std::runtime_error &e) { 
    238219    return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("Socket error: ") + boost::lexical_cast<std::wstring>(e.what())); 
    239 #ifdef USE_SSL 
    240   } catch (simpleSSL::SSLException &e) { 
    241     return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("SSL Socket error: ") + e.getMessage()); 
    242 #endif 
    243220  } catch (...) { 
    244221    return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("Unknown error -- REPORT THIS!")); 
     
    369346  } 
    370347}; 
     348#ifdef USE_SSL 
    371349 
    372350class nrpe_ssl_socket { 
     
    419397  } 
    420398}; 
    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  
    430399NRPEPacket NRPEClient::send_ssl(std::wstring host, int port, int timeout, NRPEPacket packet) 
    431400{ 
     
    439408  return socket.recv(packet, boost::posix_time::seconds(timeout)); 
    440409} 
     410#endif 
     411 
     412NRPEPacket 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 
    441420/* 
    442421NRPEPacket NRPEClient::send_nossl(std::wstring host, int port, int timeout, NRPEPacket packet) 
  • trunk/modules/NRPEClient/NRPEClient.h

    r201 r220  
    2121 
    2222NSC_WRAPPERS_MAIN(); 
    23 #include <Socket.h> 
    24 #ifdef USE_SSL 
    25 #include <SSLSocket.h> 
    26 #endif 
    2723#include <map> 
    28 #include <nrpe/NRPEPacket.hpp> 
    29 #ifdef USE_BOOST 
     24#include <nrpe/nrpepacket.hpp> 
    3025#include <boost/program_options.hpp> 
    31 #endif 
    3226 
    3327 
     
    4236    std::wstring arguments; 
    4337    std::wstring command_line; 
     38    std::vector<std::wstring> argument_vector; 
    4439    int port; 
    4540    int timeout; 
    4641    unsigned int buffer_length; 
    47     bool ssl; 
     42    bool no_ssl; 
    4843    nrpe_connection_data(unsigned int buffer_length_ = 1024)  
    4944      : host(_T("127.0.0.1")),  
    5045      port(5666),  
    5146      timeout(10),  
    52       ssl(true),  
     47      no_ssl(false),  
    5348      buffer_length(buffer_length_)  
    5449    {} 
     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    } 
    5557    std::wstring get_cli(std::wstring arguments_) { 
    5658      if (command_line.empty()) { 
     
    7072      ss << _T(", port: ") << port; 
    7173      ss << _T(", timeout: ") << timeout; 
    72       ss << _T(", ssl: ") << ssl; 
     74      ss << _T(", no_ssl: ") << no_ssl; 
    7375      ss << _T(", buffer_length: ") << buffer_length; 
    7476      return ss.str(); 
     
    107109  std::wstring getModuleDescription() { 
    108110    return _T("A simple client for checking remote NRPE servers (think proxy).\n") 
    109 #ifndef USE_BOOST 
    110     _T("BOOST support is missing (this is probably very bad)!\n") 
    111 #endif 
    112111#ifndef USE_SSL 
    113112    _T("SSL support is missing (so you cant use encryption)!") 
     
    119118  bool hasMessageHandler(); 
    120119  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,const unsigned int argLen,TCHAR** args); 
     120  int commandLineExec(const unsigned int argLen,TCHAR** args); 
    122121  std::wstring getConfigurationMeta(); 
    123122 
     
    127126  NRPEPacket send_ssl(std::wstring host, int port, int timeout, NRPEPacket packet); 
    128127  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); 
    134131 
    135132 
  • trunk/modules/NRPEClient/stdafx.h

    r207 r220  
    2121#pragma once 
    2222 
     23#ifdef _WIN32 
    2324#define _WIN32_WINNT 0x0400 
    24  
    2525#define WIN32_LEAN_AND_MEAN   // Exclude rarely-used stuff from Windows headers 
    2626// Windows Header Files: 
    2727#include <windows.h> 
    2828#include <winsock2.h> 
     29#endif 
    2930 
    3031#include <string> 
     
    4243#include <boost/optional.hpp> 
    4344#include <boost/bind.hpp> 
     45#ifdef USE_SSL 
    4446#include <boost/asio/ssl.hpp> 
     47#endif 
    4548 
    46 #ifdef MEMCHECK 
    47 #include <vld.h> 
    48 #endif 
  • trunk/service/NSCPlugin.cpp

    r219 r220  
    391391} 
    392392 
    393 int NSCPlugin::commandLineExec(const wchar_t* command, const unsigned int argLen, wchar_t **arguments) { 
     393int NSCPlugin::commandLineExec(const unsigned int argLen, wchar_t **arguments) { 
    394394  if (fCommandLineExec== NULL) 
    395395    throw NSPluginException(module_, _T("Module does not support CommandLineExec")); 
    396396  try { 
    397     return fCommandLineExec(command, argLen, arguments); 
     397    return fCommandLineExec(argLen, arguments); 
    398398  } catch (...) { 
    399399    throw NSPluginException(module_, _T("Unhandled exception in commandLineExec.")); 
  • trunk/service/NSCPlugin.h

    r219 r220  
    119119  typedef int (*lpHasMessageHandler)(); 
    120120  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*,const unsigned int,wchar_t**); 
     121  typedef int (*lpCommandLineExec)(const unsigned int,wchar_t**); 
    122122  typedef int (*lpHandleMessage)(int,const wchar_t*,const int,const wchar_t*); 
    123123  typedef int (*lpUnLoadModule)(); 
     
    160160  void unload(void); 
    161161  std::wstring getCongifurationMeta(); 
    162   int commandLineExec(const wchar_t* command, const unsigned int argLen, wchar_t **arguments); 
     162  int commandLineExec(const unsigned int argLen, wchar_t **arguments); 
    163163  void showTray(); 
    164164  void hideTray(); 
  • trunk/service/NSClient++.cpp

    r219 r220  
    354354      mainClient.enableDebug(false); 
    355355      mainClient.initCore(false); 
    356       if (argc>=4) 
    357         nRetCode = mainClient.commandLineExec(argv[2], argv[3], argc-4, &argv[4]); 
     356      if (argc>=3) 
     357        nRetCode = mainClient.commandLineExec(argv[2], argc-3, &argv[3]); 
    358358      else 
    359         nRetCode = mainClient.commandLineExec(argv[2], argv[3], 0, NULL); 
     359        nRetCode = mainClient.commandLineExec(argv[2], 0, NULL); 
    360360      mainClient.exitCore(true); 
    361361      return nRetCode; 
     
    404404  } else if (argc > 2) { 
    405405    g_bConsoleLog = true; 
     406    std::wcout << _T(" * * * * * * * ") << std::endl; 
    406407    mainClient.initCore(true); 
    407408    if (argc>=3) 
    408       nRetCode = mainClient.commandLineExec(argv[1], argv[2], argc-3, &argv[3]); 
     409      nRetCode = mainClient.commandLineExec(argv[1], argc-2, &argv[2]); 
    409410    else 
    410       nRetCode = mainClient.commandLineExec(argv[1], argv[2], 0, NULL); 
     411      nRetCode = mainClient.commandLineExec(argv[1], 0, NULL); 
    411412    mainClient.exitCore(true); 
    412413    return nRetCode; 
     
    888889// Member functions 
    889890 
    890 int NSClientT::commandLineExec(const wchar_t* module, const wchar_t* command, const unsigned int argLen, wchar_t** args) { 
     891int NSClientT::commandLineExec(const wchar_t* module, const unsigned int argLen, wchar_t** args) { 
    891892  std::wstring sModule = module; 
    892893  std::wstring moduleList = _T(""); 
     
    906907          LOG_DEBUG_STD(_T("Found module: ") + p->getName() + _T("...")); 
    907908          try { 
    908             return p->commandLineExec(command, argLen, args); 
     909            return p->commandLineExec(argLen, args); 
    909910          } catch (NSPluginException e) { 
    910911            LOG_ERROR_CORE_STD(_T("Could not execute command: ") + e.error_ + _T(" in ") + e.file_); 
     
    919920    LOG_DEBUG_STD(_T("Loading plugin: ") + plugin->getName() + _T("...")); 
    920921    plugin->load_plugin(NSCAPI::dontStart); 
    921     return plugin->commandLineExec(command, argLen, args); 
     922    return plugin->commandLineExec(argLen, args); 
    922923  } catch (NSPluginException e) { 
    923924    LOG_MESSAGE_STD(_T("Module (") + e.file_ + _T(") was not found: ") + e.error_); 
  • trunk/service/NSClient++.h

    r219 r220  
    168168  std::wstring execute(std::wstring password, std::wstring cmd, std::list<std::wstring> args); 
    169169  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, const unsigned int argLen, wchar_t** args); 
     170  int commandLineExec(const wchar_t* module, const unsigned int argLen, wchar_t** args); 
    171171 
    172172  void addPlugins(const std::list<std::wstring> plugins); 
Note: See TracChangeset for help on using the changeset viewer.