BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext) { // Split the window in two vertically. if (!m_wndSplitter.CreateStatic(this, 1, 2)) { TRACE0("Failed to CreateStaticSplitter\n"); return FALSE; } m_wndSplitter.SetColumnInfo(0,640, 0); m_wndSplitter.SetRowInfo(0,480, 0); // Now split the first pane in two horizontaly for the 3d and 2d views. if (!m_wndSplitter3.CreateStatic( &m_wndSplitter, // our parent window is the first splitter 2, 1, // the new splitter is 2 rows, 1 column WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed m_wndSplitter.IdFromRowCol(0, 0) // new splitter is in the first row, 2nd column of first splitter )) { TRACE0("Failed to create nested splitter\n"); return FALSE; } // Attach the 3d edit view class to the top pane. if (!m_wndSplitter3.CreateView(0, 0, RUNTIME_CLASS(CBTEditView), CSize(640, 480), pContext)) { TRACE0("Failed to create second pane\n"); return FALSE; } // And attach the 2d edit view to the bottom pane. if (!m_wndSplitter3.CreateView(1, 0, RUNTIME_CLASS(CWFView), CSize(640, 64), pContext)) { TRACE0("Failed to create second pane\n"); return FALSE; } if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CTextureView), CSize(20, 20), pContext)) { TRACE0("Failed to create second pane\n"); return FALSE; } //// The second horizontal split. // if (!m_wndSplitter2.CreateStatic( // &m_wndSplitter, // our parent window is the first splitter // 2, 1, // the new splitter is 2 rows, 1 column // WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed // m_wndSplitter.IdFromRowCol(0, 1) // // new splitter is in the first row, 2nd column of first splitter // )) // { // TRACE0("Failed to create nested splitter\n"); // return FALSE; // } // // if (!m_wndSplitter2.CreateView(0, 0, // RUNTIME_CLASS(CDBView), CSize(20, 128), pContext)) // { // TRACE0("Failed to create second pane\n"); // return FALSE; // } //// The second horizontal split. // if (!m_wndSplitter2.CreateStatic( // &m_wndSplitter, // our parent window is the first splitter // 2, 1, // the new splitter is 2 rows, 1 column // WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed // m_wndSplitter.IdFromRowCol(0, 1) // // new splitter is in the first row, 2nd column of first splitter // )) // { // TRACE0("Failed to create nested splitter\n"); // return FALSE; // } // // if (!m_wndSplitter2.CreateView(0, 0, // RUNTIME_CLASS(CDBView), CSize(20, 128), pContext)) // { // TRACE0("Failed to create second pane\n"); // return FALSE; // } // // if (!m_wndSplitter2.CreateView(1, 0, // RUNTIME_CLASS(CTextureView), CSize(20, 20), pContext)) // { // TRACE0("Failed to create second pane\n"); // return FALSE; // } return TRUE; }
int COGLColorCombiner4::ParseDecodedMux() { #define nextUnit() {unitNo++;} #ifndef USE_GLES if( m_maxTexUnits<3) return ParseDecodedMux2Units(); OGLExtCombinerSaveType res; for( int k=0; k<8; k++ ) res.units[k].tex = -1; COGLDecodedMux &mux = *(COGLDecodedMux*)m_pDecodedMux; int unitNos[2]; for( int rgbalpha = 0; rgbalpha<2; rgbalpha++ ) { unitNos[rgbalpha] = 0; for( int cycle = 0; cycle<2; cycle++ ) { int &unitNo = unitNos[rgbalpha]; OGLExtCombinerType &unit = res.units[unitNo]; OGLExt1CombType &comb = unit.Combs[rgbalpha]; CombinerFormatType type = m_pDecodedMux->splitType[cycle*2+rgbalpha]; N64CombinerType &m = m_pDecodedMux->m_n64Combiners[cycle*2+rgbalpha]; comb.arg0 = comb.arg1 = comb.arg2 = CM_IGNORE_BYTE; switch( type ) { case CM_FMT_TYPE_NOT_USED: comb.arg0 = MUX_COMBINED; unit.ops[rgbalpha] = GL_REPLACE; nextUnit(); break; case CM_FMT_TYPE_D: // = A comb.arg0 = m.d; unit.ops[rgbalpha] = GL_REPLACE; nextUnit(); break; case CM_FMT_TYPE_A_ADD_D: // = A+D comb.arg0 = m.a; comb.arg1 = m.d; unit.ops[rgbalpha] = GL_ADD; nextUnit(); break; case CM_FMT_TYPE_A_SUB_B: // = A-B comb.arg0 = m.a; comb.arg1 = m.b; unit.ops[rgbalpha] = GL_SUBTRACT; nextUnit(); break; case CM_FMT_TYPE_A_MOD_C: // = A*C comb.arg0 = m.a; comb.arg1 = m.c; unit.ops[rgbalpha] = GL_MODULATE; nextUnit(); break; case CM_FMT_TYPE_A_MOD_C_ADD_D: // = A*C+D if( m_bSupportModAdd_ATI ) { comb.arg0 = m.a; comb.arg2 = m.c; comb.arg1 = m.d; unit.ops[rgbalpha] = GL_MODULATE_ADD_ATI; nextUnit(); } else { if( unitNo < m_maxTexUnits-1 ) { comb.arg0 = m.a; comb.arg1 = m.c; unit.ops[rgbalpha] = GL_MODULATE; nextUnit(); res.units[unitNo].Combs[rgbalpha].arg0 = MUX_COMBINED; res.units[unitNo].Combs[rgbalpha].arg1 = m.d; res.units[unitNo].ops[rgbalpha] = GL_ADD; nextUnit(); } else { comb.arg0 = m.a; comb.arg1 = m.c; comb.arg2 = m.d; unit.ops[rgbalpha] = GL_INTERPOLATE; nextUnit(); } } break; case CM_FMT_TYPE_A_LERP_B_C: // = (A-B)*C+B comb.arg0 = m.a; comb.arg1 = m.b; comb.arg2 = m.c; unit.ops[rgbalpha] = GL_INTERPOLATE; nextUnit(); break; case CM_FMT_TYPE_A_SUB_B_ADD_D: // = A-B+D if( unitNo < m_maxTexUnits-1 ) { comb.arg0 = m.a; comb.arg1 = m.b; unit.ops[rgbalpha] = GL_SUBTRACT; nextUnit(); res.units[unitNo].Combs[rgbalpha].arg0 = MUX_COMBINED; res.units[unitNo].Combs[rgbalpha].arg1 = m.d; res.units[unitNo].ops[rgbalpha] = GL_ADD; nextUnit(); } else { comb.arg0 = m.a; comb.arg1 = m.c; comb.arg2 = m.d; unit.ops[rgbalpha] = GL_INTERPOLATE; nextUnit(); } break; case CM_FMT_TYPE_A_SUB_B_MOD_C: // = (A-B)*C if( unitNo < m_maxTexUnits-1 ) { comb.arg0 = m.a; comb.arg1 = m.b; unit.ops[rgbalpha] = GL_SUBTRACT; nextUnit(); res.units[unitNo].Combs[rgbalpha].arg0 = MUX_COMBINED; res.units[unitNo].Combs[rgbalpha].arg1 = m.c; res.units[unitNo].ops[rgbalpha] = GL_MODULATE; nextUnit(); } else { comb.arg0 = m.a; comb.arg1 = m.c; comb.arg2 = m.d; unit.ops[rgbalpha] = GL_INTERPOLATE; nextUnit(); } break; case CM_FMT_TYPE_A_B_C_D: // = (A-B)*C+D default: if( unitNo < m_maxTexUnits-1 ) { comb.arg0 = m.a; comb.arg1 = m.b; unit.ops[rgbalpha] = GL_SUBTRACT; nextUnit(); if( m_bSupportModAdd_ATI ) { res.units[unitNo].Combs[rgbalpha].arg0 = MUX_COMBINED; res.units[unitNo].Combs[rgbalpha].arg2 = m.c; res.units[unitNo].Combs[rgbalpha].arg1 = m.d; res.units[unitNo].ops[rgbalpha] = GL_MODULATE_ADD_ATI; nextUnit(); } else { res.units[unitNo].Combs[rgbalpha].arg0 = m.a; res.units[unitNo].Combs[rgbalpha].arg1 = m.b; res.units[unitNo].Combs[rgbalpha].arg2 = m.c; res.units[unitNo].ops[rgbalpha] = GL_INTERPOLATE; nextUnit(); } } else { comb.arg0 = m.a; comb.arg1 = m.c; comb.arg2 = m.d; unit.ops[rgbalpha] = GL_INTERPOLATE; nextUnit(); } break; } } } res.numOfUnits = std::min(m_maxTexUnits, std::max(unitNos[0],unitNos[1])); if( unitNos[0]>m_maxTexUnits || unitNos[1]>m_maxTexUnits ) { TRACE0("Unit overflows"); } for( int j=0; j<2; j++ ) { if( unitNos[j]<res.numOfUnits ) { for( int i=unitNos[j]; i<res.numOfUnits; i++ ) { res.units[i].Combs[j].arg0 = MUX_COMBINED; res.units[i].ops[j] = GL_REPLACE; } } } res.units[0].tex = 0; res.units[1].tex = 1; res.primIsUsed = mux.isUsed(MUX_PRIM); res.envIsUsed = mux.isUsed(MUX_ENV); res.lodFracIsUsed = mux.isUsed(MUX_LODFRAC) || mux.isUsed(MUX_PRIMLODFRAC); return SaveParsedResult(res); #else return 0; #endif }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) return -1; BOOL bNameValid; // 基于持久值设置视觉管理器和样式 OnApplicationLook(theApp.m_nAppLook); if (!m_wndMenuBar.Create(this)) { TRACE0("未能创建菜单栏\n"); return -1; // 未能创建 } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); // 防止菜单栏在激活时获得焦点 CMFCPopupMenu::SetForceMenuFocus(FALSE); if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) { TRACE0("未能创建工具栏\n"); return -1; // 未能创建 } CString strToolBarName; bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); ASSERT(bNameValid); m_wndToolBar.SetWindowText(strToolBarName); CString strCustomize; bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); ASSERT(bNameValid); m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); // 允许用户定义的工具栏操作: InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId); if (!m_wndStatusBar.Create(this)) { TRACE0("未能创建状态栏\n"); return -1; // 未能创建 } m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndMenuBar); DockPane(&m_wndToolBar); // 启用 Visual Studio 2005 样式停靠窗口行为 CDockingManager::SetDockingMode(DT_SMART); // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 EnableAutoHidePanes(CBRS_ALIGN_ANY); // 启用工具栏和停靠窗口菜单替换 EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); // 启用快速(按住 Alt 拖动)工具栏自定义 CMFCToolBar::EnableQuickCustomization(); if (CMFCToolBar::GetUserImages() == NULL) { // 加载用户定义的工具栏图像 if (m_UserImages.Load(_T(".\\UserImages.bmp"))) { CMFCToolBar::SetUserImages(&m_UserImages); } } // 启用菜单个性化(最近使用的命令) // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail(ID_FILE_NEW); lstBasicCommands.AddTail(ID_FILE_OPEN); lstBasicCommands.AddTail(ID_FILE_SAVE); lstBasicCommands.AddTail(ID_FILE_PRINT); lstBasicCommands.AddTail(ID_APP_EXIT); lstBasicCommands.AddTail(ID_EDIT_CUT); lstBasicCommands.AddTail(ID_EDIT_PASTE); lstBasicCommands.AddTail(ID_EDIT_UNDO); lstBasicCommands.AddTail(ID_APP_ABOUT); lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); CMFCToolBar::SetBasicCommands(lstBasicCommands); m_menu.AttachMenu(this->GetMenu()->GetSafeHmenu()); m_menu.ChangeMenuItem(&m_menu,TRUE); return 0; }
int CScdIFApp::ExitInstance() { TRACE0("ScdIF : ExitInstance\n"); _Module.Term(); return CWinApp::ExitInstance(); }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOffice2007)); CMDITabInfo mdiTabParams; mdiTabParams.m_bTabIcons = TRUE; mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; mdiTabParams.m_bAutoColor = TRUE; EnableMDITabbedGroups (TRUE, mdiTabParams); CDockingManager::SetDockingMode (DT_SMART); m_wndRibbonBar.Create (this); InitRibbon (); if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // Load control bar icons: CMFCToolBarImages imagesWorkspace; imagesWorkspace.SetImageSize (CSize (16, 16)); imagesWorkspace.SetTransparentColor (RGB (255, 0, 255)); imagesWorkspace.Load (IDB_WORKSPACE); if (!m_wndWorkSpace.Create (_T("View 1"), this, CRect (0, 0, 200, 200), TRUE, ID_VIEW_WORKSPACE, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) { TRACE0("Failed to create Workspace bar\n"); return FALSE; // fail to create } m_wndWorkSpace.SetIcon (imagesWorkspace.ExtractIcon (0), FALSE); if (!m_wndWorkSpace2.Create (_T("View 2"), this, CRect (0, 0, 200, 200), TRUE, ID_VIEW_WORKSPACE2, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) { TRACE0("Failed to create Workspace bar 2\n"); return FALSE; // fail to create } m_wndWorkSpace2.SetIcon (imagesWorkspace.ExtractIcon (1), FALSE); if (!m_wndOutput.Create (_T("Output"), this, CRect (0, 0, 150, 150), TRUE /* Has gripper */, ID_VIEW_OUTPUT, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI)) { TRACE0("Failed to create output bar\n"); return -1; // fail to create } m_wndOutput.SetIcon (imagesWorkspace.ExtractIcon (2), FALSE); m_wndWorkSpace.EnableDocking(CBRS_ALIGN_ANY); m_wndWorkSpace2.EnableDocking(CBRS_ALIGN_ANY); m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); EnableAutoHidePanes(CBRS_ALIGN_ANY); DockPane (&m_wndWorkSpace); m_wndWorkSpace2.AttachToTabWnd (&m_wndWorkSpace, DM_STANDARD, FALSE, NULL); DockPane(&m_wndOutput); // Enable windows manager: EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); return 0; }
BOOL CBCGPRibbonBackstagePagePrint::OnInitDialog() { CBCGPDialog::OnInitDialog(); UpdateLabels(); if (CBCGPVisualManager::GetInstance()->IsDWMCaptionSupported()) { m_wndZoomNum.m_bOnGlass = TRUE; } BOOL bInitialized = FALSE; CView* pView = NULL; CFrameWnd* pFrame = DYNAMIC_DOWNCAST(CFrameWnd, AfxGetApp ()->GetMainWnd ()); if (pFrame != NULL) { if (pFrame->IsKindOf (RUNTIME_CLASS(CMDIFrameWnd))) { pFrame = ((CMDIFrameWnd*)pFrame)->GetActiveFrame (); } pView = pFrame->GetActiveView (); bInitialized = pView != NULL; } CRect rectWnd; CWnd* pWndLocation = GetDlgItem (IDC_BCGBARRES_PRINT_PREVIEW); ASSERT(pWndLocation); pWndLocation->GetWindowRect (rectWnd); ScreenToClient (rectWnd); pWndLocation->ShowWindow (SW_HIDE); pWndLocation->DestroyWindow (); if (bInitialized && pView->GetSafeHwnd () != NULL) { // Create the preview view object m_wndPreview = CreatePreviewWnd(); if (m_wndPreview == NULL) { TRACE0("Error: Failed to create preview control.\n"); } else if (!m_wndPreview->Create(WS_CHILD | WS_TABSTOP, CRect(0, 0, 0, 0), this, IDC_BCGBARRES_PRINT_PREVIEW)) { TRACE0("Error: Failed to create preview control.\n"); delete m_wndPreview; m_wndPreview = NULL; } else { m_wndPreview->m_bVisualManagerStyle = IsVisualManagerStyle(); m_wndPreview->m_bBackstageMode = IsBackstageMode(); m_wndPreview->SetNotifyPage (IDC_BCGBARRES_PRINT_PAGE_NUM); m_wndPreview->SetNotifyZoom (IDC_BCGBARRES_PRINT_ZOOM_NUM); InitializePrintInfo(); if (!m_wndPreview->SetPrintView (pView, NULL)) { TRACE0("Error: Failed to initialize preview control.\n"); m_wndPreview->DestroyWindow (); delete m_wndPreview; m_wndPreview = NULL; bInitialized = FALSE; } else { m_wndPreview->ShowWindow (SW_SHOWNA); m_wndPreview->MoveWindow (rectWnd); } } } OnInitPrintControls(); CBCGPStaticLayout* pLayout = (CBCGPStaticLayout*)GetLayout(); ASSERT_VALID(pLayout); pLayout->AddAnchor(IDC_BCGBARRES_PRINT_SEPARATOR, CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeVert); if (m_wndPreview->GetSafeHwnd () != NULL) { pLayout->AddAnchor(m_wndPreview->GetSafeHwnd (), CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeBoth); } pLayout->AddAnchor(AFX_ID_PREVIEW_PREV, CBCGPStaticLayout::e_MoveTypeVert, CBCGPStaticLayout::e_SizeTypeNone); pLayout->AddAnchor(IDC_BCGBARRES_PRINT_PAGE_NUM, CBCGPStaticLayout::e_MoveTypeVert, CBCGPStaticLayout::e_SizeTypeNone); pLayout->AddAnchor(AFX_ID_PREVIEW_NEXT, CBCGPStaticLayout::e_MoveTypeVert, CBCGPStaticLayout::e_SizeTypeNone); pLayout->AddAnchor(IDC_BCGBARRES_PRINT_ZOOM_NUM, CBCGPStaticLayout::e_MoveTypeBoth, CBCGPStaticLayout::e_SizeTypeNone); pLayout->AddAnchor(IDC_BCGBARRES_PRINT_ZOOM_SLIDER, CBCGPStaticLayout::e_MoveTypeBoth, CBCGPStaticLayout::e_SizeTypeNone); PRINTDLG* dlgPrint = GetPrintDlg(); if (!bInitialized || dlgPrint == NULL || dlgPrint->hDevMode == NULL || dlgPrint->hDevNames == NULL) { m_btnPrint.EnableWindow (FALSE); SetCopies(m_nCopies, FALSE); } OnPageChanged (); OnZoomChanged (); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CMonProcDlg::OnCheckTomcatButton( ) { CString csTomcat = "java"; CWnd *pWnd = 0; bool bStatus; #ifdef DEBUG_TRACE bool bTrace = FALSE; #endif int nCnt; int nStartupDelay = m_nStartupDelay / 20; long lRC; if ( nStartupDelay < 100 ) nStartupDelay = 100; CButton *pCheckButton = (CButton *) GetDlgItem( IDC_CHECKTOMCAT ); CButton *pCancelButton = (CButton *) GetDlgItem( IDC_CANCELCHECKTOMCAT ); pCheckButton->EnableWindow( FALSE ); PumpMessages( ); g_nCheckTomcat = 1; // going to begin checking Tomcat while ( g_nCheckTomcat ) { if ( !m_win32proc.GetProcessStatus( &csTomcat, &bStatus ) ) { AfxMessageBox( m_win32proc.GetLastError( ) ); return; } if ( pWnd == 0 && m_csWindowTitle.IsEmpty( ) == FALSE ) pWnd = FindWindow( m_csWindowClass, m_csWindowTitle ); if ( bStatus == FALSE ) // Tomcat not running { if ( m_nWriteLogMessage ) { if ( pWnd && ::IsWindow( pWnd->m_hWnd ) ) { ::SendMessage( pWnd->m_hWnd, WM_USER + m_nWriteLogMessage, 0, 0 ); PumpMessages( ); } } WinExec( m_csKillApp, SW_SHOW ); pWnd = 0; #ifdef DEBUG_TRACE TRACE0( "Tomcat not running\n" ); bTrace = FALSE; #endif Sleep( m_nKillAppDelay ); // two-second delay to let OE go down WinExec( m_csStartup, SW_SHOW ); #ifdef DEBUG_TRACE TRACE0( "WinExec Tomcat startup\n" ); #endif nCnt = 0; while ( g_nCheckTomcat && nCnt++ < 20 ) { PumpMessages( ); Sleep( nStartupDelay ); // twenty-second delay to let Tomcat start } } else { #ifdef DEBUG_TRACE if ( bTrace == FALSE ) { TRACE0( "Tomcat is running\n" ); bTrace = TRUE; } #endif if ( pWnd ) { if ( ::IsWindow( pWnd->m_hWnd ) ) { lRC = ::SendMessage( pWnd->m_hWnd, WM_USER + m_nQueryAliveMessage, 0, 0 ); PumpMessages( ); } else lRC = 0; } else lRC = -1; if ( lRC != -1 ) { // ::SendMessage( pWnd->m_hWnd, WM_USER + m_nWriteLogMessage, 0, 0 ); doesn't exist // PumpMessages( ); WinExec( m_csKillApp, SW_SHOW ); // stop OE pWnd = 0; #ifdef DEBUG_TRACE TRACE0( "Zeidon not running\n" ); bTrace = FALSE; #endif WinExec( m_csShutdown, SW_SHOW ); // stop Tomcat Sleep( m_nKillAppDelay ); // two-second delay to let OE go down WinExec( m_csStartup, SW_SHOW ); #ifdef DEBUG_TRACE TRACE0( "WinExec Tomcat2 startup\n" ); #endif } } if ( g_nCheckTomcat == 1 ) // beginning to check Tomcat { g_nCheckTomcat = 2; // check for Tomcat now in full swing pCheckButton->ShowWindow( SW_HIDE ); pCancelButton->ShowWindow( SW_SHOW ); } PumpMessages( ); Sleep( 1000 ); // one-second delay to let other apps work } }
/* * Delete a route from RTMv2 based on a routing socket message. * XXX: We should report errors in more detail, e.g. if the * route could not be added because it already existed, etc. */ int rtm_delete_route(struct rt_msghdr *rtm, int msgsize) { static const min_msgsize = (sizeof(struct rt_msghdr) + (sizeof(sockunion_t) * 2)); sockunion_t *sa; struct in_addr in_dest; struct in_addr in_mask; int found; int i; int prefix; int retval; DWORD result; RTM_DEST_INFO di; RTM_NET_ADDRESS dest; RTM_ROUTE_CHANGE_FLAGS changeflags; /* * Sanity check message size, fields etc. */ if (!rtm) return -1; if (msgsize < min_msgsize || (rtm->rtm_msglen < min_msgsize)) return -1; if (rtm->rtm_type != RTM_DELETE) return -1; if ((rtm->rtm_addrs & (RTA_DST|RTA_NETMASK)) != (RTA_DST|RTA_NETMASK)) return -1; /* * Extract destination, netmask and next-hop from routing * socket message. * XXX: bsd's delete order is: <DST,GATEWAY,NETMASK> * XXX: we don't check to see if gateway is present and * if so we do not handle it correctly. */ sa = (sockunion_t *)(rtm + 1); in_dest = sa->sin.sin_addr; ++sa; in_mask = sa->sin.sin_addr; /* * Convert netmask to a prefix length. * Convert destination to an RTM_NET_ADDRESS. */ RTM_IPV4_LEN_FROM_MASK(prefix, in_mask.s_addr); RTM_IPV4_MAKE_NET_ADDRESS(&dest, in_dest.s_addr, prefix); /* * Look up the route to be deleted in RTMv2, from those * which belong to our protocol, in the unicast view. */ ZeroMemory(&di, sizeof(di)); di.DestAddress = dest; result = RtmGetExactMatchDestination(g_ce.hRtmHandle, &dest, RTM_THIS_PROTOCOL, RTM_VIEW_MASK_UCAST, &di); if (result != NO_ERROR) { TRACE1(NETWORK, "error %u looking up route to delete", result); retval = -1; goto out; } i = 0; found = 0; for (i = 0; i < di.NumberOfViews; i++) { if (di.ViewInfo[i].ViewId == RTM_VIEW_ID_UCAST) { /* * Return a match only if the unicast view for our protocol * contains a single next-hop route to the destination. */ if (di.ViewInfo[i].NumRoutes == 1) found = 1; break; } } if (!found) { TRACE0(NETWORK, "route not found in table"); retval = -1; goto out; } result = RtmDeleteRouteToDest(g_ce.hRtmHandle, di.ViewInfo[i].Route, &changeflags); if (result != NO_ERROR) { TRACE1(NETWORK, "error %u deleting route", result); retval = -1; goto out; } retval = 0; out: return (retval); }
int rtm_ifannounce(LPWSTR ifname, DWORD ifindex, int what) { WCHAR fnameW[IFNAMSIZ]; struct if_announcemsghdr *ifa; int result; int retval; TRACE3(ENTER, "Entering rtm_ifannounce %S %d %d", ifname, ifindex, what); ifa = NULL; retval = -1; if ((what != IFAN_ARRIVAL) && (what != IFAN_DEPARTURE)) { goto out; } ifa = malloc(sizeof(*ifa)); if (ifa == NULL) { goto out; } ifa->ifan_name[0] = '\0'; /* * If this is a new interface, then look up the FriendlyName from * the unicode GUID name; convert Unicode to ASCII afterwards. * If the caller didn't supply this, the error is fatal to this function. * If we can't find it, the error is non-fatal to this function. * * XXX: The very fact that we don't provide the interface name here * is a limitation to do with how the notifications work in the * Microsoft stack. It only tells us the interface index when * the interface goes away. XORP currently depends on both for * interface deletion. We could look it up from the transport, * but it's more work to deliver redundant information. */ if (what == IFAN_ARRIVAL) { if (ifname == NULL) goto out; result = MprConfigGetFriendlyName(g_ce.hMprConfig, ifname, fnameW, sizeof(fnameW)); if (result != NO_ERROR) { TRACE1(NETWORK, "can't find friendlyname for ifname %S", ifname); } else { wcstombs(ifa->ifan_name, fnameW, IFNAMSIZ); } } /* * Fill our the rest of the interface announcement and send it to * all connected clients. */ ifa->ifan_msglen = sizeof(*ifa); ifa->ifan_version = RTM_VERSION; /* XXX should set to 0 or ignore */ ifa->ifan_type = RTM_IFANNOUNCE; ifa->ifan_index = ifindex; ifa->ifan_what = what; broadcast_pipe_message(ifa, sizeof(*ifa)); retval = 0; out: if (ifa != NULL) free(ifa); TRACE0(ENTER, "Leaving rtm_ifannounce"); return (retval); }
DWORD CE_Create ( PCONFIGURATION_ENTRY pce) { DWORD dwErr = NO_ERROR; /* initialize to default values */ ZeroMemory(pce, sizeof(CONFIGURATION_ENTRY)); pce->dwTraceID = INVALID_TRACEID; do { /* initialize the read-write lock */ CREATE_READ_WRITE_LOCK(&(pce->rwlLock)); if (!READ_WRITE_LOCK_CREATED(&(pce->rwlLock))) { dwErr = GetLastError(); TRACE1(CONFIGURATION, "Error %u creating read-write-lock", dwErr); break; } /* initialize the global heap */ pce->hGlobalHeap = HeapCreate(0, 0, 0); if (pce->hGlobalHeap == NULL) { dwErr = GetLastError(); TRACE1(CONFIGURATION, "Error %u creating global heap", dwErr); break; } /* * Initialize the count of threads that are active in subsystem. * Create the semaphore released by each thread when it is done; * required for clean stop to the protocol. */ pce->ulActivityCount = 0; pce->hActivitySemaphore = CreateSemaphore(NULL, 0, 0xfffffff, NULL); if (pce->hActivitySemaphore == NULL) { dwErr = GetLastError(); TRACE1(CONFIGURATION, "Error %u creating semaphore", dwErr); break; } /* Logging & Tracing Information */ pce->dwTraceID = TraceRegister(XORPRTM_TRACENAME); /* Event Queue */ INITIALIZE_LOCKED_QUEUE(&(pce->lqEventQueue)); if (!LOCKED_QUEUE_INITIALIZED(&(pce->lqEventQueue))) { dwErr = GetLastError(); TRACE1(CONFIGURATION, "Error %u initializing locked queue", dwErr); break; } /* Protocol State */ pce->iscStatus = XORPRTM_STATUS_STOPPED; } while (FALSE); if (dwErr != NO_ERROR) { /* something went wrong, so cleanup. */ TRACE0(CONFIGURATION, "Failed to create configuration entry"); CE_Destroy(pce); } return dwErr; }
DWORD CE_Initialize ( PCONFIGURATION_ENTRY pce, HANDLE hMgrNotificationEvent, PSUPPORT_FUNCTIONS psfSupportFunctions, PXORPRTM_GLOBAL_CONFIG pigc) { DWORD dwErr = NO_ERROR; pipe_instance_t *pp; int i, pipefail; do { pce->ulActivityCount = 0; pce->hMprConfig = NULL; dwErr = MprConfigServerConnect(NULL, &pce->hMprConfig); if (dwErr != NO_ERROR) { TRACE0(CONFIGURATION, "could not obtain mpr config handle"); } /* Router Manager Information */ pce->hMgrNotificationEvent = hMgrNotificationEvent; if (psfSupportFunctions) pce->sfSupportFunctions = *psfSupportFunctions; pipefail = 0; for (i = 0; i < PIPE_INSTANCES; i++) { pp = pipe_new(); if (pp == NULL) { pipefail = 1; break; } else { pipe_listen(pp); pce->pipes[i] = pp; } } if (pipefail) { TRACE0(CONFIGURATION, "failed to allocate all pipes"); break; } TRACE0(ANY, "Listening on pipes ok."); pce->reiRtmEntity.RtmInstanceId = 0; #ifdef IPV6_DLL pce->reiRtmEntity.AddressFamily = AF_INET6; #else pce->reiRtmEntity.AddressFamily = AF_INET; #endif pce->reiRtmEntity.EntityId.EntityProtocolId = PROTO_IP_XORPRTM; pce->reiRtmEntity.EntityId.EntityInstanceId = 0; dwErr = RtmRegisterEntity( &pce->reiRtmEntity, NULL, RTM_CallbackEvent, TRUE, &pce->rrpRtmProfile, &pce->hRtmHandle); if (dwErr != NO_ERROR) { TRACE1(CONFIGURATION, "Error %u registering with RTM", dwErr); break; } TRACE0(ANY, "registered entity ok."); dwErr = RtmRegisterForChangeNotification( pce->hRtmHandle, RTM_VIEW_MASK_UCAST, RTM_CHANGE_TYPE_ALL, NULL, &pce->hRtmNotificationHandle); if (dwErr != NO_ERROR) { TRACE1(CONFIGURATION, "Error %u registering for change with RTM", dwErr); break; } TRACE0(ANY, "registered rtm changes ok."); pce->iscStatus = XORPRTM_STATUS_RUNNING; } while (FALSE); if (dwErr != NO_ERROR) { TRACE0(ANY, "init failed, cleaning up."); CE_Cleanup(pce); } else { TRACE0(ANY, "Leaving init ok "); } return dwErr; }
void CScriptView::OnScriptMakeModel() { // First we save script file CModelerDoc *pDoc = (CModelerDoc *) GetDocument(); CTFileName fnScriptName = CTString(pDoc->GetPathName()); CTFileName fnModelName = fnScriptName.FileDir() + fnScriptName.FileName() + ".mdl"; try { fnScriptName.RemoveApplicationPath_t(); } catch( char *err_str) { AfxMessageBox( err_str); return; } pDoc->OnSaveDocument( pDoc->GetPathName()); // close mdl document with same name POSITION pos = theApp.m_pdtModelDocTemplate->GetFirstDocPosition(); while (pos!=NULL) { CModelerDoc *pmdCurrent = (CModelerDoc *)theApp.m_pdtModelDocTemplate->GetNextDoc(pos); if( CTFileName( CTString(pmdCurrent->GetPathName())) == fnModelName) { pmdCurrent->OnCloseDocument(); break; } } // Now we will create one instance of new document of type CModelerDoc CDocument* pDocument = theApp.m_pdtModelDocTemplate->CreateNewDocument(); if (pDocument == NULL) { TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n"); AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC); return; } ASSERT_VALID(pDocument); BOOL bAutoDelete = pDocument->m_bAutoDelete; pDocument->m_bAutoDelete = FALSE; // don't destroy if something goes wrong CFrameWnd* pFrame = theApp.m_pdtModelDocTemplate->CreateNewFrame(pDocument, NULL); pDocument->m_bAutoDelete = bAutoDelete; if (pFrame == NULL) { AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC); delete pDocument; // explicit delete on error return; } ASSERT_VALID(pFrame); pDocument->SetPathName( fnModelName, FALSE); pDocument->SetTitle( fnModelName.FileName() + fnModelName.FileExt()); char strError[ 256]; if( !((CModelerDoc *)pDocument)->CreateModelFromScriptFile( fnScriptName, strError)) { pDocument->OnCloseDocument(); AfxMessageBox( strError); return; } theApp.m_pdtModelDocTemplate->InitialUpdateFrame(pFrame, pDocument, TRUE); ((CModelerDoc *)pDocument)->m_emEditModel.edm_md.md_bPreparedForRendering = FALSE; pDocument->SetModifiedFlag(); // add textures from .ini file CTFileName fnIniFileName = fnScriptName.NoExt() + ".ini"; try { ((CModelerDoc *)pDocument)->m_emEditModel.CSerial::Load_t(fnIniFileName); } catch( char *strError) { // ignore errors (void) strError; } }
static int EplLinIoctl ( struct inode* pDeviceFile_p, // information about the device to open struct file* pInstance_p, // information about driver instance unsigned int uiIoctlCmd_p, // Ioctl command to execute unsigned long ulArg_p) // Ioctl command specific argument/parameter { tEplKernel EplRet; int iErr; int iRet; // TRACE1("EPL: + EplLinIoctl (uiIoctlCmd_p=%d)...\n", uiIoctlCmd_p); iRet = -EINVAL; switch (uiIoctlCmd_p) { // ---------------------------------------------------------- case EPLLIN_CMD_INITIALIZE: { tEplApiInitParam EplApiInitParam; iErr = copy_from_user(&EplApiInitParam, (const void*)ulArg_p, sizeof (EplApiInitParam)); if (iErr != 0) { iRet = -EIO; goto Exit; } EplApiInitParam.m_pfnCbEvent = EplLinCbEvent; EplApiInitParam.m_pfnCbSync = EplLinCbSync; EplApiInitParam.m_pfnObdInitRam = EplObdInitRam; EplRet = EplApiInitialize(&EplApiInitParam); #if (EPL_OBD_USE_LOAD_CONCISEDCF != FALSE) if (EplRet == kEplSuccessful) { EplRet = EplApiSetCdcFilename(pszCdcFilename_g); } #endif uiEplState_g = EPL_STATE_INITED; iRet = (int) EplRet; break; } // ---------------------------------------------------------- case EPLLIN_CMD_SHUTDOWN: { // shutdown the threads TRACE0("EPL: + EPLLIN_CMD_SHUTDOWN\n"); // pass control to sync kernel thread, but signal termination atomic_set(&AtomicSyncState_g, EVENT_STATE_TERM); wake_up_interruptible(&WaitQueueCbSync_g); wake_up_interruptible(&WaitQueuePI_In_g); // pass control to event queue kernel thread atomic_set(&AtomicEventState_g, EVENT_STATE_TERM); wake_up_interruptible(&WaitQueueCbEvent_g); wake_up_interruptible(&WaitQueueProcess_g); if (uiEplState_g == EPL_STATE_RUNNING) { // post NmtEventSwitchOff EplRet = EplApiExecNmtCommand(kEplNmtEventSwitchOff); } TRACE0("EPL: - EPLLIN_CMD_SHUTDOWN\n"); iRet = 0; break; } // ---------------------------------------------------------- case EPLLIN_CMD_READ_LOCAL_OBJECT: { tEplLinLocalObject LocalObject; void* pData; iErr = copy_from_user(&LocalObject, (const void*)ulArg_p, sizeof (LocalObject)); if (iErr != 0) { iRet = -EIO; goto Exit; } if ((LocalObject.m_pData == NULL) || (LocalObject.m_uiSize == 0)) { iRet = (int) kEplApiInvalidParam; goto Exit; } pData = vmalloc(LocalObject.m_uiSize); if (pData == NULL) { // no memory available iRet = -ENOMEM; goto Exit; } EplRet = EplApiReadLocalObject(LocalObject.m_uiIndex, LocalObject.m_uiSubindex, pData, &LocalObject.m_uiSize); if (EplRet == kEplSuccessful) { iErr = copy_to_user(LocalObject.m_pData, pData, LocalObject.m_uiSize); vfree(pData); if (iErr != 0) { iRet = -EIO; goto Exit; } // return actual size (LocalObject.m_uiSize) iErr = put_user(LocalObject.m_uiSize, (unsigned int*)(ulArg_p + (unsigned long)&LocalObject.m_uiSize - (unsigned long)&LocalObject)); if (iErr != 0) { iRet = -EIO; goto Exit; } } else { vfree(pData); } iRet = (int) EplRet; break; } // ---------------------------------------------------------- case EPLLIN_CMD_WRITE_LOCAL_OBJECT: { tEplLinLocalObject LocalObject; void* pData; iErr = copy_from_user(&LocalObject, (const void*)ulArg_p, sizeof (LocalObject)); if (iErr != 0) { iRet = -EIO; goto Exit; } if ((LocalObject.m_pData == NULL) || (LocalObject.m_uiSize == 0)) { iRet = (int) kEplApiInvalidParam; goto Exit; } pData = vmalloc(LocalObject.m_uiSize); if (pData == NULL) { // no memory available iRet = -ENOMEM; goto Exit; } iErr = copy_from_user(pData, LocalObject.m_pData, LocalObject.m_uiSize); if (iErr != 0) { iRet = -EIO; goto Exit; } EplRet = EplApiWriteLocalObject(LocalObject.m_uiIndex, LocalObject.m_uiSubindex, pData, LocalObject.m_uiSize); vfree(pData); iRet = (int) EplRet; break; } case EPLLIN_CMD_READ_OBJECT: { tEplLinSdoObject SdoObject; void* pData; tEplLinSdoBufHeader* pBufHeader; tEplSdoComConHdl* pSdoComConHdl; iErr = copy_from_user(&SdoObject, (const void*)ulArg_p, sizeof (SdoObject)); if (iErr != 0) { iRet = -EIO; goto Exit; } if ((SdoObject.m_le_pData == NULL) || (SdoObject.m_uiSize == 0)) { iRet = (int) kEplApiInvalidParam; goto Exit; } pBufHeader = (tEplLinSdoBufHeader*) vmalloc(sizeof (tEplLinSdoBufHeader) + SdoObject.m_uiSize); if (pBufHeader == NULL) { // no memory available iRet = -ENOMEM; goto Exit; } // initiate temporary buffer pBufHeader->m_pUserArg = SdoObject.m_pUserArg; // original user argument pointer pBufHeader->m_pData = SdoObject.m_le_pData; // original data pointer from app pData = pBufHeader + sizeof (tEplLinSdoBufHeader); if (SdoObject.m_fValidSdoComConHdl != FALSE) { pSdoComConHdl = &SdoObject.m_SdoComConHdl; } else { pSdoComConHdl = NULL; } EplRet = EplApiReadObject(pSdoComConHdl, SdoObject.m_uiNodeId, SdoObject.m_uiIndex, SdoObject.m_uiSubindex, pData, &SdoObject.m_uiSize, SdoObject.m_SdoType, pBufHeader); // return actual SDO handle (SdoObject.m_SdoComConHdl) iErr = put_user(SdoObject.m_SdoComConHdl, (unsigned int*)(ulArg_p + (unsigned long)&SdoObject.m_SdoComConHdl - (unsigned long)&SdoObject)); if (iErr != 0) { iRet = -EIO; goto Exit; } if (EplRet == kEplSuccessful) { iErr = copy_to_user(SdoObject.m_le_pData, pData, SdoObject.m_uiSize); vfree(pBufHeader); if (iErr != 0) { iRet = -EIO; goto Exit; } // return actual size (SdoObject.m_uiSize) iErr = put_user(SdoObject.m_uiSize, (unsigned int*)(ulArg_p + (unsigned long)&SdoObject.m_uiSize - (unsigned long)&SdoObject)); if (iErr != 0) { iRet = -EIO; goto Exit; } } else if (EplRet != kEplApiTaskDeferred) { // error ocurred vfree(pBufHeader); if (iErr != 0) { iRet = -EIO; goto Exit; } } iRet = (int) EplRet; break; } case EPLLIN_CMD_WRITE_OBJECT: { tEplLinSdoObject SdoObject; void* pData; tEplLinSdoBufHeader* pBufHeader; tEplSdoComConHdl* pSdoComConHdl; iErr = copy_from_user(&SdoObject, (const void*)ulArg_p, sizeof (SdoObject)); if (iErr != 0) { iRet = -EIO; goto Exit; } if ((SdoObject.m_le_pData == NULL) || (SdoObject.m_uiSize == 0)) { iRet = (int) kEplApiInvalidParam; goto Exit; } pBufHeader = (tEplLinSdoBufHeader*) vmalloc(sizeof (tEplLinSdoBufHeader) + SdoObject.m_uiSize); if (pBufHeader == NULL) { // no memory available iRet = -ENOMEM; goto Exit; } // initiate temporary buffer pBufHeader->m_pUserArg = SdoObject.m_pUserArg; // original user argument pointer pBufHeader->m_pData = SdoObject.m_le_pData; // original data pointer from app pData = pBufHeader + sizeof (tEplLinSdoBufHeader); iErr = copy_from_user(pData, SdoObject.m_le_pData, SdoObject.m_uiSize); if (iErr != 0) { iRet = -EIO; goto Exit; } if (SdoObject.m_fValidSdoComConHdl != FALSE) { pSdoComConHdl = &SdoObject.m_SdoComConHdl; } else { pSdoComConHdl = NULL; } EplRet = EplApiWriteObject(pSdoComConHdl, SdoObject.m_uiNodeId, SdoObject.m_uiIndex, SdoObject.m_uiSubindex, pData, SdoObject.m_uiSize, SdoObject.m_SdoType, pBufHeader); // return actual SDO handle (SdoObject.m_SdoComConHdl) iErr = put_user(SdoObject.m_SdoComConHdl, (unsigned int*)(ulArg_p + (unsigned long)&SdoObject.m_SdoComConHdl - (unsigned long)&SdoObject)); if (iErr != 0) { iRet = -EIO; goto Exit; } if (EplRet != kEplApiTaskDeferred) { // succeeded or error ocurred, but task not deferred vfree(pBufHeader); } iRet = (int) EplRet; break; } // ---------------------------------------------------------- case EPLLIN_CMD_FREE_SDO_CHANNEL: { // forward SDO handle to EPL stack EplRet = EplApiFreeSdoChannel((tEplSdoComConHdl)ulArg_p); iRet = (int) EplRet; break; } #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0) // ---------------------------------------------------------- case EPLLIN_CMD_MN_TRIGGER_STATE_CHANGE: { tEplLinNodeCmdObject NodeCmdObject; iErr = copy_from_user(&NodeCmdObject, (const void*)ulArg_p, sizeof (NodeCmdObject)); if (iErr != 0) { iRet = -EIO; goto Exit; } EplRet = EplApiMnTriggerStateChange(NodeCmdObject.m_uiNodeId, NodeCmdObject.m_NodeCommand); iRet = (int) EplRet; break; } #endif // ---------------------------------------------------------- case EPLLIN_CMD_GET_EVENT: { tEplLinEvent Event; // save event structure iErr = copy_from_user(&Event, (const void*)ulArg_p, sizeof (Event)); if (iErr != 0) { iRet = -EIO; goto Exit; } // save return code from application's event callback function RetCbEvent_g = Event.m_RetCbEvent; if (RetCbEvent_g == kEplShutdown) { // pass control to event queue kernel thread, but signal termination atomic_set(&AtomicEventState_g, EVENT_STATE_TERM); wake_up_interruptible(&WaitQueueCbEvent_g); // exit with error -> EplApiProcess() will leave the infinite loop TRACE0("EPL: EPLLIN_CMD_GET_EVENT set term\n"); iRet = 1; goto Exit; } // pass control to event queue kernel thread atomic_set(&AtomicEventState_g, EVENT_STATE_IOCTL); wake_up_interruptible(&WaitQueueCbEvent_g); // fall asleep itself in own wait queue iErr = wait_event_interruptible(WaitQueueProcess_g, (atomic_read(&AtomicEventState_g) != EVENT_STATE_IOCTL)); if (iErr != 0) { // waiting was interrupted by signal // pass control to event queue kernel thread, but signal termination atomic_set(&AtomicEventState_g, EVENT_STATE_TERM); wake_up_interruptible(&WaitQueueCbEvent_g); // exit with this error -> EplApiProcess() will leave the infinite loop TRACE1("EPL: EPLLIN_CMD_GET_EVENT iErr=%d\n",iErr); iRet = iErr; goto Exit; } else if (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM) { // termination in progress // pass control to event queue kernel thread, but signal termination wake_up_interruptible(&WaitQueueCbEvent_g); // exit with this error -> EplApiProcess() will leave the infinite loop TRACE0("EPL: EPLLIN_CMD_GET_EVENT term is set\n"); iRet = 1; goto Exit; } // copy event to user space iErr = copy_to_user(Event.m_pEventType, &EventType_g, sizeof (EventType_g)); if (iErr != 0) { // not all data could be copied iRet = -EIO; goto Exit; } // $$$ d.k. perform SDO event processing if (EventType_g == kEplApiEventSdo) { void* pData; tEplLinSdoBufHeader* pBufHeader; pBufHeader = (tEplLinSdoBufHeader*) pEventArg_g->m_Sdo.m_pUserArg; pData = pBufHeader + sizeof (tEplLinSdoBufHeader); if (pEventArg_g->m_Sdo.m_SdoAccessType == kEplSdoAccessTypeRead) { // copy read data to user space iErr = copy_to_user(pBufHeader->m_pData, pData, pEventArg_g->m_Sdo.m_uiTransferredByte); if (iErr != 0) { // not all data could be copied iRet = -EIO; goto Exit; } } pEventArg_g->m_Sdo.m_pUserArg = pBufHeader->m_pUserArg; vfree(pBufHeader); } iErr = copy_to_user(Event.m_pEventArg, pEventArg_g, min(sizeof (tEplApiEventArg), Event.m_uiEventArgSize)); if (iErr != 0) { // not all data could be copied iRet = -EIO; goto Exit; } // return to EplApiProcess(), which will call the application's event callback function iRet = 0; break; } // ---------------------------------------------------------- case EPLLIN_CMD_PI_SETUP: { EplRet = EplApiProcessImageSetup(); iRet = (int) EplRet; break; } // ---------------------------------------------------------- case EPLLIN_CMD_PI_IN: { tEplApiProcessImage ProcessImageIn; // save process image structure iErr = copy_from_user(&ProcessImageIn, (const void*)ulArg_p, sizeof (ProcessImageIn)); if (iErr != 0) { iRet = -EIO; goto Exit; } if (atomic_read(&AtomicSyncState_g) == EVENT_STATE_READY) { // EplApiProcessImageExchangeIn called twice without calling EplApiProcessImageExchangeOut in between iRet = (int) kEplInvalidOperation; goto Exit; } // pass control to event queue kernel thread atomic_set(&AtomicSyncState_g, EVENT_STATE_IOCTL); // fall asleep itself in own wait queue iErr = wait_event_interruptible(WaitQueuePI_In_g, (atomic_read(&AtomicSyncState_g) != EVENT_STATE_IOCTL)); if (iErr != 0) { // waiting was interrupted by signal // pass control to sync kernel thread, but signal termination atomic_set(&AtomicSyncState_g, EVENT_STATE_TERM); wake_up_interruptible(&WaitQueueCbSync_g); // exit with this error -> application will leave the infinite loop TRACE1("EPL: EPLLIN_CMD_PI_IN iErr=%d\n", iErr); iRet = iErr; goto Exit; } else if (atomic_read(&AtomicSyncState_g) == EVENT_STATE_TERM) { // termination in progress // pass control to sync kernel thread, but signal termination wake_up_interruptible(&WaitQueueCbSync_g); // exit with this error -> application will leave the infinite loop TRACE0("EPL: EPLLIN_CMD_PI_IN TERM is set\n"); iRet = 1; goto Exit; } // exchange process image EplRet = EplApiProcessImageExchangeIn(&ProcessImageIn); // return to EplApiProcessImageExchangeIn() iRet = (int) EplRet; break; } // ---------------------------------------------------------- case EPLLIN_CMD_PI_OUT: { tEplApiProcessImage ProcessImageOut; // save process image structure iErr = copy_from_user(&ProcessImageOut, (const void*)ulArg_p, sizeof (ProcessImageOut)); if (iErr != 0) { iRet = -EIO; goto Exit; } if (atomic_read(&AtomicSyncState_g) != EVENT_STATE_READY) { iRet = (int) kEplInvalidOperation; goto Exit; } // exchange process image EplRet = EplApiProcessImageExchangeOut(&ProcessImageOut); // pass control to sync kernel thread atomic_set(&AtomicSyncState_g, EVENT_STATE_IOCTL); wake_up_interruptible(&WaitQueueCbSync_g); // return to EplApiProcessImageExchangeout() iRet = (int) EplRet; break; } // ---------------------------------------------------------- case EPLLIN_CMD_NMT_COMMAND: { // forward NMT command to EPL stack EplRet = EplApiExecNmtCommand((tEplNmtEvent)ulArg_p); iRet = (int) EplRet; break; } // ---------------------------------------------------------- case EPLLIN_CMD_POST_USER_EVENT: { // post user event EplRet = EplApiPostUserEvent((void*)ulArg_p); iRet = (int) EplRet; break; } // ---------------------------------------------------------- default: { break; } } Exit: // TRACE1("EPL: - EplLinIoctl (iRet=%d)\n", iRet); return (iRet); }
tEplKernel PUBLIC EplLinCbEvent( tEplApiEventType EventType_p, // IN: event type (enum) tEplApiEventArg* pEventArg_p, // IN: event argument (union) void GENERIC* pUserArg_p) { tEplKernel EplRet = kEplSuccessful; int iErr; // block any further call to this function, i.e. enter critical section iErr = down_interruptible(&SemaphoreCbEvent_g); if (iErr != 0) { // waiting was interrupted by signal EplRet = kEplShutdown; goto Exit; } // wait for EplApiProcess() to call ioctl // normally it should be waiting already for us to pass a new event iErr = wait_event_interruptible(WaitQueueCbEvent_g, (atomic_read(&AtomicEventState_g) == EVENT_STATE_IOCTL) || (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM)); if ((iErr != 0) || (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM)) { // waiting was interrupted by signal EplRet = kEplShutdown; TRACE0("EPL: EplLinCbEvent() TERM is set while waiting for ioctl\n"); goto LeaveCriticalSection; } // save event information for ioctl EventType_g = EventType_p; pEventArg_g = pEventArg_p; // pass control to application's event callback function, i.e. EplApiProcess() atomic_set(&AtomicEventState_g, EVENT_STATE_READY); wake_up_interruptible(&WaitQueueProcess_g); // now, the application's event callback function processes the event // wait for completion of application's event callback function, i.e. EplApiProcess() calls ioctl again iErr = wait_event_interruptible(WaitQueueCbEvent_g, (atomic_read(&AtomicEventState_g) != EVENT_STATE_READY)); if ((iErr != 0) || (atomic_read(&AtomicEventState_g) == EVENT_STATE_TERM)) { // waiting was interrupted by signal EplRet = kEplShutdown; TRACE0("EPL: EplLinCbEvent() TERM is set while waiting for completion\n"); goto LeaveCriticalSection; } // read return code from application's event callback function EplRet = RetCbEvent_g; LeaveCriticalSection: up(&SemaphoreCbEvent_g); Exit: // check if NMT_GS_OFF is reached if (EventType_p == kEplApiEventNmtStateChange) { if (pEventArg_p->m_NmtStateChange.m_NewNmtState == kEplNmtGsOff) { // NMT state machine was shut down TRACE0("EPL: EplLinCbEvent(NMT_GS_OFF)\n"); uiEplState_g = EPL_STATE_SHUTDOWN; // atomic_set(&AtomicEventState_g, EVENT_STATE_TERM); // wake_up_interruptible(&WaitQueueProcess_g); wake_up(&WaitQueueRelease_g); } else { // NMT state machine is running uiEplState_g = EPL_STATE_RUNNING; } } return EplRet; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) return -1; BOOL bNameValid; // 基于持久值设置视觉管理器和样式 OnApplicationLook(theApp.m_nAppLook); CMDITabInfo mdiTabParams; mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_VS2005; // 其他可用样式... mdiTabParams.m_bActiveTabCloseButton = TRUE; // 设置为 FALSE 会将关闭按钮放置在选项卡区域的右侧 mdiTabParams.m_bTabIcons = FALSE; // 设置为 TRUE 将在 MDI 选项卡上启用文档图标 mdiTabParams.m_bAutoColor = FALSE; // 设置为 FALSE 将禁用 MDI 选项卡的自动着色 mdiTabParams.m_bDocumentMenu = TRUE; // 在选项卡区域的右边缘启用文档菜单 mdiTabParams.m_bEnableTabSwap = TRUE; //启用选项卡交换 mdiTabParams.m_bTabCustomTooltips = TRUE; EnableMDITabbedGroups(TRUE, mdiTabParams); if (!m_wndMenuBar.Create(this)) { TRACE0("未能创建菜单栏\n"); return -1; // 未能创建 } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); //取消首先显示最近使用的命令 CMFCMenuBar::SetRecentlyUsedMenus(FALSE); // 防止菜单栏在激活时获得焦点 CMFCPopupMenu::SetForceMenuFocus(FALSE); if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_HC : IDR_MAINFRAME)) { TRACE0("未能创建工具栏\n"); return -1; // 未能创建 } // Create FormEdit toolbar if (!m_wndToolbarFormEdit.Create(this, WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC| CBRS_GRIPPER | CBRS_BORDER_3D, ID_VIEW_FORMEDIT_TOOLBAR) || !m_wndToolbarFormEdit.LoadToolBar(IDR_FORMEDIT)) { TRACE0("未能创建窗口编辑工具栏\n"); return FALSE; // 未能创建 } CString strToolBarName; bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); ASSERT(bNameValid); m_wndToolBar.SetWindowText(strToolBarName); CString strCustomize; bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); ASSERT(bNameValid); m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); CString strFormEditToolBarName; bNameValid = strFormEditToolBarName.LoadString(IDS_TOOLBAR_FORMEDIT); ASSERT(bNameValid); m_wndToolbarFormEdit.SetWindowText(strFormEditToolBarName); m_wndToolbarFormEdit.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); // 允许用户定义的工具栏操作: InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId); if (!m_wndStatusBar.Create(this)) { TRACE0("未能创建状态栏\n"); return -1; // 未能创建 } m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolbarFormEdit.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndMenuBar); DockPane(&m_wndToolBar); DockPane(&m_wndToolbarFormEdit); DockPaneLeftOf(&m_wndToolBar, &m_wndToolbarFormEdit); // 启用 Visual Studio 2005 样式停靠窗口行为 CDockingManager::SetDockingMode(DT_SMART); // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 EnableAutoHidePanes(CBRS_ALIGN_ANY); // 加载菜单项图像(不在任何标准工具栏上): CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); // 创建停靠窗口 if (!CreateDockingWindows()) { TRACE0("未能创建停靠窗口\n"); return -1; } m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); m_wndResourceView.EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndFileView); CDockablePane* pTabbedBar = NULL; m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); m_wndResourceView.AttachToTabWnd(pTabbedBar, DM_SHOW, TRUE, &pTabbedBar); m_wndProperties.EnableDocking(CBRS_ALIGN_RIGHT); m_wndToolBox.EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndProperties); DockPane(&m_wndToolBox); // 启用增强的窗口管理对话框 EnableWindowsDialog(ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); // 启用工具栏和停靠窗口菜单替换 EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR, FALSE, TRUE); // 启用快速(按住 Alt 拖动)工具栏自定义 CMFCToolBar::EnableQuickCustomization(); if (CMFCToolBar::GetUserImages() == NULL) { // 加载用户定义的工具栏图像 if (m_UserImages.Load(_T(".\\UserImages.bmp"))) { m_UserImages.SetImageSize(CSize(16, 16), FALSE); CMFCToolBar::SetUserImages(&m_UserImages); } } // 启用菜单个性化(最近使用的命令) // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail(ID_FILE_NEW); lstBasicCommands.AddTail(ID_FILE_OPEN); lstBasicCommands.AddTail(ID_FILE_SAVE); lstBasicCommands.AddTail(ID_FILE_PRINT); lstBasicCommands.AddTail(ID_APP_EXIT); lstBasicCommands.AddTail(ID_EDIT_CUT); lstBasicCommands.AddTail(ID_EDIT_PASTE); lstBasicCommands.AddTail(ID_EDIT_UNDO); lstBasicCommands.AddTail(ID_APP_ABOUT); lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); CMFCToolBar::SetBasicCommands(lstBasicCommands); return 0; }
/* * Send one RTM_NEWADDR message for each IPv4 address we've found * in the binding message. We ignore pbind->RemoteAddress for now. * * XXX: This does not work like BSD's notifications; again, if we * wish to send changes, like routes, we need to maintain state, * as the RTMv2 APIs send the entire state of the interface's * address list each time. * * For this reason it's probably better to use IP Helper as * the means of interface information discovery (with * GetAdaptersAddresses()). */ int rtm_newaddr(DWORD ifindex, #ifdef IPV6_DLL PIPV6_ADAPTER_BINDING_INFO pbind #else PIP_ADAPTER_BINDING_INFO pbind #endif ) { static const msgsize = sizeof(struct ifa_msghdr) + (sizeof(sockunion_t) * 2); struct ifa_msghdr *ifam; sockunion_t *sa; sockunion_t *sa2; int i; int result; int retval; TRACE2(ENTER, "Entering rtm_newaddr %d %p", ifindex, pbind); retval = -1; ifam = NULL; if (pbind == NULL) goto out; if (pbind->AddressCount == 0) goto out; ifam = malloc(sizeof(*ifam)); if (ifam == NULL) goto out; sa = (sockunion_t *)(ifam + 1); sa2 = (sa + 1); for (i = 0; i < pbind->AddressCount; i++) { ifam->ifam_msglen = msgsize; ifam->ifam_version = RTM_VERSION; ifam->ifam_type = RTM_NEWADDR; ifam->ifam_addrs = RTA_DST | RTA_NETMASK; ifam->ifam_flags = 0; ifam->ifam_index = ifindex; ifam->ifam_metric = 0; #ifdef IPV6_DLL sa->sin6.sin6_family = AF_INET6; sa->sin6.sin6_addr.s_addr = pbind->Address[i].Address; sa2->sin6.sin6_family = AF_INET6; sa2->sin6.sin6_addr.s_addr = pbind->Address[i].Mask; #else sa->sin.sin_family = AF_INET; sa->sin.sin_addr.s_addr = pbind->Address[i].Address; sa2->sin.sin_family = AF_INET; sa2->sin.sin_addr.s_addr = pbind->Address[i].Mask; #endif broadcast_pipe_message(ifam, msgsize); } retval = 0; out: if (ifam != NULL) free(ifam); TRACE0(ENTER, "Leaving rtm_newaddr"); return (retval); }
TxtrCacheEntry * CTextureManager::GetTexture(TxtrInfo * pgti, bool fromTMEM, bool doCRCCheck, bool AutoExtendTexture) { TxtrCacheEntry *pEntry; if( g_curRomInfo.bDisableTextureCRC ) doCRCCheck = false; gRDP.texturesAreReloaded = true; dwAsmCRC = 0; uint32_t dwPalCRC = 0; pEntry = GetTxtrCacheEntry(pgti); bool loadFromTextureBuffer=false; int txtBufIdxToLoadFrom = -1; if( (frameBufferOptions.bCheckRenderTextures&&!frameBufferOptions.bWriteBackBufToRDRAM) || (frameBufferOptions.bCheckBackBufs&&!frameBufferOptions.bWriteBackBufToRDRAM) ) { txtBufIdxToLoadFrom = g_pFrameBufferManager->CheckAddrInRenderTextures(pgti->Address, true); if( txtBufIdxToLoadFrom >= 0 ) { loadFromTextureBuffer = true; // Check if it is the same size, RenderTextureInfo &info = gRenderTextureInfos[txtBufIdxToLoadFrom]; //if( info.pRenderTexture && info.CI_Info.dwAddr == pgti->Address && info.CI_Info.dwFormat == pgti->Format if( info.pRenderTexture && info.CI_Info.dwFormat == pgti->Format && info.CI_Info.dwSize == pgti->Size ) { info.txtEntry.ti = *pgti; return &info.txtEntry; } } } if (frameBufferOptions.bCheckBackBufs && g_pFrameBufferManager->CheckAddrInBackBuffers(pgti->Address, pgti->HeightToLoad*pgti->Pitch, false) >= 0) { if( !frameBufferOptions.bWriteBackBufToRDRAM ) { // Load the texture from recent back buffer txtBufIdxToLoadFrom = g_pFrameBufferManager->CheckAddrInRenderTextures(pgti->Address, true); if( txtBufIdxToLoadFrom >= 0 ) { loadFromTextureBuffer = true; // Check if it is the same size, RenderTextureInfo &info = gRenderTextureInfos[txtBufIdxToLoadFrom]; //if( info.pRenderTexture && info.CI_Info.dwAddr == pgti->Address && info.CI_Info.dwFormat == pgti->Format if( info.pRenderTexture && info.CI_Info.dwFormat == pgti->Format && info.CI_Info.dwSize == pgti->Size ) { info.txtEntry.ti = *pgti; return &info.txtEntry; } } } } if (pEntry && pEntry->dwTimeLastUsed == status.gRDPTime && status.gDlistCount != 0 && !status.bN64FrameBufferIsUsed ) // This is not good, Palatte may changes { // We've already calculated a CRC this frame! dwAsmCRC = pEntry->dwCRC; } else { if ( doCRCCheck ) { if( loadFromTextureBuffer ) dwAsmCRC = gRenderTextureInfos[txtBufIdxToLoadFrom].crcInRDRAM; else CalculateRDRAMCRC(pgti->pPhysicalAddress, pgti->LeftToLoad, pgti->TopToLoad, pgti->WidthToLoad, pgti->HeightToLoad, pgti->Size, pgti->Pitch); } } int maxCI = 0; if ( doCRCCheck && (pgti->Format == TXT_FMT_CI || (pgti->Format == TXT_FMT_RGBA && pgti->Size <= TXT_SIZE_8b ))) { //maxCI = pgti->Size == TXT_SIZE_8b ? 255 : 15; extern unsigned char CalculateMaxCI(void *pPhysicalAddress, uint32_t left, uint32_t top, uint32_t width, uint32_t height, uint32_t size, uint32_t pitchInBytes ); if( !pEntry || pEntry->dwCRC != dwAsmCRC || pEntry->maxCI < 0 ) { maxCI = CalculateMaxCI(pgti->pPhysicalAddress, pgti->LeftToLoad, pgti->TopToLoad, pgti->WidthToLoad, pgti->HeightToLoad, pgti->Size, pgti->Pitch); } else { maxCI = pEntry->maxCI; } //Check PAL CRC uint8_t * pStart; uint32_t dwPalSize = 16; uint32_t dwOffset; if( pgti->Size == TXT_SIZE_8b ) { dwPalSize = 256; dwOffset = 0; } else { dwOffset = pgti->Palette << 4; } pStart = (uint8_t*)pgti->PalAddress+dwOffset*2; //uint32_t y; //for (y = 0; y < dwPalSize*2; y+=4) //{ // dwPalCRC = (dwPalCRC + *(uint32_t*)&pStart[y]); //} uint32_t dwAsmCRCSave = dwAsmCRC; //dwPalCRC = CalculateRDRAMCRC(pStart, 0, 0, dwPalSize, 1, TXT_SIZE_16b, dwPalSize*2); dwPalCRC = CalculateRDRAMCRC(pStart, 0, 0, maxCI+1, 1, TXT_SIZE_16b, dwPalSize*2); dwAsmCRC = dwAsmCRCSave; } if (pEntry && doCRCCheck ) { if(pEntry->dwCRC == dwAsmCRC && pEntry->dwPalCRC == dwPalCRC && (!loadFromTextureBuffer || gRenderTextureInfos[txtBufIdxToLoadFrom].updateAtFrame < pEntry->FrameLastUsed ) ) { // Tile is ok, return pEntry->dwUses++; pEntry->dwTimeLastUsed = status.gRDPTime; pEntry->FrameLastUsed = status.gDlistCount; LOG_TEXTURE(TRACE0(" Use current texture:\n")); pEntry->lastEntry = g_lastTextureEntry; g_lastTextureEntry = pEntry; lastEntryModified = false; DEBUGGER_IF_DUMP((pauseAtNext && loadFromTextureBuffer) , {DebuggerAppendMsg("Load cached texture from render_texture");} );
/* * Create a new instance of a pipe and return a pointer to * its instance structure. */ pipe_instance_t * pipe_new(void) { pipe_instance_t *npp; int failed; DWORD result; TRACE0(ENTER, "Entering pipe_new"); npp = malloc(sizeof(*npp)); if (npp == NULL) return NULL; ZeroMemory(npp, sizeof(*npp)); failed = 1; /* XXX buffer management */ npp->rsize = PIPE_READBUF_SIZE; npp->state = PIPE_STATE_INIT; InitializeCriticalSection(&npp->rcs); /* * Create the event object used to signal connection completion. */ npp->cevent = CreateEvent(NULL, FALSE, FALSE, NULL); if (npp->cevent == NULL) { result = GetLastError(); TRACE1(CONFIGURATION, "Error %u creating event", result); goto fail; } npp->cov.hEvent = npp->cevent; /* * Create the event object used to signal read completion. */ npp->revent = CreateEvent(NULL, FALSE, FALSE, NULL); if (npp->revent == NULL) { result = GetLastError(); TRACE1(CONFIGURATION, "Error %u creating event", result); goto fail; } npp->rov.hEvent = npp->revent; /* * Create the instance of the named pipe itself. */ npp->pipe = CreateNamedPipeA(XORPRTM_PIPENAME, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, PIPE_TYPE_MESSAGE, PIPE_INSTANCES, 0, 0, XORPRTM_PIPETIMEOUT, NULL); if (npp->pipe == NULL) { result = GetLastError(); TRACE1(CONFIGURATION, "Error %u creating named pipe", result); goto fail; } failed = 0; fail: if (failed) { pipe_destroy(npp); npp = NULL; } TRACE1(ENTER, "Leaving pipe_new %p", npp); return (npp); }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) return -1; BOOL bNameValid; // set the visual manager and style based on persisted value OnApplicationLook(theApp.m_nAppLook); CMDITabInfo mdiTabParams; mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; // other styles available... mdiTabParams.m_bActiveTabCloseButton = TRUE; // set to FALSE to place close button at right of tab area mdiTabParams.m_bTabIcons = FALSE; // set to TRUE to enable document icons on MDI taba mdiTabParams.m_bAutoColor = TRUE; // set to FALSE to disable auto-coloring of MDI tabs mdiTabParams.m_bDocumentMenu = TRUE; // enable the document menu at the right edge of the tab area EnableMDITabbedGroups(TRUE, mdiTabParams); if (!m_wndMenuBar.Create(this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); // prevent the menu bar from taking the focus on activation CMFCPopupMenu::SetForceMenuFocus(FALSE); if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } CString strToolBarName; bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); ASSERT(bNameValid); m_wndToolBar.SetWindowText(strToolBarName); CString strCustomize; bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); ASSERT(bNameValid); m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); // Allow user-defined toolbars operations: InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId); if (!m_wndStatusBar.Create(this)) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); // TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndMenuBar); DockPane(&m_wndToolBar); // enable Visual Studio 2005 style docking window behavior CDockingManager::SetDockingMode(DT_SMART); // enable Visual Studio 2005 style docking window auto-hide behavior EnableAutoHidePanes(CBRS_ALIGN_ANY); // Load menu item image (not placed on any standard toolbars): CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); // create docking windows if (!CreateDockingWindows()) { TRACE0("Failed to create docking windows\n"); return -1; } m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndFileView); CDockablePane* pTabbedBar = NULL; m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndOutput); m_wndProperties.EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndProperties); // Enable enhanced windows management dialog EnableWindowsDialog(ID_WINDOW_MANAGER, ID_WINDOW_MANAGER, TRUE); // Enable toolbar and docking window menu replacement EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); // enable quick (Alt+drag) toolbar customization CMFCToolBar::EnableQuickCustomization(); if (CMFCToolBar::GetUserImages() == NULL) { // load user-defined toolbar images if (m_UserImages.Load(_T(".\\UserImages.bmp"))) { CMFCToolBar::SetUserImages(&m_UserImages); } } // enable menu personalization (most-recently used commands) // TODO: define your own basic commands, ensuring that each pulldown menu has at least one basic command. CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail(ID_FILE_NEW); lstBasicCommands.AddTail(ID_FILE_OPEN); lstBasicCommands.AddTail(ID_FILE_SAVE); lstBasicCommands.AddTail(ID_FILE_PRINT); lstBasicCommands.AddTail(ID_APP_EXIT); lstBasicCommands.AddTail(ID_EDIT_CUT); lstBasicCommands.AddTail(ID_EDIT_PASTE); lstBasicCommands.AddTail(ID_EDIT_UNDO); lstBasicCommands.AddTail(ID_APP_ABOUT); lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); CMFCToolBar::SetBasicCommands(lstBasicCommands); // Switch the order of document name and application name on the window title bar. This // improves the usability of the taskbar because the document name is visible with the thumbnail. ModifyStyle(0, FWS_PREFIXTITLE); return 0; }
/* * XXX: This must be called from primary thread, or lock held if not! */ int pipe_listen(pipe_instance_t *pp) { int retval; DWORD result; retval = -1; TRACE1(ENTER, "Entering pipe_listen %p", pp); if (pp == NULL || pp->state != PIPE_STATE_INIT) return (retval); /* * Register a pool thread to wait for pipe connection. * Clear event state to avoid spurious signals. */ ResetEvent(pp->cevent); result = RegisterWaitForSingleObject(&(pp->cwait), pp->cevent, pipe_connect_cb, pp, INFINITE, WT_EXECUTEINIOTHREAD | WT_EXECUTEONLYONCE); if (result == 0) { result = GetLastError(); TRACE1(CONFIGURATION, "Error %u RegisterWaitForSingleObject()", result); goto fail; } /* * Register a pool thread to wait for data to be received on the pipe. * We don't cause this to be activated until we post a read request * from within the connection callback. * XXX: We want the read callback to be called whenever the * object is signalled, not just once. */ ResetEvent(pp->revent); result = RegisterWaitForSingleObject(&(pp->rwait), pp->revent, pipe_read_cb, pp, INFINITE, WT_EXECUTEINIOTHREAD | WT_EXECUTEONLYONCE); if (result == 0) { result = GetLastError(); TRACE1(CONFIGURATION, "Error %u RegisterWaitForSingleObject()", result); goto fail; } /* * Post the connection request. If it returns non-zero, then the * connection attempt is pending and the thread will be signalled * when complete. If it returns zero, then there's a problem. * ERROR_NO_DATA means the client disconnected, but we didn't * call DisconnectNamedPipe(). * ConnectNamedPipe() does not reset the event object associated * with the OVERLAPPED parameter. */ result = ConnectNamedPipe(pp->pipe, &pp->cov); if (result == 0) { result = GetLastError(); if (result == ERROR_PIPE_LISTENING) { TRACE0(NETWORK, "Error: listening; Reconnecting named pipe"); result = ConnectNamedPipe(pp->pipe, &pp->cov); } if (result == ERROR_PIPE_CONNECTED) { TRACE0(NETWORK, "Error: named pipe already connected"); goto fail; } if (result == ERROR_NO_DATA) { TRACE0(NETWORK, "Error: previous session not cleaned up"); goto fail; } } pp->state = PIPE_STATE_LISTEN; retval = 0; fail: if (retval == -1) { if (pp->cwait != NULL) { UnregisterWaitEx(pp->cwait, pp->cevent); ResetEvent(pp->cevent); pp->cwait = NULL; } if (pp->rwait != NULL) { UnregisterWaitEx(pp->rwait, pp->revent); ResetEvent(pp->revent); pp->rwait = NULL; } } TRACE1(ENTER, "Leaving pipe_listen", pp); return (retval); }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) return -1; BOOL bNameValid; // set the visual manager and style based on persisted value OnApplicationLook(theApp.m_nAppLook); if (!m_wndMenuBar.Create(this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); // prevent the menu bar from taking the focus on activation CMFCPopupMenu::SetForceMenuFocus(FALSE); if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } CString strToolBarName; bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); ASSERT(bNameValid); m_wndToolBar.SetWindowText(strToolBarName); CString strCustomize; bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); ASSERT(bNameValid); m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); // Allow user-defined toolbars operations: InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId); if (!m_wndStatusBar.Create(this)) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); // TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndMenuBar); DockPane(&m_wndToolBar); // enable Visual Studio 2005 style docking window behavior CDockingManager::SetDockingMode(DT_SMART); // enable Visual Studio 2005 style docking window auto-hide behavior EnableAutoHidePanes(CBRS_ALIGN_ANY); // Enable toolbar and docking window menu replacement EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); // enable quick (Alt+drag) toolbar customization CMFCToolBar::EnableQuickCustomization(); if (CMFCToolBar::GetUserImages() == NULL) { // load user-defined toolbar images if (m_UserImages.Load(_T(".\\UserImages.bmp"))) { CMFCToolBar::SetUserImages(&m_UserImages); } } // enable menu personalization (most-recently used commands) // TODO: define your own basic commands, ensuring that each pulldown menu has at least one basic command. CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail(ID_FILE_NEW); lstBasicCommands.AddTail(ID_FILE_OPEN); lstBasicCommands.AddTail(ID_FILE_SAVE); lstBasicCommands.AddTail(ID_FILE_PRINT); lstBasicCommands.AddTail(ID_APP_EXIT); lstBasicCommands.AddTail(ID_EDIT_CUT); lstBasicCommands.AddTail(ID_EDIT_PASTE); lstBasicCommands.AddTail(ID_EDIT_UNDO); lstBasicCommands.AddTail(ID_APP_ABOUT); lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7); CMFCToolBar::SetBasicCommands(lstBasicCommands); return 0; }
/* * Issue a routing socket message for a single changed destination. */ DWORD rtm_send_dest_change(RTM_ENTITY_HANDLE reh, PRTM_DEST_INFO prdi) { #ifdef IPV6_DLL struct in6_addr dst; struct in6_addr ip; struct in6_addr nhip; #else struct in_addr dst; struct in_addr ip; struct in_addr nhip; #endif int i; int dstprefix; int nhprefix; int type; DWORD result; if (!prdi) return NO_ERROR; TRACE1(NETWORK, "RtmDestInfo Destination %p", prdi); #ifdef IPV6_DLL RTM_IPV6_GET_ADDR_AND_LEN(dst.s6_addr, dstprefix, &prdi->DestAddress); #else RTM_IPV4_GET_ADDR_AND_LEN(dst.s_addr, dstprefix, &prdi->DestAddress); #endif /* * Determine the nature of the change; whether a route has * been added, changed or deleted for the given situation. * We look only at the unicast routing view. */ for (i = 0; i < prdi->NumberOfViews; i++) { if (prdi->ViewInfo[i].ViewId == RTM_VIEW_ID_UCAST) { #ifdef IPV6_DLL /* * XXX: Don't filter IPv6 routes [yet]. */ #else /* IPv4 */ /* * Ignore routes to the all-ones broadcast destination. */ if ((dst.s_addr == INADDR_BROADCAST && dstprefix == 32)) { TRACE0(NETWORK, "ignoring all-ones broadcast"); break; } #ifdef notyet /* * XXX: Ignore multicast routes (for now). */ if (IN4_IS_ADDR_MULTICAST(dst.s_addr)) { TRACE0(NETWORK, "ignoring multicast route"); break; } #endif /* notyet */ #endif /* IPV6_DLL */ if (prdi->ViewInfo[i].NumRoutes == 0) { TRACE0(NETWORK, "route deleted"); type = RTM_DELETE; } else if (prdi->ViewInfo[i].NumRoutes == 1) { TRACE0(NETWORK, "route added"); type = RTM_ADD; } else { /* * XXX: The route has multiple next-hops. We do not know * which next-hop we should send to the FEA, so do not * process such changes for now. */ TRACE1(NETWORK, "route change, dest %d nexthops, no msg", prdi->ViewInfo[i].NumRoutes); type = 0; } break; /* stop when unicast route view is dealt with. */ } } /* * Craft a routing socket message based on the changes. * We only allocate memory here if we require it. */ if (type != 0) { sockunion_t *sa; struct rt_msghdr *rtm; #ifdef IPV6_DLL struct in6_addr nh; #else struct in_addr nh; #endif int maxmsgsize; maxmsgsize = sizeof(struct rt_msghdr) + (sizeof(sockunion_t) * 3); rtm = malloc(maxmsgsize); ZeroMemory(rtm, maxmsgsize); sa = (sockunion_t *)(rtm + 1); rtm->rtm_msglen = maxmsgsize - sizeof(*sa); rtm->rtm_version = RTM_VERSION; rtm->rtm_type = type; rtm->rtm_addrs = RTA_DST | RTA_NETMASK; /* Destination */ #ifdef IPV6_DLL sa->sin6.sin6_family = AF_INET6; sa->sin6.sin6_addr = dst; #else sa->sin.sin_family = AF_INET; sa->sin.sin_addr = dst; #endif /* * Route additions require that we also report the next-hop. * Perform the necessary RTMv2 incantations to look up the * next-hop from the destination reported as changed. * XXX: Better error checking here considered desirable. */ if (type == RTM_ADD) { PRTM_ROUTE_INFO prri; RTM_NEXTHOP_INFO nhi; rtm->rtm_msglen += sizeof(*sa); rtm->rtm_addrs |= RTA_GATEWAY; /* XXX weird heap malloc. */ MALLOC(&prri, RTM_SIZE_OF_ROUTE_INFO(g_ce.rrpRtmProfile.MaxNextHopsInRoute), &result); result = RtmGetRouteInfo(reh, prdi->ViewInfo[i].Route, prri, NULL); if (result != NO_ERROR) { TRACE1(NETWORK, "RtmGetRouteInfo() returns %d", result); } result = RtmGetNextHopInfo(reh, prri->NextHopsList.NextHops[0], &nhi); if (result != NO_ERROR) { TRACE1(ANY, "Error %u getting next hop", result); } /* Gateway */ #ifdef IPV6_DLL RTM_IPV6_GET_ADDR_AND_LEN(nhip.s6_addr, nhprefix, &nhi.NextHopAddress); ++sa; sa->sin6.sin6_family = AF_INET6; sa->sin6.sin6_addr = nhip; #else RTM_IPV4_GET_ADDR_AND_LEN(nhip.s_addr, nhprefix, &nhi.NextHopAddress); ++sa; sa->sin.sin_family = AF_INET; sa->sin.sin_addr = nhip; #endif /* IPV6_DLL */ /* * Free the next-hop info structures. */ (void)RtmReleaseNextHopInfo(reh, &nhi); (void)RtmReleaseRouteInfo(reh, prri); FREE(prri); } /* Netmask; comes after gateway in the RTM_ADD case. */ ++sa; #ifdef IPV6_DLL /* XXX: may not be right */ sa->sin6.sin6_family = AF_INET; sa->sin6.sin6_addr.s6_addr = RTM_IPV6_MASK_FROM_LEN(dstprefix); #else sa->sin.sin_family = AF_INET; sa->sin.sin_addr.s_addr = RTM_IPV4_MASK_FROM_LEN(dstprefix); #endif broadcast_pipe_message(rtm, rtm->rtm_msglen); free(rtm); } return NO_ERROR; }
STDAPI DllCanUnloadNow(void) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); TRACE0("ScdIF : Calling AfxDllCanUnloadNow\n"); return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE; }
void WINAPI pipe_reread_cb(void *ctx) { pipe_instance_t *pp; DWORD result; int failed; pp = (pipe_instance_t *)ctx; EnterCriticalSection(&pp->rcs); TRACE1(ENTER, "Entering pipe_reread_cb %p", ctx); failed = 0; if (pp->state != PIPE_STATE_CONNECTED) { TRACE0(NETWORK, "WARNING: not PIPE_STATE_CONNECTED"); } /* * Tear down and wire up read thread callback again. * This is probably inefficient. */ UnregisterWaitEx(pp->rwait, pp->revent); ResetEvent(pp->revent); /* XXX ReadFile() should do this for us? */ pp->rwait = NULL; /* * Post a new read request. Deal with fatal errors. */ result = ReadFile(pp->pipe, pp->rbuf, pp->rsize, NULL, &pp->rov); if (result == 0) { result = GetLastError(); if (result != ERROR_IO_PENDING) { TRACE1(ANY, "WARNING: pipe_reread_cb read returned %d", result); } if (result == ERROR_BROKEN_PIPE) { failed = 1; goto fail; } } /* * Now, and only now, do we kick off the read thread, in order * to avoid being preempted if the client disconnects. */ result = RegisterWaitForSingleObject(&(pp->rwait), pp->revent, pipe_read_cb, pp, INFINITE, WT_EXECUTEINIOTHREAD | WT_EXECUTEONLYONCE); if (result == 0) { result = GetLastError(); TRACE1(CONFIGURATION, "Error %u RegisterWaitForSingleObject()", result); failed = 1; } fail: /* * If a fatal error occurred, disconnect the pipe client, and * listen for a new connection on this instance. */ if (failed) { ResetEvent(pp->revent); QueueUserWorkItem( (LPTHREAD_START_ROUTINE)pipe_relisten_cb, (PVOID)pp, WT_EXECUTEINIOTHREAD); } out: TRACE0(ENTER, "Leaving pipe_reread_cb"); LeaveCriticalSection(&pp->rcs); }
BOOL CTables :: Open (UINT nOpenType /* = snapshot */, LPCSTR lpszSQL /* = NULL */, DWORD dwOptions /* = none */) { #ifdef WIN32 ASSERT(lpszSQL == NULL); RETCODE nRetCode; // Cache state info and allocate hstmt SetState(nOpenType,NULL,noDirtyFieldCheck); if (!AllocHstmt()) return FALSE; TRY { OnSetOptions(m_hstmt); AllocStatusArrays(); // call the ODBC catalog function with data member params AFX_SQL_ASYNC(this, (::SQLTables)(m_hstmt, (m_strQualifierParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const char*)m_strQualifierParam), SQL_NTS, (m_strOwnerParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const char*)m_strOwnerParam), SQL_NTS, (m_strNameParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const char*)m_strNameParam), SQL_NTS, (m_strTypeParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const char*)m_strTypeParam), SQL_NTS)); if (!Check(nRetCode)) ThrowDBException(nRetCode, m_hstmt); // Allocate memory and cache info AllocAndCacheFieldInfo(); AllocRowset(); // Fetch the first row of data MoveNext(); // If EOF, result set is empty, set BOF as well m_bBOF = m_bEOF; } CATCH_ALL(e) { Close(); THROW_LAST(); } END_CATCH_ALL return TRUE; #else // WIN16 RETCODE nRetCode; ASSERT(lpszSQL == NULL); // Allocation and opening of database not supported if (m_hstmt == SQL_NULL_HSTMT) { CString strDefaultConnect; TRY { if (m_pDatabase == NULL) { m_pDatabase = new CDatabase(); m_bRecordsetDb = TRUE; } strDefaultConnect = GetDefaultConnect(); // If not already opened, attempt to open if (!m_pDatabase->IsOpen() && !m_pDatabase->Open("", FALSE, FALSE, strDefaultConnect)) return FALSE; AFX_SQL_SYNC(::SQLAllocStmt(m_pDatabase->m_hdbc, &m_hstmt)); if (!Check(nRetCode)) ThrowDBException(SQL_INVALID_HANDLE); } CATCH_ALL(e) { #ifdef _DEBUG if (afxTraceFlags & 0x20) TRACE0("Error: CDatabase create for CRecordset failed\n"); #endif // _DEBUG strDefaultConnect.Empty(); if (m_bRecordsetDb) { DELETE_OBJ (m_pDatabase); /* if (m_pDatabase) { delete m_pDatabase; m_pDatabase = NULL; } */ } ASSERT(m_hstmt == SQL_NULL_HSTMT); THROW_LAST(); } END_CATCH_ALL }
void CALLBACK pipe_read_cb(PVOID lpParameter, BOOLEAN TimerOrWaitFired) { struct rt_msghdr *rtm; pipe_instance_t *pp; DWORD result; DWORD nbytes; pp = (pipe_instance_t *)lpParameter; EnterCriticalSection(&pp->rcs); TRACE1(ENTER, "Entering pipe_read_cb %p", lpParameter); if (pp->state != PIPE_STATE_CONNECTED) { TRACE0(NETWORK, "WARNING: not PIPE_STATE_CONNECTED, bailing."); /* * XXX: Is something racy, or is it just me? * Try to avoid deadlocking by returning if we * got called when we weren't connected. */ goto out; } result = GetOverlappedResult(pp->pipe, &pp->rov, &nbytes, TRUE); if (result == 0) { result = GetLastError(); TRACE1(NETWORK, "WARNING: pipe_read_cb read returned %d", result); if (result == ERROR_BROKEN_PIPE) { /* * We must queue the new listen on a separate thread to * avoid infinite recursion. */ TRACE0(NETWORK, "Posting listen again."); ResetEvent(pp->revent); QueueUserWorkItem( (LPTHREAD_START_ROUTINE)pipe_relisten_cb, (PVOID)pp, WT_EXECUTEINIOTHREAD); goto out; } } TRACE1(NETWORK, "Read %d bytes from named pipe.", nbytes); /* * Perform sanity checks on input message. * XXX: We should use a more appropriate errno value. * We use -1 as ENOBUFS, etc are not part of the namespace. */ rtm = (struct rt_msghdr *)&pp->rbuf[0]; if (rtm->rtm_version != RTM_VERSION) { TRACE1(NETWORK, "Invalid rtm_version %d, dropping.", rtm->rtm_version); goto drop; } /* * Sanity check size. */ if (rtm->rtm_msglen > nbytes || nbytes < sizeof(struct rt_msghdr)) { TRACE1(NETWORK, "Invalid rtm_msglen %d, dropping.", rtm->rtm_msglen); rtm->rtm_errno = -1; goto drop; } if (rtm->rtm_pid == 0) { TRACE1(NETWORK, "Invalid rtm_pid %d, dropping.", rtm->rtm_pid); rtm->rtm_errno = -1; goto bounce; } switch (rtm->rtm_type) { case RTM_ADD: result = rtm_add_route(rtm, nbytes); if (result == 0) { TRACE0(NETWORK, "route added successfully"); } else { TRACE0(NETWORK, "failed to add route"); } rtm->rtm_errno = result; break; case RTM_DELETE: result = rtm_delete_route(rtm, nbytes); if (result == 0) { TRACE0(NETWORK, "route deleted successfully"); } else { TRACE0(NETWORK, "failed to delete route"); } rtm->rtm_errno = result; break; default: TRACE1(NETWORK, "Invalid rtm_type %d, dropping.", rtm->rtm_type); rtm->rtm_errno = -1; break; } bounce: /* * There is currently no analogue of the BSD SO_LOOPBACK option. * XXX: Normally processes will hear their own messages echoed across * the routing socket emulation pipe. Because the broadcast technique * uses blocking NT I/O, processes must read back their own message * after issuing it. */ broadcast_pipe_message(pp->rbuf, nbytes); drop: TRACE0(NETWORK, "Posting read again."); ResetEvent(pp->revent); QueueUserWorkItem( (LPTHREAD_START_ROUTINE)pipe_reread_cb, (PVOID)pp, WT_EXECUTEINIOTHREAD); out: TRACE0(ENTER, "Leaving pipe_read_cb"); LeaveCriticalSection(&pp->rcs); }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // enable Windows XP look: CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); CMFCToolBar::EnableQuickCustomization (); //--------------------------------- // Set toolbar and menu image size: //--------------------------------- CMFCToolBar::SetSizes (CSize (28, 28), CSize (22, 22)); CMFCToolBar::SetMenuSizes (CSize (22, 22), CSize (16, 16)); // TODO: Define your own basic commands. Be sure, that each pulldown // menu have at least one basic command. CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); lstBasicCommands.AddTail (ID_APP_EXIT); lstBasicCommands.AddTail (ID_APP_ABOUT); lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); lstBasicCommands.AddTail (ID_COMMAND_HISTORY); lstBasicCommands.AddTail (ID_VIEW_LARGEICON); lstBasicCommands.AddTail (ID_VIEW_SMALLICON); lstBasicCommands.AddTail (ID_VIEW_LIST); lstBasicCommands.AddTail (ID_VIEW_DETAILS); lstBasicCommands.AddTail (ID_EDIT_CUT); lstBasicCommands.AddTail (ID_EDIT_COPY); lstBasicCommands.AddTail (ID_EDIT_PASTE); CMFCToolBar::SetBasicCommands (lstBasicCommands); if (!m_wndMenuBar.Create (this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); // Remove menubar gripper and borders: m_wndMenuBar.SetPaneStyle (m_wndMenuBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); // Detect color depth. 256 color toolbars can be used in the // high or true color modes only (bits per pixel is > 8): CClientDC dc (this); BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; UINT uiToolbarColdID = bIsHighColor ? IDB_TOOLBARCOLD256 : 0; UINT uiMenuID = bIsHighColor ? IDB_MENU256 : IDB_MENU16; if (!m_wndToolBar.CreateEx(this) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, uiToolbarColdID, uiMenuID, FALSE, 0, 0, uiToolbarHotID)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } // Remove toolbar gripper and borders: m_wndToolBar.SetPaneStyle (m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); //---------------------------------------- // Create a combo box for the address bar: //---------------------------------------- if (!m_wndAddress.Create (CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 200, 120), this, AFX_IDW_TOOLBAR + 1)) { TRACE0("Failed to create combobox\n"); return -1; // fail to create } // Each rebar pane will ocupy its own row: DWORD dwStyle = RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK; if (!m_wndReBar.Create(this) || !m_wndReBar.AddBar (&m_wndMenuBar) || !m_wndReBar.AddBar (&m_wndToolBar, NULL, NULL, dwStyle) || !m_wndReBar.AddBar(&m_wndAddress, _T("Address"), NULL, dwStyle)) { TRACE0("Failed to create rebar\n"); return -1; // fail to create } m_wndMenuBar.AdjustLayout (); m_wndToolBar.AdjustLayout (); //-------------------------------------------------------------- // Set up min/max sizes and ideal sizes for pieces of the rebar: //-------------------------------------------------------------- REBARBANDINFO rbbi; CRect rectToolBar; m_wndToolBar.GetItemRect(0, &rectToolBar); rbbi.cbSize = sizeof(rbbi); rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE; rbbi.cxMinChild = rectToolBar.Width(); rbbi.cyMinChild = rectToolBar.Height(); rbbi.cx = rbbi.cxIdeal = rectToolBar.Width() * m_wndToolBar.GetCount (); m_wndReBar.GetReBarCtrl().SetBandInfo (1, &rbbi); rbbi.cxMinChild = 0; CRect rectAddress; m_wndAddress.GetEditCtrl()->GetWindowRect(&rectAddress); rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE; rbbi.cyMinChild = rectAddress.Height() + 10; rbbi.cxIdeal = 200; m_wndReBar.GetReBarCtrl().SetBandInfo (3, &rbbi); // TODO: Remove this if you don't want chevrons: m_wndMenuBar.EnableCustomizeButton (TRUE, (UINT)-1, _T("")); m_wndToolBar.EnableCustomizeButton (TRUE, (UINT)-1, _T("")); if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } if (!m_wndFoldersBar.Create (_T("Folders"), this, CRect (0, 0, 200, 200), TRUE, ID_VIEW_FOLDERS, WS_CHILD | WS_VISIBLE | CBRS_LEFT | CBRS_HIDE_INPLACE | WS_CAPTION)) { TRACE0("Failed to create folders bar\n"); return -1; // fail to create } EnableDocking (CBRS_ALIGN_ANY); m_wndReBar.EnableDocking (CBRS_TOP); DockPane (&m_wndReBar); m_wndFoldersBar.EnableDocking (CBRS_LEFT | CBRS_RIGHT); DockPane (&m_wndFoldersBar); CString strMainToolbarTitle; strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); m_wndToolBar.SetWindowText (strMainToolbarTitle); // TODO: Remove this if you don't want tool tips m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); return 0; }
HWND COccManager::CreateDlgControl(CWnd* pWndParent, HWND hwAfter, BOOL bDialogEx, LPDLGITEMTEMPLATE pItem, WORD nMsg, BYTE* lpData, DWORD cb) { LPWSTR pszClass = (LPWSTR)(pItem + 1); DLGITEMTEMPLATE dlgItemTmp; if (bDialogEx) { // We have an extended dialog template: copy relevant parts into an // ordinary dialog template, because their layouts are different DLGITEMTEMPLATEEX* pItemEx = (DLGITEMTEMPLATEEX*)pItem; dlgItemTmp.style = pItemEx->style; dlgItemTmp.dwExtendedStyle = pItemEx->exStyle; dlgItemTmp.x = pItemEx->x; dlgItemTmp.y = pItemEx->y; dlgItemTmp.cx = pItemEx->cx; dlgItemTmp.cy = pItemEx->cy; dlgItemTmp.id = (WORD)pItemEx->id; pItem = &dlgItemTmp; pszClass = (LPWSTR)(pItemEx + 1); } CRect rect(pItem->x, pItem->y, pItem->x + pItem->cx, pItem->y + pItem->cy); ::MapDialogRect(pWndParent->m_hWnd, &rect); BSTR bstrLicKey = NULL; // extract license key data, if any if (cb >= sizeof(ULONG)) { ULONG cchLicKey = *(UNALIGNED ULONG*)lpData; lpData += sizeof(ULONG); cb -= sizeof(ULONG); if (cchLicKey > 0) { bstrLicKey = SysAllocStringLen((LPCOLESTR)lpData, cchLicKey); lpData += cchLicKey * sizeof(WCHAR); cb -= cchLicKey * sizeof(WCHAR); } } // If WM_OCC_INITNEW, we should have exhausted all of the data by now. ASSERT((nMsg != WM_OCC_INITNEW) || (cb == 0)); CDataBoundProperty* pBindings = NULL; CString strDataField; WORD ctlidRowSource = 0; DISPID defdispid = 0; UINT dwType = 0; if (nMsg == WM_OCC_LOADFROMSTREAM_EX || nMsg == WM_OCC_LOADFROMSTORAGE_EX) { // Read the size of the section ULONG cbOffset = *(UNALIGNED ULONG*)lpData; ULONG cbBindInfo = cbOffset - sizeof(DWORD); lpData += sizeof(DWORD); ULONG dwFlags = *(UNALIGNED ULONG*)lpData; cbBindInfo -= sizeof(DWORD); lpData += sizeof(DWORD); ASSERT(dwFlags == 1); ULONG cbBinding = *(UNALIGNED ULONG*)lpData; cbBindInfo -= sizeof(DWORD); lpData += sizeof(DWORD); while(cbBindInfo > 0) { DISPID dispid; UWORD ctlid; dispid = *(UNALIGNED DISPID *)lpData; lpData += sizeof(DISPID); cbBindInfo -= sizeof(DISPID); ctlid = *(UNALIGNED WORD *)lpData; lpData += sizeof(WORD); cbBindInfo -= sizeof(WORD); if(dispid == DISPID_DATASOURCE) { defdispid = *(UNALIGNED ULONG*)lpData; cbBindInfo -= sizeof(DISPID); lpData += sizeof(DISPID); dwType = *(UNALIGNED ULONG*)lpData; cbBindInfo -= sizeof(DWORD); lpData += sizeof(DWORD); ASSERT(*(UNALIGNED DISPID *)lpData == DISPID_DATAFIELD); lpData += sizeof(DISPID); cbBindInfo -= sizeof(DISPID); // Skip the string length lpData += sizeof(DWORD); cbBindInfo -= sizeof(DWORD); strDataField = (char *)lpData; lpData += strDataField.GetLength()+1; cbBindInfo -= strDataField.GetLength()+1; ctlidRowSource = ctlid; } else pBindings = new CDataBoundProperty(pBindings, dispid, ctlid); } cb -= cbOffset; } // From now on act as a regular type nMsg -= (WM_OCC_LOADFROMSTREAM_EX - WM_OCC_LOADFROMSTREAM); GUID clsid; HRESULT hr; if (pszClass[0] == L'{') hr = CLSIDFromString(pszClass, &clsid); else hr = CLSIDFromProgID(pszClass, &clsid); #ifdef _DEBUG if (FAILED(hr)) { TRACE1("Unable to convert \"%ls\" to a class ID.\n", pszClass); TRACE1(">>> Result code: 0x%08lx\n", hr); if (pszClass[0] != L'{') TRACE0(">>> Is the control properly registered?\n"); } #endif CMemFile memFile(lpData, cb); CMemFile* pMemFile = (nMsg == WM_OCC_INITNEW) ? NULL : &memFile; CWnd* pWndNew = NULL; COleControlSite* pSite = NULL; if (SUCCEEDED(hr) && pWndParent->InitControlContainer() && pWndParent->m_pCtrlCont->CreateControl(NULL, clsid, NULL, pItem->style, rect, pItem->id, pMemFile, (nMsg == WM_OCC_LOADFROMSTORAGE), bstrLicKey, &pSite)) { ASSERT(pSite != NULL); // set ZOrder only! SetWindowPos(pSite->m_hWnd, hwAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); pSite->m_pBindings = pBindings; pSite->m_strDataField = strDataField; pSite->m_ctlidRowSource = ctlidRowSource; pSite->m_defdispid = defdispid; pSite->m_dwType = dwType; // Determine if this is a DataSource by QI for ICursor ICursor* pCursor; if (SUCCEEDED(pSite->m_pObject->QueryInterface(IID_ICursor, (LPVOID *)&pCursor))) { pCursor->Release(); pSite->m_pDataSourceControl = new CDataSourceControl(pSite); } } if (bstrLicKey != NULL) SysFreeString(bstrLicKey); return (pSite != NULL) ? pSite->m_hWnd : NULL; }
/** * Activates the next measurement request. * * @param hMeasurementMgr A handle to the Measurement Manager module. * * @date 16-Dec-2005 */ TI_STATUS measurementMgr_activateNextRequest(TI_HANDLE hMeasurementMgr) { measurementMgr_t * pMeasurementMgr = (measurementMgr_t *) hMeasurementMgr; requestHandler_t * pRequestH = (requestHandler_t *) pMeasurementMgr->hRequestH; MeasurementRequest_t * pRequestArr[MAX_NUM_REQ]; TI_UINT8 numOfRequestsInParallel = 0; TI_BOOL valid; TI_UINT8 index; /* Keep note of the time we started processing the request. this will be used */ /* to give the measurementSRV a time frame to perform the measurement operation */ pMeasurementMgr->currentRequestStartTime = os_timeStampMs(pMeasurementMgr->hOs); TRACE1(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Timer started at %d, we have 20ms to begin measurement...\n", pMeasurementMgr->currentRequestStartTime); TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Looking for a valid request\n"); do { TI_STATUS status; if (numOfRequestsInParallel != 0) { TRACE4(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Changing activeRequestID from %d to %d, and numOfWaitingRequests from %d to %d.\n", pRequestH->activeRequestID, pRequestH->activeRequestID + numOfRequestsInParallel, pRequestH->numOfWaitingRequests, pRequestH->numOfWaitingRequests - numOfRequestsInParallel); } pRequestH->activeRequestID += numOfRequestsInParallel; pRequestH->numOfWaitingRequests -= numOfRequestsInParallel; for (index = 0; index < MAX_NUM_REQ; index++) { pRequestArr[index] = NULL; } numOfRequestsInParallel = 0; /* Getting the next request/requests from the request handler */ status = requestHandler_getNextReq(pMeasurementMgr->hRequestH, TI_FALSE, pRequestArr, &numOfRequestsInParallel); /* Checking if there are no waiting requests */ if (status != TI_OK) { TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": There are no waiting requests in the queue\n"); return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), MEASUREMENTMGR_EVENT_SEND_REPORT, pMeasurementMgr); } /* Checking validity of request/s */ valid = measurementMgr_isRequestValid(pMeasurementMgr, pRequestArr, numOfRequestsInParallel); /* Checking if the current request is Beacon Table */ if( (numOfRequestsInParallel == 1) && (pRequestArr[0]->Type == MSR_TYPE_BEACON_MEASUREMENT) && (pRequestArr[0]->ScanMode == MSR_SCAN_MODE_BEACON_TABLE) ) { TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Received Beacon Table request, building a report for it and continuing\n"); pMeasurementMgr->buildReport(hMeasurementMgr, *(pRequestArr[0]), NULL); valid = TI_FALSE; /* In order to get the next request/s*/ } } while (valid == TI_FALSE); TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Request(s) for activation:\n"); for (index = 0; index < numOfRequestsInParallel; index++) { TRACE6(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": \n\nRequest #%d:\n Type: %d\n Measured Channel: %d (Serving Channel: %d)\n Scan Mode: %d\n Duration: %d\n\n", index+1, pRequestArr[index]->Type, pRequestArr[index]->channelNumber, pMeasurementMgr->servingChannelID, pRequestArr[index]->ScanMode, pRequestArr[index]->DurationTime); } /* Ignore requests if traffic intensity is high */ if (measurementMgr_isTrafficIntensityHigherThanThreshold(pMeasurementMgr) == TI_TRUE) { TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Traffic intensity too high, giving up...\n"); measurementMgr_rejectPendingRequests(pMeasurementMgr, MSR_REJECT_TRAFFIC_INTENSITY_TOO_HIGH); return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), MEASUREMENTMGR_EVENT_SEND_REPORT, pMeasurementMgr); } TRACE0(pMeasurementMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Request is Valid, about to start\n"); pMeasurementMgr->measuredChannelID = pRequestArr[0]->channelNumber; /* Request resource from the SCR */ return measurementMgrSM_event((TI_UINT8 *) &(pMeasurementMgr->currentState), MEASUREMENTMGR_EVENT_REQUEST_SCR, pMeasurementMgr); }
void LogoutNode::yzDoWork(int LineNo,Channel &channel) { LPTSTR VoicePath1 = ""; CString strState = ""; CString tmpState = ""; switch(channel.nType) { case CHTYPE_USER: if( !OffHookDetect(LineNo) && channel.UsableFlag != TRUE ) { pList1->SetItemText(LineNo,4,_T("")); pList1->SetItemText(LineNo,5,_T("")); TRACE0("\n|"); switch(state) { case CH_LOGOUT: case CH_WAITONHOOK: StopPlayFile(LineNo); StartPlaySignal(LineNo,SIG_STOP); ResetLine(LineNo,channel); return; default: break; } } break; case CHTYPE_TRUNK: if( Sig_CheckBusy(LineNo) && channel.UsableFlag != TRUE ) { pList1->SetItemText(LineNo,4,_T("")); pList1->SetItemText(LineNo,5,_T("")); switch(state) { case CH_LOGOUT: case CH_WAITONHOOK: StopPlayFile(LineNo); StartPlaySignal(LineNo,SIG_STOP); ResetLine(LineNo,channel); return; default: break; } break; } }//end switch switch(state) { case CH_LOGOUT: channel.nTimeElapse = 0; strState = _T("播放语音"); tmpState = pList1->GetItemText(LineNo,2); if( tmpState != strState ) pList1->SetItemText(LineNo,2,strState); if( channel.IsLogin ) { if( myXml.findVoiceNameByNodeId(channel.CurrNodeId,_T("Logout"),VoicePath1) ) { StartPlayFile(LineNo,VoicePath1,0L); } //更新坐席人员注销时间 CTime tm; CString strTime; tm=CTime::GetCurrentTime(); strTime = tm.Format(_T("%Y-%m-%d %X")); mySql.updateUserRecentLogoutTime( (LPCTSTR)channel.UserId,strTime,pConn ); //更新坐席人员状态界面 int itemCount = pList2->GetItemCount(); for(int i=0; i<itemCount; i++) { if(pList2->GetItemText(i,1) == (LPCTSTR)channel.UserId) { pList2->SetItemText(i,3,_T("")); pList2->SetItemText(i,4,_T("")); pList2->SetItemText(i,6,strTime); break; } } //写日志,注销成功。 CString strDetails; strDetails = strTime + CString(_T("座席")) + (LPCTSTR)channel.UserId + CString(_T("注销成功;")); myXml.insertTextToLogItem(channel.strItemId,strDetails,_T("Details"),channel.ctStartTime); channel.IsLogin = FALSE; channel.UserId[0] = NULL; } else { if( myXml.findVoiceNameByNodeId(channel.CurrNodeId,_T("NotLogin"),VoicePath1) ) { StartPlayFile(LineNo,VoicePath1,0L); } } state = CH_WAITONHOOK; break; case CH_WAITONHOOK: strState = _T("等待挂机"); tmpState = pList1->GetItemText(LineNo,2); if( tmpState != strState ) pList1->SetItemText(LineNo,2,strState); if(CheckPlayEnd(LineNo)) { StopPlayFile(LineNo); StartPlaySignal(LineNo,SIG_BUSY1); } break; default: break; }//end switch }