GameLoopResult GameLoopWaitForAnyKeyOrButtonFunc(void *data) { GameLoopWaitForAnyKeyOrButtonData *wData = data; int cmds[MAX_LOCAL_PLAYERS]; memset(cmds, 0, sizeof cmds); GetPlayerCmds(&gEventHandlers, &cmds); for (int i = 0; i < MAX_LOCAL_PLAYERS; i++) { if (cmds[i] & (CMD_BUTTON1 | CMD_BUTTON2)) { // Interpret anything other than CMD_BUTTON1 as cancel return WaitResult(wData, cmds[i] & CMD_BUTTON1); } } // Check menu commands const int menuCmd = GetMenuCmd(&gEventHandlers); if (menuCmd & (CMD_BUTTON1 | CMD_BUTTON2)) { // Interpret anything other than CMD_BUTTON1 as cancel return WaitResult(wData, menuCmd & CMD_BUTTON1); } // Check if anyone pressed escape if (EventIsEscape(&gEventHandlers, cmds, menuCmd)) { return WaitResult(wData, false); } return UPDATE_RESULT_OK; }
virtual void OnTimeout() { if(!WaitResult()){ std::string s; s = std::string((char*)CNodeName(nk)) + "." + (char*)CGroupName(gk) + " 上的数据库标签信息接收超时."; rtk_queue_event(PT_Progress, 1, 0, s.data()); } }
/******************************************************** * function:FTPLogIn * purpose:登录到FTP Server * return: FTP_SUCCEED 成功 , FTP_FAIL 失败 * *********************************************************/ int CFTPClient::FTPLogin ( const char* strServer, const char* strUser, const char* strPassword, const int i_iPort ) { struct hostent* lpHostEnt; /* Internet host information structure*/ struct sockaddr_in sockAddr; /* Socket address structure */ unsigned long lFtpAddr; sockAddr.sin_family = AF_INET; ////sockAddr.sin_port = htons(21); if ( i_iPort > 0 ) { sockAddr.sin_port = htons( i_iPort ); } else { sockAddr.sin_port = htons( 21 ); } /* 设置FTP server Internet 地址: 首先,判断是否是 格式 "133.96.168.1" 否则,判断是否是主机名 如:"sjz1" */ lFtpAddr = inet_addr( strServer ); if ( lFtpAddr == INADDR_NONE ) { if ( !( lpHostEnt = gethostbyname( strServer ) ) ) { perror( "gethostbyname" ); return -1; } sockAddr.sin_addr = *( (struct in_addr*) *lpHostEnt->h_addr_list ); } else { //sockAddr.sin_addr=*((struct in_addr *)&lFtpAddr); sockAddr.sin_addr.s_addr = lFtpAddr; } if ( ( m_hControlChannel = socket( AF_INET, SOCK_STREAM, 0 ) ) < 0 ) { perror( "socket() create " ); return -1; } if ( connect ( m_hControlChannel, reinterpret_cast < struct sockaddr * > (&sockAddr), sizeof(sockAddr) ) < 0 ) { close( m_hControlChannel ); perror( "connect()" ); return FTP_E_CONNECT; } int ret = WaitResult( m_hControlChannel ); if ( ret != 220 ) { close( m_hControlChannel ); return FTP_E_CONNECT; } /* 发送user命令 */ char buf[256]; snprintf( buf, sizeof( buf ), (char*)"USER %s\r\n", strUser ); int len = strlen( buf ); ret = Write( m_hControlChannel, buf, &len ); if ( ret < 0 || len != strlen( buf ) ) { close( m_hControlChannel ); return FTP_E_CONNECT; } ret = WaitResult( m_hControlChannel ); if ( ret != 331 ) { close( m_hControlChannel ); return FTP_E_USER; } /*发送pass命令*/ snprintf( buf, sizeof( buf ), (char*)"PASS %s\r\n", strPassword ); len = strlen( buf ); ret = Write( m_hControlChannel, buf, &len ); if ( ret < 0 || len != strlen( buf ) ) { close( m_hControlChannel ); return FTP_E_CONNECT; } ret = WaitResult( m_hControlChannel ); if ( ret != 230 ) { close( m_hControlChannel ); return FTP_E_PASS; } return 0; }