Exemple #1
0
int app::run(){
	
	while(m_brun){
		
		void* data = NULL;
		if(m_ring_buf.pop(data) == -1){
			continue;
		}
		
		app_hd * msg = (app_hd*)data;
		if(msg->type == tcp_type){
			switch(msg->event){
				case ev_sys_recv:
					on_recv(msg->u.tcp.n, msg->content, msg->length);
					break;
					
				case ev_sys_close:
					on_close(msg->u.tcp.n, *((int*)msg->content));
					delete msg->u.tcp.n;
					break;
					
				case ev_sys_accept:
					on_accept(msg->u.tcp.n);
					break;
					
				case ev_sys_connect_ok:
					on_connect(msg->u.tcp.n);
					break;
					
				case ev_sys_connect_fail:
					on_connect(msg->u.tcp.n);
					delete msg->u.tcp.n;
				break;
				
			}
		}
		else if(msg->type == timer_type){
			on_timer(msg->event, msg->u.timer.interval, msg->u.timer.ptr);
		}
		else if(msg->type == app_type){
			on_app(msg->event, msg->content, msg->length);
		}
		else{
			error_log("msg from unknown app_name(%s)\n", m_name);
		}
		free(msg);
	}
	return 0;
}
Exemple #2
0
Expr const*
Parser::postfix()
{
  Expr const* e = primary();
  while (true) {
    // We have an application only when the lookahead
    // indicates the start of a new primary expression.
    if (lookahead() == identifier_tok ||
        lookahead() == backslash_tok ||
        lookahead() == lparen_tok)
      e = on_app(e, primary());
    else
      break;
  }
  return e;
}
Exemple #3
0
int app::dispatch(const app_hd * msg){
	
	if(msg->type == tcp_type){
		switch(msg->event){
			case ev_sys_recv:
				on_recv(msg->u.tcp.n, msg->content, msg->length);
				break;
				
			case ev_sys_close:
				on_close(msg->u.tcp.n, *((int*)msg->content));
				delete msg->u.tcp.n;
				break;
				
			case ev_sys_accept:
				on_accept(msg->u.tcp.n);
				break;
				
			case ev_sys_connect_ok:
				on_connect(msg->u.tcp.n);
				break;
				
			case ev_sys_connect_fail:
				on_connect(msg->u.tcp.n);
				delete msg->u.tcp.n;
			break;
			
			case ev_sys_write:
				handle_write(msg->u.tcp.n);
			break;
		}
	}
	else if(msg->type == timer_type){
		on_timer(msg->event, msg->u.timer.interval, msg->u.timer.ptr);
	}
	else if(msg->type == app_type){
		on_app(msg->event, msg->content, msg->length);
	}
	else{
		error_log("msg from unknown app_name(%s)\n", m_name);
	}
	return 0;	
}
Exemple #4
0
	LRESULT CComWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
	{
		switch(uMsg)
		{
		case WM_INITDIALOG:		return on_create(m_hWnd, GetModuleHandle(0));
		case WM_VSCROLL: 
		case WM_HSCROLL:		return on_scroll(uMsg, wParam, lParam);
		case WM_SIZE:			
								__super::HandleMessage(uMsg, wParam, lParam, bHandled);
								return on_size(LOWORD(lParam), HIWORD(lParam));
		case WM_CLOSE:			return on_close();
		case WM_COMMAND:		return on_command(HWND(lParam), LOWORD(wParam), HIWORD(wParam));
		case WM_DEVICECHANGE:	return on_device_change(wParam, (DEV_BROADCAST_HDR*)lParam);
		case WM_SETTINGCHANGE:	return on_setting_change(wParam, LPCTSTR(lParam));
		case WM_CONTEXTMENU:	return on_contextmenu(HWND(wParam), GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
		case WM_LBUTTONDOWN:	return SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, 0);
		}
		if (uMsg >= WM_APP && uMsg <= 0xBFFF)
			return on_app(uMsg, wParam, lParam);

		return __super::HandleMessage(uMsg, wParam, lParam, bHandled);
	}