Changeset 846bbe4 in nscp


Ignore:
Timestamp:
08/09/08 08:10:41 (5 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
c0522cd
Parents:
da1c7e1
Message:

2008-08-09 MickeM

+ Added ChangeWindowMessageFilter? so systray should not work on vista and beyond!

2008-07-28 MickeM

  • Improved the error handling for the check proc state.
  • Removed all (I think) asserts replacing them with exceptions (should I hope reduce crashes and instead leave some form of errors)
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • AutoBuild.h

    rda1c7e1 r846bbe4  
    33// change the FALSE to TRUE for autoincrement of build number 
    44#define INCREMENT_VERSION TRUE 
    5 #define FILEVER        0,3,3,15 
    6 #define PRODUCTVER     0,3,3,15 
    7 #define STRFILEVER     _T("0.3.3.15") 
    8 #define STRPRODUCTVER  _T("0.3.3.15") 
    9 #define STRPRODUCTDATE  _T("2008-07-02") 
     5#define FILEVER        0,3,3,29 
     6#define PRODUCTVER     0,3,3,29 
     7#define STRFILEVER     _T("0.3.3.29") 
     8#define STRPRODUCTVER  _T("0.3.3.29") 
     9#define STRPRODUCTDATE  _T("2008-07-28") 
    1010#endif // AUTOBUILD_H 
  • NSClient++.cpp

    rdff5db9 r846bbe4  
    247247          LOG_ERROR_STD(_T("Exception raised: ") + e.error_ + _T(" in module: ") + e.file_); 
    248248          //return false; 
     249        } catch (std::exception e) { 
     250          LOG_ERROR_STD(_T("exception loading plugin: ") + (*it) + strEx::string_to_wstring(e.what())); 
     251          return false; 
    249252        } catch (...) { 
    250253          LOG_ERROR_STD(_T("Unknown exception loading plugin: ") + (*it)); 
  • changelog

    rda1c7e1 r846bbe4  
    44 * Add API for rehashing the daemon (or implement it the API is there but does nothing) 
    55 * Improved socket performance (would be nice if we could be used as a "hub") 
    6  * "The message is blocked by User Interface Privilege Isolation, Administrative applications that need to see it can allow it through by calling ChangeWindowMessageFilter after making sure the necessary security precautions are in place. " 
    7  
    8 2008-03-11 MickeM 
    9  ! 0.3.3 Released 
     6 
     72008-08-09 MickeM 
     8 + Added ChangeWindowMessageFilter so systray should not work on vista and beyond! 
     9 
     102008-07-28 MickeM 
     11 * Improved the error handling for the check proc state. 
     12 * Removed all (I think) asserts replacing them with exceptions (should I hope reduce crashes and instead leave some form of errors) 
     13 
     142008-07-25 MickeM 
     15 + Built a garage at the summer house 
     16 * cut down all the reeds and shrubbs at the summer house. 
     17 
     182008-07-03 MickeM 
     19 * Fixed (again) issue with performance data and CheckDriveSize (when using "Min" bounds) 
     20 + Added some more error messages for when counters are not found. 
     21 * Fixed an issue with the new namespace option 
     22 
     232008-07-02 MickeM 
     24 ! 0.3.3 Released (take 2) 
     25 + Added new option alias to controll the name for performance counters when using checkfile use like so: 
     26    checkfile alias=foo file=C:\boot.ini filter-written=>1000d syntax=gurka MaxCrit=1 
     27 * Fixed issue with performance data and CheckDriveSize (when using "Min" bounds) 
     28 ! 0.3.3 Released (take 1) 
     29 * Fixed some issues (?) with the installer the w32 and x64 are now different components (GUIDs). 
    1030 
    11312008-07-02 MickeM 
  • helpers/UploadBinaries/UploadBinaries.vcproj

    r6d3bbc1 r846bbe4  
    321321      <Tool 
    322322        Name="VCCustomBuildTool" 
    323         CommandLine="echo Making archive&#x0D;&#x0A;7z.exe a -r -tzip -bd &quot;$(TargetDir)\NSClient++-$(PlatformName).zip&quot; &quot;$(TargetDir)\*&quot;&#x0D;&#x0A;echo Renaming archive&#x0D;&#x0A;postbuild.pl &quot;$(TargetDir)\NSClient++-$(PlatformName).zip&quot; zip&#x0D;&#x0A;echo Sending to server&#x0D;&#x0A;pscp.exe &quot;$(TargetDir)\*.zip&quot; mickem@ssl.nakednuns.org:/var/www/files/nightly/&#x0D;&#x0A;" 
     323        CommandLine="echo Making archive&#x0D;&#x0A;7z.exe a -r -tzip -bd &quot;$(TargetDir)\NSClient++-$(PlatformName).zip&quot; &quot;$(TargetDir)\*&quot;&#x0D;&#x0A;echo Renaming archive&#x0D;&#x0A;postbuild.pl &quot;$(TargetDir)\NSClient++-$(PlatformName).zip&quot; zip&#x0D;&#x0A;echo Sending to server&#x0D;&#x0A;pscp.exe &quot;$(TargetDir)\*.zip&quot; nscp@druss.medin.name:/var/www/files/nightly/&#x0D;&#x0A;" 
    324324        Outputs="foo" 
    325325      /> 
  • helpers/UploadInstaller/UploadInstaller.vcproj

    r6d3bbc1 r846bbe4  
    9090    </Configuration> 
    9191    <Configuration 
    92       Name="Release|Win32" 
    93       OutputDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)" 
    94       IntermediateDirectory="$(ConfigurationName)" 
    95       ConfigurationType="1" 
    96       CharacterSet="2" 
    97       WholeProgramOptimization="1" 
    98       > 
    99       <Tool 
    100         Name="VCPreBuildEventTool" 
    101       /> 
    102       <Tool 
    103         Name="VCCustomBuildTool" 
    104         CommandLine="echo Renaming archive&#x0D;&#x0A;echo mkdir &quot;$(OutDir)&quot;&#x0D;&#x0A;mkdir &quot;$(OutDir)&quot;&#x0D;&#x0A;cmd /c del &quot;$(OutDir)\*.msi&quot;&quot;&#x0D;&#x0A;cmd /c copy &quot;..\installer\bin\$(ConfigurationName)\NSClient++.msi&quot; &quot;$(OutDir)\NSClient++-$(PlatformName).msi&quot;&quot;&#x0D;&#x0A;postbuild.pl &quot;$(TargetDir)\NSClient++-$(PlatformName).msi&quot; msi&#x0D;&#x0A;echo Sending to server&#x0D;&#x0A;pscp.exe &quot;$(TargetDir)\*.msi&quot; mickem@ssl.nakednuns.org:/var/www/files/nightly/&#x0D;&#x0A;" 
    105         Outputs="foo" 
    106       /> 
    107       <Tool 
    108         Name="VCXMLDataGeneratorTool" 
    109       /> 
    110       <Tool 
    111         Name="VCWebServiceProxyGeneratorTool" 
    112       /> 
    113       <Tool 
    114         Name="VCMIDLTool" 
    115       /> 
    116       <Tool 
    117         Name="VCCLCompilerTool" 
    118         RuntimeLibrary="2" 
    119         WarningLevel="3" 
    120         Detect64BitPortabilityProblems="true" 
    121         DebugInformationFormat="3" 
    122       /> 
    123       <Tool 
    124         Name="VCManagedResourceCompilerTool" 
    125       /> 
    126       <Tool 
    127         Name="VCResourceCompilerTool" 
    128       /> 
    129       <Tool 
    130         Name="VCPreLinkEventTool" 
    131       /> 
    132       <Tool 
    133         Name="VCLinkerTool" 
    134         GenerateDebugInformation="true" 
    135         OptimizeReferences="2" 
    136         EnableCOMDATFolding="2" 
    137         TargetMachine="1" 
    138       /> 
    139       <Tool 
    140         Name="VCALinkTool" 
    141       /> 
    142       <Tool 
    143         Name="VCManifestTool" 
    144       /> 
    145       <Tool 
    146         Name="VCXDCMakeTool" 
    147       /> 
    148       <Tool 
    149         Name="VCBscMakeTool" 
    150       /> 
    151       <Tool 
    152         Name="VCFxCopTool" 
    153       /> 
    154       <Tool 
    155         Name="VCAppVerifierTool" 
    156       /> 
    157       <Tool 
    158         Name="VCWebDeploymentTool" 
    159       /> 
    160       <Tool 
    161         Name="VCPostBuildEventTool" 
    162       /> 
    163     </Configuration> 
    164     <Configuration 
    16592      Name="Debug|x64" 
    16693      OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" 
     
    208135        GenerateDebugInformation="true" 
    209136        TargetMachine="17" 
     137      /> 
     138      <Tool 
     139        Name="VCALinkTool" 
     140      /> 
     141      <Tool 
     142        Name="VCManifestTool" 
     143      /> 
     144      <Tool 
     145        Name="VCXDCMakeTool" 
     146      /> 
     147      <Tool 
     148        Name="VCBscMakeTool" 
     149      /> 
     150      <Tool 
     151        Name="VCFxCopTool" 
     152      /> 
     153      <Tool 
     154        Name="VCAppVerifierTool" 
     155      /> 
     156      <Tool 
     157        Name="VCWebDeploymentTool" 
     158      /> 
     159      <Tool 
     160        Name="VCPostBuildEventTool" 
     161      /> 
     162    </Configuration> 
     163    <Configuration 
     164      Name="Release|Win32" 
     165      OutputDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)" 
     166      IntermediateDirectory="$(ConfigurationName)" 
     167      ConfigurationType="1" 
     168      CharacterSet="2" 
     169      WholeProgramOptimization="1" 
     170      > 
     171      <Tool 
     172        Name="VCPreBuildEventTool" 
     173      /> 
     174      <Tool 
     175        Name="VCCustomBuildTool" 
     176        CommandLine="echo Renaming archive&#x0D;&#x0A;echo mkdir &quot;$(OutDir)&quot;&#x0D;&#x0A;mkdir &quot;$(OutDir)&quot;&#x0D;&#x0A;cmd /c del &quot;$(OutDir)\*.msi&quot;&quot;&#x0D;&#x0A;cmd /c copy &quot;..\installer\bin\$(ConfigurationName)\NSClient++.msi&quot; &quot;$(OutDir)\NSClient++-$(PlatformName).msi&quot;&quot;&#x0D;&#x0A;postbuild.pl &quot;$(TargetDir)\NSClient++-$(PlatformName).msi&quot; msi&#x0D;&#x0A;echo Sending to server&#x0D;&#x0A;pscp.exe &quot;$(TargetDir)\*.msi&quot; nscp@druss.medin.name:/var/www/files/nightly/&#x0D;&#x0A;" 
     177        Outputs="foo" 
     178      /> 
     179      <Tool 
     180        Name="VCXMLDataGeneratorTool" 
     181      /> 
     182      <Tool 
     183        Name="VCWebServiceProxyGeneratorTool" 
     184      /> 
     185      <Tool 
     186        Name="VCMIDLTool" 
     187      /> 
     188      <Tool 
     189        Name="VCCLCompilerTool" 
     190        RuntimeLibrary="2" 
     191        WarningLevel="3" 
     192        Detect64BitPortabilityProblems="true" 
     193        DebugInformationFormat="3" 
     194      /> 
     195      <Tool 
     196        Name="VCManagedResourceCompilerTool" 
     197      /> 
     198      <Tool 
     199        Name="VCResourceCompilerTool" 
     200      /> 
     201      <Tool 
     202        Name="VCPreLinkEventTool" 
     203      /> 
     204      <Tool 
     205        Name="VCLinkerTool" 
     206        GenerateDebugInformation="true" 
     207        OptimizeReferences="2" 
     208        EnableCOMDATFolding="2" 
     209        TargetMachine="1" 
    210210      /> 
    211211      <Tool 
  • include/EnumNtSrv.cpp

    r34e7428 r846bbe4  
    2727static char THIS_FILE[] = __FILE__; 
    2828#endif 
    29  
    30 #define ASSERT(x) 
    3129 
    3230//============================================================================= 
     
    106104std::wstring TNtServiceInfo::GetErrorControl(void) 
    107105{ 
    108   ASSERT(m_dwErrorControl < 4); 
     106  if (m_dwErrorControl >= 4) 
     107    throw std::exception(); 
    109108  TCHAR *types[] = { 
    110109    _T("ERROR_IGNORE"),   // 0 
     
    119118std::wstring TNtServiceInfo::GetCurrentState(void) 
    120119{ 
    121   ASSERT(m_dwCurrentState < 8); 
     120  if (m_dwErrorControl >= 8) 
     121    throw std::exception(); 
    122122  TCHAR *types[] = { 
    123123    _T("UNKNOWN"), 
     
    226226} 
    227227 
    228 /* 
    229 // Enumerate services on this machine and return an STL list of service objects  
    230 // dwType = bit OR of SERVICE_WIN32, SERVICE_DRIVER 
    231 // dwState = bit OR of SERVICE_ACTIVE, SERVICE_INACTIVE 
    232 void TNtServiceInfo::EnumServices(DWORD dwType, DWORD dwState, TNtServiceInfoList *pList) 
    233 { 
    234   ASSERT(pList != NULL); 
    235   TNtServiceInfo *pSrvList = NULL; 
    236   DWORD dwCount = 0; 
    237   pSrvList = TNtServiceInfo::EnumServices(dwType, dwState, &dwCount); 
    238   for (DWORD dwIndex = 0; dwIndex < dwCount; dwIndex ++) { 
    239     pList->insert(pList->end(), pSrvList[dwIndex]); 
    240   } 
    241   delete [] pSrvList; 
    242 } 
    243 */ 
    244228/*############################################################################# 
    245229# End of file ENUMNTSRV.CPP 
  • include/EnumProcess.cpp

    rda1c7e1 r846bbe4  
    313313  } 
    314314  CloseHandle(hProc); 
     315  return TRUE; 
    315316} 
    316317 
  • include/EnumProcess.h

    rb7ed6ac r846bbe4  
    7575    CProcessEntry(const CProcessEntry &e) : dwPID(e.dwPID), fill(e.fill), filename(e.filename), command_line(e.command_line) {} 
    7676    virtual ~CProcessEntry() {} 
    77     bool getCommandLine() const { return fill&fill_command_line!=0; } 
    78     bool getFilename() const { return fill&fill_filename!=0; } 
     77    bool getCommandLine() const { return (fill&fill_command_line)!=0; } 
     78    bool getFilename() const { return (fill&fill_filename)!=0; } 
    7979  }; 
    8080 
  • include/MutexRW.h

    r978bd31 r846bbe4  
    2222 
    2323#include <iostream> 
    24 #include <assert.h> 
    2524 
    2625//#define TRACE(x, y)  
     
    8281    if (dwEvent != WAIT_OBJECT_0) 
    8382      return false; 
    84     //      assert(dwEvent == WAIT_OBJECT_0); 
    8583 
    8684    m_nReaders++; 
     
    9492        return false; 
    9593      } 
    96       //assert(dwEvent == WAIT_OBJECT_0); 
    9794    } 
    9895    // V( semReaders ) 
     
    105102    // P( semReaders ) 
    106103    dwEvent = ::WaitForSingleObject( m_semReaders, INFINITE ); 
    107     assert(dwEvent == WAIT_OBJECT_0); 
     104    if (dwEvent != WAIT_OBJECT_0) 
     105      throw std::exception("Unlock_DataRead::this is really bad..."); 
    108106 
    109107    m_nReaders--; 
     
    126124    if (dwEvent != WAIT_OBJECT_0) 
    127125      return false; 
    128     //assert(dwEvent == WAIT_OBJECT_0); 
    129126    return true; 
    130127  } 
     
    146143    :  m_pMutexRW(pMutexRW), m_bIsLocked(false) 
    147144  { 
    148     assert(m_pMutexRW); 
     145    if (!m_pMutexRW) 
     146      throw std::exception("No mutex in lock: this is really bad..."); 
    149147    if (bInitialLock){ 
    150148      m_bIsLocked = m_pMutexRW->Lock_DataRead(dwMilliseconds); 
     
    157155 
    158156  inline void Lock(DWORD dwMilliseconds = INFINITE){ 
    159     assert(m_bIsLocked == false); 
     157    if (m_bIsLocked) 
     158      throw std::exception("Mutex locked when trying to lock: this is really bad..."); 
    160159    m_bIsLocked = m_pMutexRW->Lock_DataRead(dwMilliseconds); 
    161160  }; 
    162161 
    163162  inline void Unlock(){ 
    164     assert(m_bIsLocked); 
     163    if (!m_bIsLocked) 
     164      throw std::exception("Mutex unlocked when trying to unlock:: this is really bad..."); 
    165165    m_pMutexRW->Unlock_DataRead(); 
    166166    m_bIsLocked = false; 
     
    182182    :  m_pMutexRW(pMutexRW), m_bIsLocked(false) 
    183183  { 
    184     assert(m_pMutexRW); 
     184    if (!m_pMutexRW) 
     185      throw std::exception("No mutex in lock: this is really bad..."); 
    185186    if (bInitialLock){ 
    186187      m_bIsLocked = m_pMutexRW->Lock_DataWrite(dwMilliseconds); 
     
    193194 
    194195  inline void Lock(DWORD dwMilliseconds = INFINITE){ 
    195     assert(m_bIsLocked == false); 
     196    if (m_bIsLocked) 
     197      throw std::exception("already locked...this is really bad..."); 
    196198    m_bIsLocked = m_pMutexRW->Lock_DataWrite(dwMilliseconds); 
    197199  }; 
    198200 
    199201  inline void Unlock(){ 
    200     assert(m_bIsLocked); 
     202    if (!m_bIsLocked) 
     203      throw std::exception("already un-locked...this is really bad..."); 
    201204    m_pMutexRW->Unlock_DataWrite(); 
    202205    m_bIsLocked = false; 
  • include/NSCHelper.cpp

    r796d8ff r846bbe4  
    2121 
    2222#include <NSCHelper.h> 
    23 #include <assert.h> 
    2423#include <msvc_wrappers.h> 
    2524#include <config.h> 
     
    350349    throw NSCMHExcpetion(_T("Settings could not be destroyed.")); 
    351350  } 
    352   assert(aBuffer == NULL); 
     351  if (aBuffer != NULL) 
     352    throw NSCMHExcpetion(_T("buffer is not null?.")); 
    353353  return ret; 
    354354} 
     
    515515    throw NSCMHExcpetion(_T("Commands could not be destroyed.")); 
    516516  } 
    517   assert(aBuffer == NULL); 
     517  if (aBuffer != NULL) 
     518    throw NSCMHExcpetion(_T("buffer is not null?.")); 
    518519  return ret; 
    519520} 
  • include/PDHCounter.h

    r3f69109 r846bbe4  
    2424#include <pdh.h> 
    2525#include <pdhmsg.h> 
    26 #include <assert.h> 
    2726#include <sstream> 
     27#include <error.hpp> 
    2828 
    2929namespace PDH { 
     
    178178 
    179179    PDHCounterInfo getCounterInfo(BOOL bExplainText = FALSE) { 
    180       assert(hCounter_ != NULL); 
     180      if (hCounter_ == NULL) 
     181        throw PDHException(_T("Counter is null!")); 
    181182      PDH_STATUS status; 
    182183      BYTE *lpBuffer = new BYTE[1025]; 
     
    206207        throw PDHException(name_, _T("PdhAddCounter failed"), status); 
    207208      } 
    208       assert(hCounter_ != NULL); 
     209      if (hCounter_ == NULL) 
     210        throw PDHException(_T("Counter is null!")); 
    209211    } 
    210212    void remove() { 
     
    279281 
    280282    void open() { 
    281       assert(hQuery_ == NULL); 
     283      if (hQuery_ != NULL) 
     284        throw PDHException(_T("query is not null!")); 
    282285      PDH_STATUS status; 
    283286      if( (status = PdhOpenQuery( NULL, 0, &hQuery_ )) != ERROR_SUCCESS) 
     
    289292 
    290293    void close() { 
    291       assert(hQuery_ != NULL); 
     294      if (hQuery_ == NULL) 
     295        throw PDHException(_T("query is null!")); 
    292296      PDH_STATUS status; 
    293297      for (CounterList::iterator it = counters_.begin(); it != counters_.end(); it++) { 
     
    444448          error = _T("The specified counter was not found in the performance object."); 
    445449          break; 
     450        case PDH_CSTATUS_NO_OBJECT: 
     451          error = _T("The specified performance object was not found on the computer."); 
     452          break; 
    446453        case PDH_CSTATUS_NO_MACHINE: 
    447454          error = _T("The specified computer could not be found or connected to."); 
     
    453460          error = _T("The function is unable to allocate a required temporary buffer."); 
    454461          break; 
     462        default: 
     463          error = _T("Unknown error: ") + error::lookup::last_error(status); 
     464          break; 
    455465      } 
    456466      return false; 
  • include/SSLSocket.h

    r2f01f93 r846bbe4  
    139139    } 
    140140    void setTmpDH(::DH* dh) { 
    141       assert(ctx_); 
    142       assert(dh); 
     141      if (!ctx_) 
     142        throw SSLException(_T("setTmpDH:: Invalid context")); 
     143      if (!dh) 
     144        throw SSLException(_T("setTmpDH:: Invalid dh")); 
    143145      SSL_CTX_set_tmp_dh(ctx_, dh); 
    144146    } 
     
    282284    } 
    283285    void attach(SOCKET s) { 
    284       assert(s); 
     286      if (!s) 
     287        throw SSLException(_T("attach:: Invalid socket")); 
    285288      try { 
    286289        tBase::attach(s); 
  • include/Socket.h

    rd76af81 r846bbe4  
    202202    } 
    203203    virtual void attach(SOCKET s) { 
    204       assert(socket_ == NULL); 
     204      if (socket_ != NULL) 
     205        throw SocketException(_T("Cant attach to existing socket!")); 
    205206      socket_ = s; 
    206207    } 
     
    314315    virtual bool sendAll(const char * buffer, unsigned int len); 
    315316 
    316     int inline sendAll(DataBuffer &buffer) { 
     317    bool inline sendAll(DataBuffer &buffer) { 
    317318      return sendAll(buffer.getBuffer(), buffer.getLength()); 
    318319    } 
    319320 
    320321    virtual int send(const char * buf, unsigned int len, int flags = 0) { 
    321       assert(socket_); 
     322      if (!socket_) 
     323        throw SocketException(_T("send:: cant send to uninitialized socket")); 
    322324      return ::send(socket_, buf, len, flags); 
    323325    } 
     
    328330    virtual void socket(int af, int type, int protocol ) { 
    329331      socket_ = ::socket(af, type, protocol); 
    330       assert(socket_ != INVALID_SOCKET); 
     332      if (socket_ == INVALID_SOCKET) 
     333        throw SocketException(_T("Failed to create socket"), WSAGetLastError()); 
    331334    } 
    332335    virtual void bind() { 
    333       assert(socket_); 
     336      if (!socket_) 
     337        throw SocketException(_T("bind:: Invalid socket")); 
    334338      int fromlen=sizeof(from_); 
    335339      if (::bind(socket_, (sockaddr*)&from_, fromlen) == SOCKET_ERROR) 
     
    337341    } 
    338342    virtual void listen(int backlog = SOMAXCONN) { 
    339       assert(socket_); 
     343      if (!socket_) 
     344        throw SocketException(_T("listen:: Invalid socket")); 
    340345      if (::listen(socket_, backlog) == SOCKET_ERROR) 
    341346        throw SocketException(_T("listen failed: "), ::WSAGetLastError()); 
     
    359364    } 
    360365    virtual void ioctlsocket(long cmd, u_long *argp) { 
    361       assert(socket_); 
     366      if (!socket_) 
     367        throw SocketException(_T("ioctlsocket:: Invalid socket")); 
    362368      if (::ioctlsocket(socket_, cmd, argp) == SOCKET_ERROR) 
    363369        throw SocketException(_T("ioctlsocket failed: "), ::WSAGetLastError()); 
     
    440446      } 
    441447      void exitThread(void) { 
    442         assert(hStopEvent_ != NULL); 
     448        if (hStopEvent_ == NULL) 
     449          throw SocketException(_T("exitThread:: no stop event??")); 
    443450        if (!SetEvent(hStopEvent_)) 
    444451          throw SocketException(_T("SetEvent failed.")); 
  • include/arrayBuffer.cpp

    ra720da5 r846bbe4  
    5656    wcsncpy_s(arrayBuffer[i], alen+2, (*it).c_str(), alen+1); 
    5757  } 
    58   assert(i == argLen); 
     58  if (i != argLen) 
     59    throw ArrayBufferException(_T("Invalid length!")); 
    5960  return arrayBuffer; 
    6061} 
     
    107108*/ 
    108109arrayBuffer::arrayBuffer arrayBuffer::split2arrayBuffer(const TCHAR* buffer, TCHAR splitChar, unsigned int &argLen) { 
    109   assert(buffer); 
     110  if (!buffer) 
     111    throw ArrayBufferException(_T("Invalid buffer specified!")); 
    110112  argLen = 0; 
    111113  const TCHAR *p = buffer; 
     
    135137void arrayBuffer::set(arrayBuffer arrayBuffer, const unsigned int argLen, const unsigned int position, std::wstring argument) { 
    136138  if (position >= argLen) 
    137     assert(false); 
     139    throw ArrayBufferException(_T("position is outside the buffer")); 
    138140  delete [] arrayBuffer[position]; 
    139141  size_t len = argument.length(); 
     
    176178    //std::wcout << _T("found token: ") << p1 << _T(":") << p2; 
    177179 
    178     assert(p2>p1); 
     180    if (p2<=p1) 
     181      throw ArrayBufferException(_T("Invalid position")); 
    179182    std::wstring token = inBuf.substr(p1,p2-p1); 
    180183    if (escape && token[0] == '\"') 
     
    244247      p = inBuf.size(); 
    245248    //    TCHAR *q = strchr(p, (i<argLen-1)?splitChar:0); 
    246     assert(p>l); 
    247249    unsigned int len = static_cast<unsigned int>(p-l); 
    248250    arrayBuffer[i] = new TCHAR[len+1]; 
  • include/arrayBuffer.h

    r47b843a r846bbe4  
    2424#include <string> 
    2525#include <list> 
    26 #include <assert.h> 
    2726#include <iostream> 
    2827/** 
     
    5150 */ 
    5251namespace arrayBuffer { 
     52  class ArrayBufferException { 
     53  public: 
     54    ArrayBufferException(std::wstring error) {} 
     55  }; 
    5356  typedef TCHAR* arrayBufferItem; 
    5457  typedef arrayBufferItem* arrayBuffer; 
  • include/charEx.h

    r978bd31 r846bbe4  
    2020***************************************************************************/ 
    2121#pragma once 
    22 #include <assert.h> 
    2322#include <windows.h> 
    2423#include <tchar.h> 
     
    4746 
    4847  inline char* tchar_to_char( const wchar_t* pStr, int len, int &nChars) { 
    49     assert(pStr != NULL); 
    50     assert(len >= 0 || len == -1); 
     48    if (pStr == NULL) 
     49      throw std::exception(); 
     50    if (len < -1) 
     51      throw std::exception(); 
    5152 
    5253    // figure out how many narrow characters we are going to get  
     
    6768 
    6869  inline wchar_t* char_to_tchar(const char* pStr, int len, int &nChars) { 
    69     assert( pStr != NULL); 
    70     assert( len >= 0 || len == -1); 
     70    if (pStr == NULL) 
     71      throw std::exception(); 
     72    if (len < -1) 
     73      throw std::exception(); 
    7174 
    7275    // figure out how many wide characters we are going to get 
     
    9093  typedef std::pair<std::wstring,TCHAR*> token; 
    9194  inline token getToken(TCHAR *buffer, TCHAR split) { 
    92     assert(buffer != NULL); 
     95    if (buffer == NULL) 
     96      throw std::exception(); 
    9397    TCHAR *p = wcschr(buffer, split); 
    9498    if (!p) 
  • include/checkHelpers.hpp

    re380ffe r846bbe4  
    510510            MAKE_PERFDATA(alias, THandler::print_unformated(value.getLowerPercentage()), _T("%"),  
    511511            THandler::print_unformated(warn), THandler::print_unformated(crit)); 
     512      } else if (type_ == value_upper) { 
     513        std::wstring unit = THandler::get_perf_unit(min(warn, min(crit, value.value))); 
     514        return  
     515          MAKE_PERFDATA(alias, THandler::print_perf((value.value), unit), unit,  
     516          THandler::print_perf(value.total-warn, unit), THandler::print_perf(value.total-crit, unit)); 
    512517      } else { 
    513518        std::wstring unit = THandler::get_perf_unit(min(warn, min(crit, value.value))); 
  • include/strEx.h

    r367bf20 r846bbe4  
    3535 
    3636namespace strEx { 
     37  class string_exception : public std::exception { 
     38    std::wstring _what; 
     39    string_exception(std::wstring what) : _what(what) {} 
     40    std::wstring what() { 
     41      return _what; 
     42    } 
     43  }; 
    3744  namespace s { 
    3845    inline std::string itos(float i) { 
     
    6067 
    6168  inline std::string wstring_to_string( const wchar_t* pStr, int len) { 
    62     //ASSERT_PTR( pStr ) ;  
    63     //ASSERT( len >= 0 || len == -1 , _T("Invalid string length: ") << len ) ;  
     69    if (pStr == NULL) 
     70      throw string_exception("Invalid pointer in wstring_to_string"); 
     71    if (len < 0 && len != -1)  
     72      throw string_exception("Invalid string length in wstring_to_string"); 
    6473 
    6574    // figure out how many narrow characters we are going to get  
     
    8493 
    8594  inline std::wstring string_to_wstring( const char* pStr , int len ) { 
    86     //ASSERT_PTR( pStr ) ;  
    87     //ASSERT( len >= 0 || len == -1 , _T("Invalid string length: ") << len ) ;  
     95    if (pStr == NULL) 
     96      throw string_exception("Invalid pointer in wstring_to_string"); 
     97    if (len < 0 && len != -1)  
     98      throw string_exception("Invalid string length in wstring_to_string"); 
    8899 
    89100    // figure out how many wide characters we are going to get  
  • modules/CheckSystem/CheckSystem.cpp

    r34e7428 r846bbe4  
    861861  try { 
    862862    runningProcs = GetProcessList(processMethod_, useCmdLine); 
    863   } catch (TCHAR *c) { 
    864     NSC_LOG_ERROR_STD(_T("ERROR: ") + c); 
    865     msg = static_cast<std::wstring>(_T("ERROR: ")) + c; 
     863  } catch (CEnumProcess::EnumProcException e) { 
     864    NSC_LOG_ERROR_STD(_T("ERROR: ") + e.getMessage()); 
     865    msg = static_cast<std::wstring>(_T("ERROR: ")) + e.getMessage(); 
     866    return NSCAPI::returnUNKNOWN; 
     867  } catch (...) { 
     868    NSC_LOG_ERROR_STD(_T("Unhandled error when processing command")); 
     869    msg = _T("Unhandled error when processing command"); 
    866870    return NSCAPI::returnUNKNOWN; 
    867871  } 
     
    894898        return NSCAPI::returnUNKNOWN; 
    895899      } 
     900#else 
     901      NSC_LOG_ERROR_STD(_T("NSClient++ is compiled with NO_BOOST_DEP so no regular expression support for you...") + (*proc).first); 
     902      msg = _T("Regular expression is not supported: ") + (*proc).first; 
     903      return NSCAPI::returnUNKNOWN; 
    896904#endif 
    897905    } else { 
     
    9951003      std::wstring tstr; 
    9961004      if (!PDH::Enumerations::validate(counter.data, tstr)) { 
    997         msg = tstr; 
    998         msg += _T(" (") + counter.getAlias() + _T("|") + counter.data + _T(")"); 
    999         return NSCHelper::translateReturn(invalidStatus); 
     1005        NSC_LOG_ERROR_STD(_T("ERROR: Counter not found: ") + counter.data + _T(": ") + tstr); 
     1006        if (bNSClient) { 
     1007          NSC_LOG_ERROR_STD(_T("ERROR: Counter not found: ") + counter.data + _T(": ") + tstr); 
     1008          //msg = _T("0"); 
     1009        } else { 
     1010          //msg = tstr; 
     1011          //msg += _T(" (") + counter.getAlias() + _T("|") + counter.data + _T(")"); 
     1012        } 
     1013        //return NSCHelper::translateReturn(invalidStatus); 
    10001014      } 
    10011015      PDH::PDHQuery pdh; 
     
    10111025      double value = cDouble.getValue(); 
    10121026      if (bNSClient) { 
     1027        if (!msg.empty()) 
     1028          msg += _T(","); 
    10131029        msg += strEx::itos(static_cast<float>(value)); 
    10141030      } else { 
     
    10191035    } catch (const PDH::PDHException e) { 
    10201036      NSC_LOG_ERROR_STD(_T("ERROR: ") + e.getError() + _T(" (") + counter.getAlias() + _T("|") + counter.data + _T(")")); 
    1021       msg = static_cast<std::wstring>(_T("ERROR: ")) + e.getError()+ _T(" (") + counter.getAlias() + _T("|") + counter.data + _T(")"); 
     1037      if (bNSClient) 
     1038        msg = _T("0"); 
     1039      else 
     1040        msg = static_cast<std::wstring>(_T("ERROR: ")) + e.getError()+ _T(" (") + counter.getAlias() + _T("|") + counter.data + _T(")"); 
    10221041      return NSCAPI::returnUNKNOWN; 
    10231042    } 
    10241043  } 
    10251044 
    1026   if (msg.empty()) 
     1045  if (msg.empty() && !bNSClient) 
    10271046    msg = _T("OK all counters within bounds."); 
    1028   else if (!bNSClient) 
     1047  else if (msg.empty()) { 
     1048    NSC_LOG_ERROR_STD(_T("No value found returning 0?")); 
     1049    msg = _T("0"); 
     1050  }else if (!bNSClient) 
    10291051    msg = NSCHelper::translateReturn(returnCode) + _T(": ") + msg; 
    10301052  return returnCode; 
  • modules/CheckWMI/CheckWMI.cpp

    r34e7428 r846bbe4  
    100100    MAP_OPTIONS_STR(_T("Query"), query) 
    101101    MAP_OPTIONS_STR2INT(_T("truncate"), truncate) 
    102     MAP_OPTIONS_STR2INT(_T("namespace"), ns) 
     102    MAP_OPTIONS_STR(_T("namespace"), ns) 
    103103    MAP_OPTIONS_STR(_T("Alias"), alias) 
    104104    MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) 
     
    174174      MAP_OPTIONS_SHOWALL(tmpObject) 
    175175      MAP_OPTIONS_NUMERIC_ALL(tmpObject, _T("")) 
    176       MAP_OPTIONS_STR2INT(_T("namespace"), ns) 
     176      MAP_OPTIONS_STR(_T("namespace"), ns) 
    177177      MAP_OPTIONS_STR(_T("Alias"), tmpObject.data) 
    178178      MAP_OPTIONS_STR(_T("AliasCol"), aliasCol) 
  • modules/NRPEListener/NRPEListener.cpp

    r5fda37e r846bbe4  
    255255    return NSCAPI::critical; 
    256256  } 
    257  
     257  return NSCAPI::returnIgnored; 
    258258} 
    259259 
  • modules/NSCAAgent/nsca_enrypt.hpp

    r394f7a1 r846bbe4  
    9191    void init(std::string password, unsigned char *transmitted_iv, int iv_size) { 
    9292      /* generate an encryption/description key using the password */ 
    93       int keysize=get_keySize(); 
     93      unsigned int keysize=get_keySize(); 
    9494 
    9595      unsigned char *key = new unsigned char[keysize+1]; 
  • modules/SysTray/SysTray.cpp

    r7f596ce r846bbe4  
    106106      hWnd = hLogWnd; 
    107107    } else { 
    108       std::cout << "Damnit!!!" << std::endl; 
    109108      NSC_LOG_ERROR_STD(_T("Failed to get mutex in logger, message discarded")); 
    110109    } 
  • modules/SysTray/TrayIcon.cpp

    r6d3bbc1 r846bbe4  
    3939} 
    4040 
     41#ifdef WINVER < 0x0600 
     42#define MSGFLT_ADD 1 
     43#define MSGFLT_REMOVE 2 
     44typedef BOOL (WINAPI *LPFN_CHANGEWINDOWMESSAGEFILTER) (UINT, DWORD); 
     45#endif 
     46 
     47LPFN_CHANGEWINDOWMESSAGEFILTER fnChangeWindowMessageFilter = NULL; 
     48BOOL ChangeWindowMessageFilter(UINT message, DWORD what) 
     49{ 
     50  if (fnChangeWindowMessageFilter == NULL) 
     51    fnChangeWindowMessageFilter = (LPFN_CHANGEWINDOWMESSAGEFILTER)GetProcAddress(GetModuleHandle(TEXT("user32")),"ChangeWindowMessageFilter"); 
     52  if (fnChangeWindowMessageFilter == NULL) 
     53    return true; 
     54  return fnChangeWindowMessageFilter(message,what); 
     55} 
     56 
    4157 
    4258void IconWidget_::createDialog(void) { 
     59  ChangeWindowMessageFilter() 
    4360  hDlgWnd = ::CreateDialog(NSCModuleWrapper::getModule(),MAKEINTRESOURCE(IDD_NSTRAYDLG),NULL,TrayIcon::DialogProc); 
    4461 
     
    4764    NSC_LOG_ERROR_STD(_T("Failed to register 'TaskbarCreated': ") + error::lookup::last_error()); 
    4865  } 
     66  ChangeWindowMessageFilter(UDM_TASKBARCREATED, MSGFLT_ADD); 
    4967 
    5068  MSG Msg; 
Note: See TracChangeset for help on using the changeset viewer.