Changeset 846bbe4 in nscp
- Timestamp:
- 08/09/08 08:10:41 (5 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- c0522cd
- Parents:
- da1c7e1
- Files:
-
- 24 edited
-
AutoBuild.h (modified) (1 diff)
-
NSClient++.cpp (modified) (1 diff)
-
changelog (modified) (1 diff)
-
helpers/UploadBinaries/UploadBinaries.vcproj (modified) (1 diff)
-
helpers/UploadInstaller/UploadInstaller.vcproj (modified) (2 diffs)
-
include/EnumNtSrv.cpp (modified) (4 diffs)
-
include/EnumProcess.cpp (modified) (1 diff)
-
include/EnumProcess.h (modified) (1 diff)
-
include/MutexRW.h (modified) (9 diffs)
-
include/NSCHelper.cpp (modified) (3 diffs)
-
include/PDHCounter.h (modified) (7 diffs)
-
include/SSLSocket.h (modified) (2 diffs)
-
include/Socket.h (modified) (6 diffs)
-
include/arrayBuffer.cpp (modified) (5 diffs)
-
include/arrayBuffer.h (modified) (2 diffs)
-
include/charEx.h (modified) (4 diffs)
-
include/checkHelpers.hpp (modified) (1 diff)
-
include/strEx.h (modified) (3 diffs)
-
modules/CheckSystem/CheckSystem.cpp (modified) (5 diffs)
-
modules/CheckWMI/CheckWMI.cpp (modified) (2 diffs)
-
modules/NRPEListener/NRPEListener.cpp (modified) (1 diff)
-
modules/NSCAAgent/nsca_enrypt.hpp (modified) (1 diff)
-
modules/SysTray/SysTray.cpp (modified) (1 diff)
-
modules/SysTray/TrayIcon.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
AutoBuild.h
rda1c7e1 r846bbe4 3 3 // change the FALSE to TRUE for autoincrement of build number 4 4 #define INCREMENT_VERSION TRUE 5 #define FILEVER 0,3,3, 156 #define PRODUCTVER 0,3,3, 157 #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") 10 10 #endif // AUTOBUILD_H -
NSClient++.cpp
rdff5db9 r846bbe4 247 247 LOG_ERROR_STD(_T("Exception raised: ") + e.error_ + _T(" in module: ") + e.file_); 248 248 //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; 249 252 } catch (...) { 250 253 LOG_ERROR_STD(_T("Unknown exception loading plugin: ") + (*it)); -
changelog
rda1c7e1 r846bbe4 4 4 * Add API for rehashing the daemon (or implement it the API is there but does nothing) 5 5 * 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 7 2008-08-09 MickeM 8 + Added ChangeWindowMessageFilter so systray should not work on vista and beyond! 9 10 2008-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 14 2008-07-25 MickeM 15 + Built a garage at the summer house 16 * cut down all the reeds and shrubbs at the summer house. 17 18 2008-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 23 2008-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). 10 30 11 31 2008-07-02 MickeM -
helpers/UploadBinaries/UploadBinaries.vcproj
r6d3bbc1 r846bbe4 321 321 <Tool 322 322 Name="VCCustomBuildTool" 323 CommandLine="echo Making archive
7z.exe a -r -tzip -bd "$(TargetDir)\NSClient++-$(PlatformName).zip" "$(TargetDir)\*"
echo Renaming archive
postbuild.pl "$(TargetDir)\NSClient++-$(PlatformName).zip" zip
echo Sending to server
pscp.exe "$(TargetDir)\*.zip" mickem@ssl.nakednuns.org:/var/www/files/nightly/
"323 CommandLine="echo Making archive
7z.exe a -r -tzip -bd "$(TargetDir)\NSClient++-$(PlatformName).zip" "$(TargetDir)\*"
echo Renaming archive
postbuild.pl "$(TargetDir)\NSClient++-$(PlatformName).zip" zip
echo Sending to server
pscp.exe "$(TargetDir)\*.zip" nscp@druss.medin.name:/var/www/files/nightly/
" 324 324 Outputs="foo" 325 325 /> -
helpers/UploadInstaller/UploadInstaller.vcproj
r6d3bbc1 r846bbe4 90 90 </Configuration> 91 91 <Configuration 92 Name="Release|Win32"93 OutputDirectory="$(ProjectDir)$(PlatformName)\$(ConfigurationName)"94 IntermediateDirectory="$(ConfigurationName)"95 ConfigurationType="1"96 CharacterSet="2"97 WholeProgramOptimization="1"98 >99 <Tool100 Name="VCPreBuildEventTool"101 />102 <Tool103 Name="VCCustomBuildTool"104 CommandLine="echo Renaming archive
echo mkdir "$(OutDir)"
mkdir "$(OutDir)"
cmd /c del "$(OutDir)\*.msi""
cmd /c copy "..\installer\bin\$(ConfigurationName)\NSClient++.msi" "$(OutDir)\NSClient++-$(PlatformName).msi""
postbuild.pl "$(TargetDir)\NSClient++-$(PlatformName).msi" msi
echo Sending to server
pscp.exe "$(TargetDir)\*.msi" mickem@ssl.nakednuns.org:/var/www/files/nightly/
"105 Outputs="foo"106 />107 <Tool108 Name="VCXMLDataGeneratorTool"109 />110 <Tool111 Name="VCWebServiceProxyGeneratorTool"112 />113 <Tool114 Name="VCMIDLTool"115 />116 <Tool117 Name="VCCLCompilerTool"118 RuntimeLibrary="2"119 WarningLevel="3"120 Detect64BitPortabilityProblems="true"121 DebugInformationFormat="3"122 />123 <Tool124 Name="VCManagedResourceCompilerTool"125 />126 <Tool127 Name="VCResourceCompilerTool"128 />129 <Tool130 Name="VCPreLinkEventTool"131 />132 <Tool133 Name="VCLinkerTool"134 GenerateDebugInformation="true"135 OptimizeReferences="2"136 EnableCOMDATFolding="2"137 TargetMachine="1"138 />139 <Tool140 Name="VCALinkTool"141 />142 <Tool143 Name="VCManifestTool"144 />145 <Tool146 Name="VCXDCMakeTool"147 />148 <Tool149 Name="VCBscMakeTool"150 />151 <Tool152 Name="VCFxCopTool"153 />154 <Tool155 Name="VCAppVerifierTool"156 />157 <Tool158 Name="VCWebDeploymentTool"159 />160 <Tool161 Name="VCPostBuildEventTool"162 />163 </Configuration>164 <Configuration165 92 Name="Debug|x64" 166 93 OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" … … 208 135 GenerateDebugInformation="true" 209 136 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
echo mkdir "$(OutDir)"
mkdir "$(OutDir)"
cmd /c del "$(OutDir)\*.msi""
cmd /c copy "..\installer\bin\$(ConfigurationName)\NSClient++.msi" "$(OutDir)\NSClient++-$(PlatformName).msi""
postbuild.pl "$(TargetDir)\NSClient++-$(PlatformName).msi" msi
echo Sending to server
pscp.exe "$(TargetDir)\*.msi" nscp@druss.medin.name:/var/www/files/nightly/
" 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" 210 210 /> 211 211 <Tool -
include/EnumNtSrv.cpp
r34e7428 r846bbe4 27 27 static char THIS_FILE[] = __FILE__; 28 28 #endif 29 30 #define ASSERT(x)31 29 32 30 //============================================================================= … … 106 104 std::wstring TNtServiceInfo::GetErrorControl(void) 107 105 { 108 ASSERT(m_dwErrorControl < 4); 106 if (m_dwErrorControl >= 4) 107 throw std::exception(); 109 108 TCHAR *types[] = { 110 109 _T("ERROR_IGNORE"), // 0 … … 119 118 std::wstring TNtServiceInfo::GetCurrentState(void) 120 119 { 121 ASSERT(m_dwCurrentState < 8); 120 if (m_dwErrorControl >= 8) 121 throw std::exception(); 122 122 TCHAR *types[] = { 123 123 _T("UNKNOWN"), … … 226 226 } 227 227 228 /*229 // Enumerate services on this machine and return an STL list of service objects230 // dwType = bit OR of SERVICE_WIN32, SERVICE_DRIVER231 // dwState = bit OR of SERVICE_ACTIVE, SERVICE_INACTIVE232 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 */244 228 /*############################################################################# 245 229 # End of file ENUMNTSRV.CPP -
include/EnumProcess.cpp
rda1c7e1 r846bbe4 313 313 } 314 314 CloseHandle(hProc); 315 return TRUE; 315 316 } 316 317 -
include/EnumProcess.h
rb7ed6ac r846bbe4 75 75 CProcessEntry(const CProcessEntry &e) : dwPID(e.dwPID), fill(e.fill), filename(e.filename), command_line(e.command_line) {} 76 76 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; } 79 79 }; 80 80 -
include/MutexRW.h
r978bd31 r846bbe4 22 22 23 23 #include <iostream> 24 #include <assert.h>25 24 26 25 //#define TRACE(x, y) … … 82 81 if (dwEvent != WAIT_OBJECT_0) 83 82 return false; 84 // assert(dwEvent == WAIT_OBJECT_0);85 83 86 84 m_nReaders++; … … 94 92 return false; 95 93 } 96 //assert(dwEvent == WAIT_OBJECT_0);97 94 } 98 95 // V( semReaders ) … … 105 102 // P( semReaders ) 106 103 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..."); 108 106 109 107 m_nReaders--; … … 126 124 if (dwEvent != WAIT_OBJECT_0) 127 125 return false; 128 //assert(dwEvent == WAIT_OBJECT_0);129 126 return true; 130 127 } … … 146 143 : m_pMutexRW(pMutexRW), m_bIsLocked(false) 147 144 { 148 assert(m_pMutexRW); 145 if (!m_pMutexRW) 146 throw std::exception("No mutex in lock: this is really bad..."); 149 147 if (bInitialLock){ 150 148 m_bIsLocked = m_pMutexRW->Lock_DataRead(dwMilliseconds); … … 157 155 158 156 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..."); 160 159 m_bIsLocked = m_pMutexRW->Lock_DataRead(dwMilliseconds); 161 160 }; 162 161 163 162 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..."); 165 165 m_pMutexRW->Unlock_DataRead(); 166 166 m_bIsLocked = false; … … 182 182 : m_pMutexRW(pMutexRW), m_bIsLocked(false) 183 183 { 184 assert(m_pMutexRW); 184 if (!m_pMutexRW) 185 throw std::exception("No mutex in lock: this is really bad..."); 185 186 if (bInitialLock){ 186 187 m_bIsLocked = m_pMutexRW->Lock_DataWrite(dwMilliseconds); … … 193 194 194 195 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..."); 196 198 m_bIsLocked = m_pMutexRW->Lock_DataWrite(dwMilliseconds); 197 199 }; 198 200 199 201 inline void Unlock(){ 200 assert(m_bIsLocked); 202 if (!m_bIsLocked) 203 throw std::exception("already un-locked...this is really bad..."); 201 204 m_pMutexRW->Unlock_DataWrite(); 202 205 m_bIsLocked = false; -
include/NSCHelper.cpp
r796d8ff r846bbe4 21 21 22 22 #include <NSCHelper.h> 23 #include <assert.h>24 23 #include <msvc_wrappers.h> 25 24 #include <config.h> … … 350 349 throw NSCMHExcpetion(_T("Settings could not be destroyed.")); 351 350 } 352 assert(aBuffer == NULL); 351 if (aBuffer != NULL) 352 throw NSCMHExcpetion(_T("buffer is not null?.")); 353 353 return ret; 354 354 } … … 515 515 throw NSCMHExcpetion(_T("Commands could not be destroyed.")); 516 516 } 517 assert(aBuffer == NULL); 517 if (aBuffer != NULL) 518 throw NSCMHExcpetion(_T("buffer is not null?.")); 518 519 return ret; 519 520 } -
include/PDHCounter.h
r3f69109 r846bbe4 24 24 #include <pdh.h> 25 25 #include <pdhmsg.h> 26 #include <assert.h>27 26 #include <sstream> 27 #include <error.hpp> 28 28 29 29 namespace PDH { … … 178 178 179 179 PDHCounterInfo getCounterInfo(BOOL bExplainText = FALSE) { 180 assert(hCounter_ != NULL); 180 if (hCounter_ == NULL) 181 throw PDHException(_T("Counter is null!")); 181 182 PDH_STATUS status; 182 183 BYTE *lpBuffer = new BYTE[1025]; … … 206 207 throw PDHException(name_, _T("PdhAddCounter failed"), status); 207 208 } 208 assert(hCounter_ != NULL); 209 if (hCounter_ == NULL) 210 throw PDHException(_T("Counter is null!")); 209 211 } 210 212 void remove() { … … 279 281 280 282 void open() { 281 assert(hQuery_ == NULL); 283 if (hQuery_ != NULL) 284 throw PDHException(_T("query is not null!")); 282 285 PDH_STATUS status; 283 286 if( (status = PdhOpenQuery( NULL, 0, &hQuery_ )) != ERROR_SUCCESS) … … 289 292 290 293 void close() { 291 assert(hQuery_ != NULL); 294 if (hQuery_ == NULL) 295 throw PDHException(_T("query is null!")); 292 296 PDH_STATUS status; 293 297 for (CounterList::iterator it = counters_.begin(); it != counters_.end(); it++) { … … 444 448 error = _T("The specified counter was not found in the performance object."); 445 449 break; 450 case PDH_CSTATUS_NO_OBJECT: 451 error = _T("The specified performance object was not found on the computer."); 452 break; 446 453 case PDH_CSTATUS_NO_MACHINE: 447 454 error = _T("The specified computer could not be found or connected to."); … … 453 460 error = _T("The function is unable to allocate a required temporary buffer."); 454 461 break; 462 default: 463 error = _T("Unknown error: ") + error::lookup::last_error(status); 464 break; 455 465 } 456 466 return false; -
include/SSLSocket.h
r2f01f93 r846bbe4 139 139 } 140 140 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")); 143 145 SSL_CTX_set_tmp_dh(ctx_, dh); 144 146 } … … 282 284 } 283 285 void attach(SOCKET s) { 284 assert(s); 286 if (!s) 287 throw SSLException(_T("attach:: Invalid socket")); 285 288 try { 286 289 tBase::attach(s); -
include/Socket.h
rd76af81 r846bbe4 202 202 } 203 203 virtual void attach(SOCKET s) { 204 assert(socket_ == NULL); 204 if (socket_ != NULL) 205 throw SocketException(_T("Cant attach to existing socket!")); 205 206 socket_ = s; 206 207 } … … 314 315 virtual bool sendAll(const char * buffer, unsigned int len); 315 316 316 intinline sendAll(DataBuffer &buffer) {317 bool inline sendAll(DataBuffer &buffer) { 317 318 return sendAll(buffer.getBuffer(), buffer.getLength()); 318 319 } 319 320 320 321 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")); 322 324 return ::send(socket_, buf, len, flags); 323 325 } … … 328 330 virtual void socket(int af, int type, int protocol ) { 329 331 socket_ = ::socket(af, type, protocol); 330 assert(socket_ != INVALID_SOCKET); 332 if (socket_ == INVALID_SOCKET) 333 throw SocketException(_T("Failed to create socket"), WSAGetLastError()); 331 334 } 332 335 virtual void bind() { 333 assert(socket_); 336 if (!socket_) 337 throw SocketException(_T("bind:: Invalid socket")); 334 338 int fromlen=sizeof(from_); 335 339 if (::bind(socket_, (sockaddr*)&from_, fromlen) == SOCKET_ERROR) … … 337 341 } 338 342 virtual void listen(int backlog = SOMAXCONN) { 339 assert(socket_); 343 if (!socket_) 344 throw SocketException(_T("listen:: Invalid socket")); 340 345 if (::listen(socket_, backlog) == SOCKET_ERROR) 341 346 throw SocketException(_T("listen failed: "), ::WSAGetLastError()); … … 359 364 } 360 365 virtual void ioctlsocket(long cmd, u_long *argp) { 361 assert(socket_); 366 if (!socket_) 367 throw SocketException(_T("ioctlsocket:: Invalid socket")); 362 368 if (::ioctlsocket(socket_, cmd, argp) == SOCKET_ERROR) 363 369 throw SocketException(_T("ioctlsocket failed: "), ::WSAGetLastError()); … … 440 446 } 441 447 void exitThread(void) { 442 assert(hStopEvent_ != NULL); 448 if (hStopEvent_ == NULL) 449 throw SocketException(_T("exitThread:: no stop event??")); 443 450 if (!SetEvent(hStopEvent_)) 444 451 throw SocketException(_T("SetEvent failed.")); -
include/arrayBuffer.cpp
ra720da5 r846bbe4 56 56 wcsncpy_s(arrayBuffer[i], alen+2, (*it).c_str(), alen+1); 57 57 } 58 assert(i == argLen); 58 if (i != argLen) 59 throw ArrayBufferException(_T("Invalid length!")); 59 60 return arrayBuffer; 60 61 } … … 107 108 */ 108 109 arrayBuffer::arrayBuffer arrayBuffer::split2arrayBuffer(const TCHAR* buffer, TCHAR splitChar, unsigned int &argLen) { 109 assert(buffer); 110 if (!buffer) 111 throw ArrayBufferException(_T("Invalid buffer specified!")); 110 112 argLen = 0; 111 113 const TCHAR *p = buffer; … … 135 137 void arrayBuffer::set(arrayBuffer arrayBuffer, const unsigned int argLen, const unsigned int position, std::wstring argument) { 136 138 if (position >= argLen) 137 assert(false);139 throw ArrayBufferException(_T("position is outside the buffer")); 138 140 delete [] arrayBuffer[position]; 139 141 size_t len = argument.length(); … … 176 178 //std::wcout << _T("found token: ") << p1 << _T(":") << p2; 177 179 178 assert(p2>p1); 180 if (p2<=p1) 181 throw ArrayBufferException(_T("Invalid position")); 179 182 std::wstring token = inBuf.substr(p1,p2-p1); 180 183 if (escape && token[0] == '\"') … … 244 247 p = inBuf.size(); 245 248 // TCHAR *q = strchr(p, (i<argLen-1)?splitChar:0); 246 assert(p>l);247 249 unsigned int len = static_cast<unsigned int>(p-l); 248 250 arrayBuffer[i] = new TCHAR[len+1]; -
include/arrayBuffer.h
r47b843a r846bbe4 24 24 #include <string> 25 25 #include <list> 26 #include <assert.h>27 26 #include <iostream> 28 27 /** … … 51 50 */ 52 51 namespace arrayBuffer { 52 class ArrayBufferException { 53 public: 54 ArrayBufferException(std::wstring error) {} 55 }; 53 56 typedef TCHAR* arrayBufferItem; 54 57 typedef arrayBufferItem* arrayBuffer; -
include/charEx.h
r978bd31 r846bbe4 20 20 ***************************************************************************/ 21 21 #pragma once 22 #include <assert.h>23 22 #include <windows.h> 24 23 #include <tchar.h> … … 47 46 48 47 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(); 51 52 52 53 // figure out how many narrow characters we are going to get … … 67 68 68 69 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(); 71 74 72 75 // figure out how many wide characters we are going to get … … 90 93 typedef std::pair<std::wstring,TCHAR*> token; 91 94 inline token getToken(TCHAR *buffer, TCHAR split) { 92 assert(buffer != NULL); 95 if (buffer == NULL) 96 throw std::exception(); 93 97 TCHAR *p = wcschr(buffer, split); 94 98 if (!p) -
include/checkHelpers.hpp
re380ffe r846bbe4 510 510 MAKE_PERFDATA(alias, THandler::print_unformated(value.getLowerPercentage()), _T("%"), 511 511 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)); 512 517 } else { 513 518 std::wstring unit = THandler::get_perf_unit(min(warn, min(crit, value.value))); -
include/strEx.h
r367bf20 r846bbe4 35 35 36 36 namespace 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 }; 37 44 namespace s { 38 45 inline std::string itos(float i) { … … 60 67 61 68 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"); 64 73 65 74 // figure out how many narrow characters we are going to get … … 84 93 85 94 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"); 88 99 89 100 // figure out how many wide characters we are going to get -
modules/CheckSystem/CheckSystem.cpp
r34e7428 r846bbe4 861 861 try { 862 862 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"); 866 870 return NSCAPI::returnUNKNOWN; 867 871 } … … 894 898 return NSCAPI::returnUNKNOWN; 895 899 } 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; 896 904 #endif 897 905 } else { … … 995 1003 std::wstring tstr; 996 1004 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); 1000 1014 } 1001 1015 PDH::PDHQuery pdh; … … 1011 1025 double value = cDouble.getValue(); 1012 1026 if (bNSClient) { 1027 if (!msg.empty()) 1028 msg += _T(","); 1013 1029 msg += strEx::itos(static_cast<float>(value)); 1014 1030 } else { … … 1019 1035 } catch (const PDH::PDHException e) { 1020 1036 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(")"); 1022 1041 return NSCAPI::returnUNKNOWN; 1023 1042 } 1024 1043 } 1025 1044 1026 if (msg.empty() )1045 if (msg.empty() && !bNSClient) 1027 1046 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) 1029 1051 msg = NSCHelper::translateReturn(returnCode) + _T(": ") + msg; 1030 1052 return returnCode; -
modules/CheckWMI/CheckWMI.cpp
r34e7428 r846bbe4 100 100 MAP_OPTIONS_STR(_T("Query"), query) 101 101 MAP_OPTIONS_STR2INT(_T("truncate"), truncate) 102 MAP_OPTIONS_STR 2INT(_T("namespace"), ns)102 MAP_OPTIONS_STR(_T("namespace"), ns) 103 103 MAP_OPTIONS_STR(_T("Alias"), alias) 104 104 MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) … … 174 174 MAP_OPTIONS_SHOWALL(tmpObject) 175 175 MAP_OPTIONS_NUMERIC_ALL(tmpObject, _T("")) 176 MAP_OPTIONS_STR 2INT(_T("namespace"), ns)176 MAP_OPTIONS_STR(_T("namespace"), ns) 177 177 MAP_OPTIONS_STR(_T("Alias"), tmpObject.data) 178 178 MAP_OPTIONS_STR(_T("AliasCol"), aliasCol) -
modules/NRPEListener/NRPEListener.cpp
r5fda37e r846bbe4 255 255 return NSCAPI::critical; 256 256 } 257 257 return NSCAPI::returnIgnored; 258 258 } 259 259 -
modules/NSCAAgent/nsca_enrypt.hpp
r394f7a1 r846bbe4 91 91 void init(std::string password, unsigned char *transmitted_iv, int iv_size) { 92 92 /* generate an encryption/description key using the password */ 93 int keysize=get_keySize();93 unsigned int keysize=get_keySize(); 94 94 95 95 unsigned char *key = new unsigned char[keysize+1]; -
modules/SysTray/SysTray.cpp
r7f596ce r846bbe4 106 106 hWnd = hLogWnd; 107 107 } else { 108 std::cout << "Damnit!!!" << std::endl;109 108 NSC_LOG_ERROR_STD(_T("Failed to get mutex in logger, message discarded")); 110 109 } -
modules/SysTray/TrayIcon.cpp
r6d3bbc1 r846bbe4 39 39 } 40 40 41 #ifdef WINVER < 0x0600 42 #define MSGFLT_ADD 1 43 #define MSGFLT_REMOVE 2 44 typedef BOOL (WINAPI *LPFN_CHANGEWINDOWMESSAGEFILTER) (UINT, DWORD); 45 #endif 46 47 LPFN_CHANGEWINDOWMESSAGEFILTER fnChangeWindowMessageFilter = NULL; 48 BOOL 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 41 57 42 58 void IconWidget_::createDialog(void) { 59 ChangeWindowMessageFilter() 43 60 hDlgWnd = ::CreateDialog(NSCModuleWrapper::getModule(),MAKEINTRESOURCE(IDD_NSTRAYDLG),NULL,TrayIcon::DialogProc); 44 61 … … 47 64 NSC_LOG_ERROR_STD(_T("Failed to register 'TaskbarCreated': ") + error::lookup::last_error()); 48 65 } 66 ChangeWindowMessageFilter(UDM_TASKBARCREATED, MSGFLT_ADD); 49 67 50 68 MSG Msg;
Note: See TracChangeset
for help on using the changeset viewer.








