Changeset bf6e9b4 in nscp for modules/CheckEventLog
- Timestamp:
- 02/02/08 13:54:12 (5 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- 52215d7
- Parents:
- 5ac88c0a
- File:
-
- 1 edited
-
modules/CheckEventLog/CheckEventLog.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
modules/CheckEventLog/CheckEventLog.cpp
r5ac88c0a rbf6e9b4 28 28 #include <utils.h> 29 29 #include <error.hpp> 30 #include <map> 30 31 31 32 CheckEventLog gCheckEventLog; … … 56 57 return false; 57 58 } 58 59 59 60 60 … … 225 225 p += len+1; 226 226 } 227 std::wstring ret = error::format::message::from_module(get_dll(), eventID(), dwArgs); 227 228 /* 229 TCHAR **_sz = (TCHAR**)GlobalAlloc(GPTR, (pevlr_->NumStrings)*sizeof(TCHAR *)); 230 register UINT z; 231 TCHAR* p = reinterpret_cast<TCHAR*>(reinterpret_cast<LPBYTE>(pevlr_) + pevlr_->StringOffset); 232 for(unsigned int z = 0; z < pevlr_->NumStrings; z++) { 233 DWORD len = wcslen(p); 234 _sz[z] = (TCHAR *)GlobalAlloc(GPTR, (len+1) * sizeof(TCHAR)); 235 wcscpy_s(_sz[z], len, p); 236 p += len+1; 237 } 238 */ 239 std::wstring ret; 240 strEx::splitList dlls = strEx::splitEx(get_dll(), _T(";")); 241 for (strEx::splitList::const_iterator cit = dlls.begin(); cit != dlls.end(); ++cit) { 242 //std::wstring msg = error::format::message::from_module((*cit), eventID(), _sz); 243 std::wstring msg = error::format::message::from_module((*cit), eventID(), dwArgs); 244 if (msg.empty()) { 245 msg = error::format::message::from_module((*cit), pevlr_->EventID, dwArgs); 246 } 247 strEx::replace(msg, _T("\n"), _T(" ")); 248 strEx::replace(msg, _T("\t"), _T(" ")); 249 std::string::size_type pos = msg.find_last_not_of(_T("\n\t ")); 250 if (pos != std::string::npos) { 251 msg = msg.substr(0,pos); 252 } 253 if (!msg.empty()) { 254 if (!ret.empty()) 255 ret += _T(", "); 256 ret += msg; 257 } 258 } 228 259 delete [] dwArgs; 229 std::string::size_type pos = ret.find_last_not_of(_T("\n\t\m"));230 if (pos != std::string::npos) {231 ret = ret.substr(0,pos-1);232 }233 260 return ret; 234 261 } … … 274 301 } 275 302 }; 303 /* 304 return (pevlr_->EventID&0xffff); 305 } 306 inline DWORD severity() const { 307 return (pevlr_->EventID>>30); 308 */ 309 class uniq_eventlog_record { 310 DWORD ID; 311 WORD type; 312 WORD category; 313 public: 314 uniq_eventlog_record(EVENTLOGRECORD *pevlr) : ID(pevlr->EventID&0xffff), type(pevlr->EventType), category(pevlr->EventCategory) {} 315 bool operator< (const uniq_eventlog_record &other) const { 316 return (ID < other.ID) || ((ID==other.ID)&&(type < other.type)) || (ID==other.ID&&type==other.type)&&(category < other.category); 317 } 318 std::wstring to_string() const { 319 return _T("id=") + strEx::itos(ID) + _T("type=") + strEx::itos(type) + _T("category=") + strEx::itos(category); 320 } 321 }; 322 typedef std::map<uniq_eventlog_record,bool> uniq_eventlog_map; 276 323 277 324 … … 332 379 bool bFilterNew = false; 333 380 bool bShowDescriptions = false; 381 bool unique = false; 334 382 unsigned int truncate = 0; 335 383 std::wstring syntax; … … 338 386 const int filter_normal = 3; 339 387 const int filter_compat = 3; 340 NSC_DEBUG_MSG_STD(_T("000") + message) ;341 388 342 389 try { … … 344 391 MAP_OPTIONS_NUMERIC_ALL(query, _T("")) 345 392 MAP_OPTIONS_STR2INT(_T("truncate"), truncate) 393 MAP_OPTIONS_BOOL_TRUE(_T("unique"), unique) 346 394 MAP_OPTIONS_BOOL_TRUE(_T("descriptions"), bShowDescriptions) 347 395 MAP_OPTIONS_PUSH(_T("file"), files) … … 402 450 return NSCAPI::returnUNKNOWN; 403 451 } 452 uniq_eventlog_map uniq_records; 404 453 405 454 //DWORD dwThisRecord; … … 464 513 match = true; 465 514 } 515 if (match&&unique) { 516 uniq_eventlog_record record = pevlr; 517 uniq_eventlog_map::const_iterator cit = uniq_records.find(record); 518 if (cit != uniq_records.end()) { 519 match = false; 520 } 521 else 522 uniq_records[record] = true; 523 } 466 524 467 525 if (match) {
Note: See TracChangeset
for help on using the changeset viewer.








