// The main entry for save results to files. static void SubmitLog(int run_type) { //For General Log { char msg[LOG_MSG_LENGTH]; FormatMsg(LOG_GENERAL, msg); LogVerbose("%s", msg); } //For GnuPlot { char msg[LOG_MSG_LENGTH]; FormatMsg(LOG_GNUPLOT, msg); GNUPLOT_SubmitResult(msg); } }
Bool HawkAppFrame::OnSessionClose(SID iSid, const AString& sAddr) { if (m_mSidAddr.Erase(iSid)) { FormatMsg("SessionClose", "Sid: %u, IpAddr: %s", iSid, sAddr.c_str()); return true; } return false; }
LRESULT CALLBACK WndSubclassProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { WND_DATA *data = (WND_DATA*)GetWindowLongPtr(hwnd, GWL_USERDATA); if(uMsg == WM_INPUTLANGCHANGE) { FormatMsg(L"%s: WM_INPUTLANGCHANGE lParam=%x wParam=%x\n", data->WndName, lParam, wParam); UpdateData(hMainDlg); //Pass message to defwindowproc } else if(uMsg == WM_INPUTLANGCHANGEREQUEST) { FormatMsg(L"%s: WM_INPUTLANGCHANGEREQUEST lParam=%x wParam=%x\n", data->WndName, lParam, wParam); UpdateData(hMainDlg); //Pass message to defwindowproc } return ( CallWindowProc( data->OrigProc, hwnd, uMsg, wParam, lParam) ); }
void VSystemWarning (VStringConst format, ...) { va_list args; char buf[maxErrorMessageLength]; va_start (args, format); FormatMsg (buf, "Warning", format, & args, strerror (errno)); va_end (args); fprintf(stderr, "%s\n", buf); }
static SYMBOL msgBuild( // BUILD ERROR MESSAGE MSG_NUM msgnum, // - message number va_list args, // - substitution arguments VBUF *pbuf ) // - buffer for message { char msgbuf[MAX_MSG+16]; // - contains expanded message CBanner(); doDecodeMessage( msgbuf, msgnum ); return FormatMsg( pbuf, msgbuf, args ); }
void VSystemError (VStringConst format, ...) { va_list args; char buf[maxErrorMessageLength]; va_start (args, format); FormatMsg (buf, "Fatal", format, & args, strerror (errno)); va_end (args); fprintf(stderr, "%s\n", buf); exit (EXIT_FAILURE); }
ERMsg CDirectoryManagerBase::GetFilePath(const std::string& fileName, const std::string& fileExt, std::string& filePath)const { ERMsg msg; filePath = GetFilePath(fileName, fileExt); if (filePath.empty()) { string directoryList = "\t" + GetDirectories(); ReplaceString(directoryList, "|", "\r\n\t"); string error = FormatMsg(IDS_WG_FILE_NOT_FOUND, _GetFileName(fileName, fileExt), directoryList.c_str()); msg.ajoute(error); } return msg; }
ERMsg CDirectoryManager::CreateNewDataBase(const std::string& filePath)const { ERMsg msg; std::string fileName = GetFileName(filePath); //verify that the file does'nt exist in all other directories if (!GetFilePath(GetFileName(fileName)).empty()) { string error = FormatMsg(IDS_WG_FILE_ALREADY_EXIST, fileName, WBSF::GetPath(filePath)); msg.ajoute(error); return msg; } ASSERT(!FileExists(filePath)); msg += CreateMultipleDir(WBSF::GetPath(filePath)); return msg;//do nothing }
ERMsg CBioSIMProject::Load(const string& filePath) { ERMsg msg; zen::XmlDoc doc; msg = load(filePath, doc); if (msg) { string rootName = doc.root().getNameAs<string>(); if (rootName.empty() || !IsEqualNoCase(rootName, XML_FLAG)) { msg.ajoute(FormatMsg(IDS_INVALID_BIOSIM_DOCUMENT, filePath)); } if (msg) { readStruc(doc.root()); m_filePath = filePath; } } return msg; }
STDMETHODIMP CImpCEDL::Init(BSTR sTargetName, BSTR sGenPath,BOOL bSilent) { AFX_MANAGE_STATE(AfxGetStaticModuleState()) HRESULT hr = S_OK; CString strPath,strSrc,strDest,strTarget; CFileStatus rStatus; PIDLEvents pEvntSink; PICEMsg pMsgSink; IErrorInfo* pInfo = NULL; DWORD dwErr = 0UL; // Enforce using of DAO36 and Jet40 by mfc42.dll AfxGetModuleState()->m_dwVersion = 0x0601; //EF don't call this: causes an zombie process! AfxDaoInit(); FC_DEBUGPRINT1(_T("CEDL> Init: thread id=0x%x\n"),::GetCurrentThreadId()); try { if(!sTargetName || !sGenPath) { ComThrow(GetObjectCLSID(),__uuidof(IDL),E_POINTER); } strTarget = sTargetName; strPath = sGenPath; strSrc = strPath + _T('\\') + strTarget; //create own event sink - not created if already done CreateEvntSink(); //check for the target specific gen path first if(!CFile::GetStatus(strSrc,rStatus)) { ComThrow(GetObjectCLSID(),__uuidof(IDL),E_CE_DL_NOGENPATH,strSrc,strTarget); } //create downloader directory within target specific gen path if //not already created strSrc = strSrc + _T('\\') + CEDL_DOMDIR; if(!CFile::GetStatus(strSrc,rStatus)) { //create a new dir if(_tmkdir(strSrc)) { //on error throw file exception with path dwErr = GetLastError(); CFileException::ThrowOsError(dwErr,strSrc); } } CStationList::CopyDatabase(strTarget,sGenPath,false); //get the path of the current database CStationList::GetDBPath(strDest,strTarget,sGenPath); pEvntSink = dynamic_cast <CProxyIDLEvents<CImpCEDL>*>(this); assert(pEvntSink); pMsgSink = dynamic_cast <CProxy_ICEMessageEvent<CImpCEDL>*>(this); assert(pMsgSink); /* TODO CHECK OBSOLETE if(m_pStationList) { //station list there - reinitialization //station list there but represents not the same project ? if(strGUID != m_pStationList->GetProjectGuid()) { /* not the same project return downloader already inited. a different project requires a call to Exit before reinit downloader return E_CE_DL_ALREADY_INITED; } /* iff any download is pending and state not CEDL_STAT_IDLE reinitialization is not possible if(m_pStationList->IsDownloadPending()) { return E_CE_DL_PENDING; } //check wether downloader database is open. if(!m_pStationList->IsDBOpen()) { //reopen it iff not open m_pStationList->OpenDB(); } if(!m_pStationList->CheckDBVersion()) { //close db first m_pStationList->CloseDB(); CStationList::CopyDatabase(sGenPath,true); //reopen m_pStationList->OpenDB(); } } */ m_pStationList = new CStationList(strPath,strDest); if(!m_pStationList) { AfxThrowMemoryException(); } m_pStationList->OpenDB(); if(!m_pStationList->CheckDBVersion()) { //close db first m_pStationList->CloseDB(); CStationList::CopyDatabase(strTarget,sGenPath,true); //reopen m_pStationList->OpenDB(); } m_pStationList->BuildStationList(sTargetName,pEvntSink,pMsgSink, bSilent?true:false); } catch(_com_error err) { Fire_OnNewMessage(NULL,E_FACILITY_CEDL,err.Error(),err.Description()); ComCatch(err); hr = err.Error(); } catch(CMemoryException* e) { e->Delete(); hr = E_OUTOFMEMORY; } catch(CDaoException* e) { hr = e->m_scode; strDest.Empty(); if(e->m_pErrorInfo) { strDest = e->m_pErrorInfo->m_strDescription; } if(strDest.IsEmpty()) { strDest.Format(IDS_CEDL_DEFERROR,hr); } ComErrorInfo(GetObjectCLSID(),__uuidof(IDL),&pInfo,strDest); _com_error err(hr,pInfo); Fire_OnNewMessage(NULL,E_FACILITY_CEDL,err.Error(),err.Description()); e->Delete(); ComCatch(err); } catch(CFileException * e) { hr = HRESULT_FROM_WIN32(e->m_lOsError); strDest.Empty(); strSrc.Empty(); FormatMsg(strSrc.GetBuffer(_MAX_PATH),hr); strSrc.ReleaseBuffer(); if(strSrc.IsEmpty()) { strSrc.Format(IDS_CEDL_DEFERROR,hr); } strSrc.TrimRight(_T("\r\n")); FormatMsg(strDest.GetBuffer(_MAX_PATH),E_CE_DL_FILE_ERROR,strTarget, strSrc,e->m_strFileName); strDest.ReleaseBuffer(); ComErrorInfo(GetObjectCLSID(),__uuidof(IDL),&pInfo,strDest); _com_error err(hr,pInfo); Fire_OnNewMessage(NULL,E_FACILITY_CEDL,err.Error(),err.Description()); e->Delete(); ComCatch(err); } if(FAILED(hr)) { Cleanup(); m_bInit = FALSE; return hr; } m_bInit = TRUE; return hr; }
Bool HawkAppFrame::OnSessionStart(SID iSid, const AString& sAddr) { m_mSidAddr.Set(iSid, sAddr); FormatMsg("SessionStart", "Sid: %u, IpAddr: %s", iSid, sAddr.c_str()); return true; }
LRESULT MainDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { HKL hKl; switch (Msg) { case WM_INITDIALOG: { WCHAR Buf[255]; UpdateData(hDlg); hMainDlg = hDlg; SubclassWnd(GetDlgItem(hDlg, IDC_LIST), L"List"); SubclassWnd(GetDlgItem(hDlg, IDC_EDIT1), L"Edit1"); SubclassWnd(GetDlgItem(hDlg, IDC_KLID), L"Klid"); SubclassWnd(GetDlgItem(hDlg, ID_CANCEL), L"CancelB"); SubclassWnd(GetDlgItem(hDlg, IDC_ACTIVATE), L"ActivateB"); SubclassWnd(GetDlgItem(hDlg, IDC_REFRESH), L"RefreshB"); SubclassWnd(GetDlgItem(hDlg, IDC_UNLOAD), L"UnloadB"); SubclassWnd(GetDlgItem(hDlg, IDC_LOAD), L"LoadB"); CheckRadioButton(hDlg, IDC_FROMLIST, IDC_FROMEDIT, IDC_FROMLIST); SetWindowText(GetDlgItem(hDlg, IDC_KLID), L"00000419"); swprintf(Buf, L"Current thread id: %d", GetCurrentThreadId()); SetWindowText(GetDlgItem(hDlg, IDC_CURTHREAD), Buf); SetWindowText(GetDlgItem(hDlg, IDC_DELAY), L"0"); return 0; } /* WM_INITDIALOG */ case WM_COMMAND: { switch(LOWORD(wParam)) { case ID_CANCEL: { EndDialog(hDlg, ERROR_CANCELLED); break; } case IDC_ACTIVATE: { if((hKl = GetActivateHandle(hDlg)) != INVALID_HANDLE_VALUE) { Sleep(GetDelayMilliseconds(hDlg)); if(!(hKl = ActivateKeyboardLayout(hKl, GetActivateFlags(hDlg)))) FormatBox(hDlg, MB_ICONERROR, L"Error", L"ActivateKeyboardLayout() failed. %d", GetLastError()); else UpdateData(hDlg); //FormatBox(hDlg, 0, L"Activated", L"Prev - %x, err - %d.", hKl, // GetLastError()); } else MessageBox(hDlg, L"No item selected", L"Error", MB_ICONERROR); break; } case IDC_UNLOAD: { if((hKl = GetSelectedLayout(hDlg)) != INVALID_HANDLE_VALUE) { Sleep(GetDelayMilliseconds(hDlg)); if(!UnloadKeyboardLayout(hKl)) FormatBox(hDlg, MB_ICONERROR, L"Error", L"UnloadKeyboardLayout() failed. %d", GetLastError()); else UpdateData(hDlg); } else MessageBox(hDlg, L"No item selected", L"Error", MB_ICONERROR); break; } case IDC_LOAD: { WCHAR buf[255]; GetWindowText(GetDlgItem(hDlg, IDC_KLID), buf, sizeof(buf)); Sleep(GetDelayMilliseconds(hDlg)); if(!LoadKeyboardLayout(buf, GetLoadFlags(hDlg))) FormatBox(hDlg, MB_ICONERROR, L"Error", L"LoadKeyboardLayout() failed. %d", GetLastError()); else UpdateData(hDlg); break; } case IDC_REFRESH: { UpdateData(hDlg); break; } case IDC_NEWTHREAD: { if(!CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL)) { FormatBox(hDlg, MB_ICONERROR, L"Error!", L"Can not create thread (%d).", GetLastError()); } } case IDC_LIST: { if(HIWORD(wParam) == LBN_SELCHANGE) { WCHAR buf[25]; if((hKl = GetSelectedLayout(hDlg)) != NULL) { swprintf(buf, L"%x", hKl); SetWindowText(GetDlgItem(hDlg, IDC_HANDLE), buf); } } break; } } return TRUE; } /* WM_COMMAND */ case WM_INPUTLANGCHANGE: { FormatMsg(L"dlg WM_INPUTLANGCHANGE lParam=%x wParam=%x\n", lParam, wParam); return FALSE; } case WM_INPUTLANGCHANGEREQUEST: { FormatMsg(L"dlg WM_INPUTLANGCHANGEREQUEST lParam=%x wParam=%x\n", lParam, wParam); UpdateData(hDlg); return FALSE; } case WM_CLOSE: { EndDialog(hDlg, ERROR_CANCELLED); return TRUE; } /* WM_CLOSE */ default: return FALSE; } }