当前位置: 首页>>代码示例>>C++>>正文


C++ EventQueue::addMessage方法代码示例

本文整理汇总了C++中EventQueue::addMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ EventQueue::addMessage方法的具体用法?C++ EventQueue::addMessage怎么用?C++ EventQueue::addMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventQueue的用法示例。


在下文中一共展示了EventQueue::addMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: atol

bool DatabaseConnection::parse_format_2(char * data, int len){
	LOG4CXX_DEBUG(logger,"In DatabaseConnection::parse_format_2() :" << len) ;
	//59:5423:501:1323670440:620781428,DB2INST1:select * from staff


	std::vector<std::string> strs;
	string str_data = data;
	boost::split(strs, str_data, boost::is_any_of(":"));

	if(strs.size() > 6){
		event.src_ip = "127.0.0.1";
		event.src_port = atol(strs[1].c_str());

		event_timestamp event_ts;
	    event_ts.event_in_s = atol(strs[3].c_str());
	    event_ts.event_in_ms = atol(strs[4].c_str());
		CachedUserInfo userInfo = userManager.getUserInfo(event.src_ip,strs[1]);

		string statement = "";
		int i = 6;
		while(i < strs.size()){
			statement += strs[i++];
		}

		statement = statement.substr(0,statement.size()-1);
		userManager.regStatement(event.src_ip,strs[1],statement);

		LOG4CXX_DEBUG(logger,"Statement " << statement);


		//Lets check if it's a duplicate
		if(userInfo.getEventTimestamp().event_in_s != 0 && (event_ts.event_in_s - userInfo.getEventTimestamp().event_in_s ) < 2){

			if( ((event_ts.event_in_s - userInfo.getEventTimestamp().event_in_s)*1000000000 + event_ts.event_in_ms - event_ts.event_in_ms) > 1000000 ){
				LOG4CXX_DEBUG(logger,"Duplicate detected: " << ((event_ts.event_in_s - userInfo.getEventTimestamp().event_in_s)*1000000000 + event_ts.event_in_ms - event_ts.event_in_ms) );
			    event_ts.event_in_s = 0;
			    event_ts.event_in_ms = 0;
			    userManager.regEventTimestamp(event.src_ip,strs[1],event_ts);
			    return true;
			}
		}else{
			userManager.regEventTimestamp(event.src_ip,strs[1],event_ts);
		}

		if(userInfo.getUsername().empty()){
			uid_t uid = atoi(strs[2].c_str());
			struct passwd * account = getpwuid(uid);
		}

		userManager.regAppName(event.src_ip,strs[1],"db2bp");



		boost::tokenizer<boost::char_separator<char> > tok(statement);
		i = 0;
		for (boost::tokenizer<boost::char_separator<char> >::iterator it = tok.begin(); it != tok.end(); ++it,i++){
			LOG4CXX_DEBUG(logger,"Token is " << *it);
			if( i == 0 &&strcasecmp((*it).c_str(),"connect") == 0 ){
				LOG4CXX_DEBUG(logger,"Processing connect");
				continue;
			}

			if( i == 0 &&strcasecmp((*it).c_str(),"terminate") == 0  ){
				LOG4CXX_DEBUG(logger,"Terminate processed");
				userManager.regUsername(event.src_ip,strs[1],"");
				break;
			}
			if( i == 1 &&strcasecmp((*it).c_str(),"to")  == 0 ){
				LOG4CXX_DEBUG(logger,"We have a connect statement");
				continue;
			}

			if( i == 2 ){
				userManager.regDBName(event.src_ip,strs[1],*it);
				continue;
			}

			if( i == 3 && strcasecmp((*it).c_str(),"user")   == 0  ){
				continue;
			}

			if( i == 4 ){
				LOG4CXX_DEBUG(logger,"Username specified " << *it);
				userManager.regUsername(event.src_ip,strs[1],*it);
			}
			break;
		}


		userManager.loadEventAttributes(event.src_ip,strs[1],event);
		LOG4CXX_DEBUG(logger,"Event: " << event.statement);

		event_queue.addMessage(event);
	}
	LOG4CXX_DEBUG(logger,"Exiting DatabaseConnection::parse_format_2()");
	return true;
}
开发者ID:database-audit,项目名称:Open-Database-Audit-Project,代码行数:97,代码来源:DatabaseConnection.cpp


注:本文中的EventQueue::addMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。