//Called before StarCraft is completely loaded extern "C" __declspec(dllexport) bool ApplyPatchSuspended(HANDLE, DWORD) { if (GetFileAttributesW(WLAUNCHER) == 0xFFFFFFFF) { MessageBoxW(NULL, L"wLauncher.exe not found!", L"wDetector Plugin", MB_OK | MB_ICONERROR); return false; } if (GetFileAttributesW(WDETECTOR) == 0xFFFFFFFF) { MessageBoxW(NULL, L"wDetector.w not found!", L"wDetector Plugin", MB_OK | MB_ICONERROR); return false; } if (wcscmp(FileVersion(WDETECTOR), L"3.37") != 0) { MessageBoxW(NULL, L"wDetector's version is incorrect!", L"wDetector Plugin", MB_OK | MB_ICONERROR); return false; } STARTUPINFOW info = { sizeof(info) }; if (!CreateProcessW(WLAUNCHER, NULL, NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo)) { MessageBoxW(NULL, L"Failed to start wLauncher.exe!", L"wDetector Plugin", MB_OK | MB_ICONERROR); return false; } return true; }
BOOL UpdateChecker::CheckForNewVersion(LPCTSTR URL2Check, FileVersion& curVersion, LPCTSTR progData/* = NULL*/, HWND asyncHWND/* = 0*/) { ASSERT(URL2Check != NULL); if (GetStatus() == S_Working) return FALSE; if (curVersion == FileVersion(0,0,0,0)) return FALSE;//Not the correct FileVersion if (m_pFD == NULL) m_pFD = new AsyncUrlDownloader; if (m_pFD->GetStatus() == IUrlDownloader::S_Working) return FALSE; SetStatus(S_Working); BOOL bRet = TRUE; std::tstring url(URL2Check); url += _T("?curversion="); TCHAR bf[30]; curVersion.toString(bf); url += bf; if (progData != NULL && progData[0] != 0) { url += _T("&progData="); url += progData; } if (asyncHWND > 0) { m_asyncHWND = asyncHWND; m_pFD->SetAsyncTarget(this); m_pFD->DownloadURL(url.c_str()); #ifdef _DEBUG //ShellExecute(0,_T("open"), url.c_str(), 0,0,0); #endif } else { UrlDownloader dl; bRet = dl.DownloadURL(URL2Check); if (bRet) bRet = Parse((LPCSTR)dl.GetBuffer(), dl.GetBufferSize()); SetStatus(bRet ? S_Succeeded : S_Failed); return TRUE; } return bRet; }
/******************************************************************** WcaInitialize() - initializes the Wca framework, should be the first thing called by all CustomActions ********************************************************************/ extern "C" HRESULT WIXAPI WcaInitialize( __in MSIHANDLE hInstall, __in_z PCSTR szCustomActionLogName ) { WCHAR wzCAFileName[MAX_PATH] = {0}; DWORD dwMajorVersion = 0; DWORD dwMinorVersion = 0; // these statics should be called once per CustomAction invocation. // Darwin doesn't preserve DLL state across CustomAction calls so // these should always be initialized to NULL. If that behavior changes // we would need to do a careful review of all of our module/global data. AssertSz(!s_fInitialized, "WcaInitialize() should only be called once per CustomAction"); Assert(NULL == s_hInstall); Assert(NULL == s_hDatabase); Assert(0 == *s_szCustomActionLogName); HRESULT hr = S_OK; s_fInitialized = TRUE; s_iRetVal = ERROR_SUCCESS; // assume all will go well s_hInstall = hInstall; s_hDatabase = ::MsiGetActiveDatabase(s_hInstall); // may return null if deferred CustomAction hr = ::StringCchCopy(s_szCustomActionLogName, countof(s_szCustomActionLogName), szCustomActionLogName); ExitOnFailure1(hr, "Failed to copy CustomAction log name: %s", szCustomActionLogName); // If we got the database handle i.e.: immediate CA if (s_hDatabase) { hr = SetVerboseLoggingAtom(IsVerboseLogging()); ExitOnFailure(hr, "Failed to set verbose logging global atom"); } if (!::GetModuleFileNameW(g_hInstCADLL, wzCAFileName, countof(wzCAFileName))) { ExitWithLastError(hr, "Failed to get module filename"); } FileVersion(wzCAFileName, &dwMajorVersion, &dwMinorVersion); // Ignore failure, just log 0.0.0.0 WcaLog(LOGMSG_VERBOSE, "Entering %s in %ls, version %u.%u.%u.%u", szCustomActionLogName, wzCAFileName, (DWORD)HIWORD(dwMajorVersion), (DWORD)LOWORD(dwMajorVersion), (DWORD)HIWORD(dwMinorVersion), (DWORD)LOWORD(dwMinorVersion)); Assert(s_hInstall); LExit: if (FAILED(hr)) { if (s_hDatabase) { ::MsiCloseHandle(s_hDatabase); s_hDatabase = NULL; } s_hInstall = NULL; s_fInitialized = FALSE; } return hr; }
int KDumpFile::MakeDumpKey(const TCHAR szVersion[]) { int nResult = FALSE; int nRetCode = FALSE; TCHAR szAppPathName[MAX_PATH]; TCHAR szModuleInfos[MAX_PATH * MAX_MODULE_COUNT]; TCHAR szDumpKey[sizeof(szModuleInfos) / sizeof(szModuleInfos[0]) + 512]; TCHAR szTmpKey[64]; KFileVersionInfo FileVersion(szAppPathName); KDumpModuleInfoVector DumpModuleInfoVector; KDumpModuleInfoVectorItor itor; KDumpModuleInfoVectorItor itorEnd; KDumpModuleInfo *pModuleInfo = NULL; _tcscpy(szAppPathName, m_szAppPath); _tcscat(szAppPathName, m_szAppName); nRetCode = KDumpModuleAnalyzer::GetModules(m_hExceptionThread, m_pExceptionInfo, &DumpModuleInfoVector); KG_PROCESS_ERROR(nRetCode); KG_PROCESS_ERROR(DumpModuleInfoVector.size() > 0); _tcsncpy(m_szExceptionModuleName, DumpModuleInfoVector[0].szModuleName, sizeof(m_szExceptionModuleName) / sizeof(m_szExceptionModuleName[0])); m_szExceptionModuleName[sizeof(m_szExceptionModuleName) / sizeof(m_szExceptionModuleName[0]) - 1] = _T('\0'); szModuleInfos[0] = _T('\0'); for ( itor = DumpModuleInfoVector.begin(), itorEnd = DumpModuleInfoVector.end(); itor != itorEnd; itor++ ) { TCHAR szModuleName[MAX_PATH]; nRetCode = _sntprintf( szModuleName, sizeof(szModuleName) / sizeof(szModuleName[0]), _T("%s%llp"), itor->szModuleName, itor->dwStackAddress - itor->dwModuleBase ); KG_PROCESS_ERROR(nRetCode >= 0 && nRetCode < sizeof(szModuleName) / sizeof(szModuleName[0])); szModuleName[sizeof(szModuleName) / sizeof(szModuleName[0]) - 1] = _T('\0'); _tcscat(szModuleInfos, szModuleName); szModuleInfos[sizeof(szModuleInfos) / sizeof(szModuleInfos[0]) - 1] = _T('\0'); } _sntprintf(szDumpKey, sizeof(szDumpKey) / sizeof(TCHAR), _T("%s%s%s%s%s%x"), szVersion, FileVersion.OriginalFilename(), FileVersion.ProductVersion(), FileVersion.FileVersion(), szModuleInfos, m_pExceptionInfo->ExceptionRecord->ExceptionCode ); szDumpKey[sizeof(szDumpKey) / sizeof(TCHAR) - 1] = _T('\0'); KG_EDStringToMD5String(szTmpKey, szDumpKey); _tcsncpy(m_szDumpKey, szTmpKey, sizeof(m_szDumpKey) / sizeof(TCHAR)); m_szDumpKey[sizeof(m_szDumpKey) / sizeof(TCHAR) - 1] = _T('\0'); #ifdef OPEN_LOG_AND_BREAK KLogPrintf( "MD5:%s\tDumpKey:%s\tModuleName:%s", szTmpKey, szDumpKey, m_szExceptionModuleName ); #endif nResult = TRUE; Exit0: return nResult; }
// Searches subdirectories of the given path for the highest version of ngen.exe available static HRESULT GetNgenVersion( __in LPWSTR pwzParentPath, __out LPWSTR* ppwzVersion ) { Assert(pwzParentPath); HRESULT hr = S_OK; DWORD dwError = 0; DWORD dwNgenFileFlags = 0; LPWSTR pwzVersionSearch = NULL; LPWSTR pwzNgen = NULL; LPWSTR pwzTemp = NULL; LPWSTR pwzTempVersion = NULL; DWORD dwMaxMajorVersion = 0; // This stores the highest major version we've seen so far DWORD dwMaxMinorVersion = 0; // This stores the minor version of the highest major version we've seen so far DWORD dwMajorVersion = 0; // This stores the major version of the directory we're currently considering DWORD dwMinorVersion = 0; // This stores the minor version of the directory we're currently considering BOOL fFound = TRUE; WIN32_FIND_DATAW wfdVersionDirectories; HANDLE hFind = INVALID_HANDLE_VALUE; hr = StrAllocFormatted(&pwzVersionSearch, L"%s*", pwzParentPath); ExitOnFailure1(hr, "failed to create outer directory search string from string %ls", pwzParentPath); hFind = FindFirstFileW(pwzVersionSearch, &wfdVersionDirectories); if (hFind == INVALID_HANDLE_VALUE) { ExitWithLastError1(hr, "failed to call FindFirstFileW with string %ls", pwzVersionSearch); } while (fFound) { pwzTempVersion = (LPWSTR)&(wfdVersionDirectories.cFileName); // Explicitly exclude v1.1.4322, which isn't backwards compatible and is not supported if (wfdVersionDirectories.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (0 != lstrcmpW(L"v1.1.4322", pwzTempVersion)) { // A potential candidate directory was found to run ngen from - let's make sure ngen actually exists here hr = StrAllocFormatted(&pwzNgen, L"%s%s\\ngen.exe", pwzParentPath, pwzTempVersion); ExitOnFailure2(hr, "failed to create inner ngen search string with strings %ls and %ls", pwzParentPath, pwzTempVersion); // If Ngen.exe does exist as a file here, then let's check the file version if (FileExistsEx(pwzNgen, &dwNgenFileFlags) && (0 == (dwNgenFileFlags & FILE_ATTRIBUTE_DIRECTORY))) { hr = FileVersion(pwzNgen, &dwMajorVersion, &dwMinorVersion); if (FAILED(hr)) { WcaLog(LOGMSG_VERBOSE, "Failed to get version of %ls - continuing", pwzNgen); } else if (dwMajorVersion > dwMaxMajorVersion || (dwMajorVersion == dwMaxMajorVersion && dwMinorVersion > dwMaxMinorVersion)) { // If the version we found is the highest we've seen so far in this search, it will be our new best-so-far candidate hr = StrAllocString(ppwzVersion, pwzTempVersion, 0); ExitOnFailure1(hr, "failed to copy temp version string %ls to version string", pwzTempVersion); // Add one for the backslash after the directory name WcaLog(LOGMSG_VERBOSE, "Found highest-so-far version of ngen.exe (in directory %ls, version %u.%u.%u.%u)", *ppwzVersion, (DWORD)HIWORD(dwMajorVersion), (DWORD)LOWORD(dwMajorVersion), (DWORD)HIWORD(dwMinorVersion), (DWORD)LOWORD(dwMinorVersion)); dwMaxMajorVersion = dwMajorVersion; dwMaxMinorVersion = dwMinorVersion; } } else { WcaLog(LOGMSG_VERBOSE, "Ignoring %ls because it doesn't contain the file ngen.exe", pwzTempVersion); } } else { WcaLog(LOGMSG_VERBOSE, "Ignoring %ls because it is from .NET Framework v1.1, which is not backwards compatible with other versions of the Framework and thus is not supported by this custom action.", pwzTempVersion); } } else { WcaLog(LOGMSG_VERBOSE, "Ignoring %ls because it isn't a directory", pwzTempVersion); } fFound = FindNextFileW(hFind, &wfdVersionDirectories); if (!fFound) { dwError = ::GetLastError(); hr = (ERROR_NO_MORE_FILES == dwError) ? ERROR_SUCCESS : HRESULT_FROM_WIN32(dwError); ExitOnFailure1(hr, "Failed to call FindNextFileW() with query %ls", pwzVersionSearch); } } if (NULL == *ppwzVersion) { hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); ExitOnRootFailure1(hr, "Searched through all subdirectories of %ls, but failed to find any version of ngen.exe", pwzParentPath); } else { WcaLog(LOGMSG_VERBOSE, "Using highest version of ngen found, located in this subdirectory: %ls, version %u.%u.%u.%u", *ppwzVersion, (DWORD)HIWORD(dwMajorVersion), (DWORD)LOWORD(dwMajorVersion), (DWORD)HIWORD(dwMinorVersion), (DWORD)LOWORD(dwMinorVersion)); } LExit: if (hFind != INVALID_HANDLE_VALUE) { if (0 == FindClose(hFind)) { dwError = ::GetLastError(); hr = HRESULT_FROM_WIN32(dwError); WcaLog(LOGMSG_STANDARD, "Failed to close handle created by outer FindFirstFile with error %x - continuing", hr); } hFind = INVALID_HANDLE_VALUE; } ReleaseStr(pwzVersionSearch); ReleaseStr(pwzNgen); ReleaseStr(pwzTemp); // Purposely don't release pwzTempVersion, because it wasn't allocated in this function, it's just a pointer to a string inside wfdVersionDirectories return hr; }
int main(int argc, char** argv) { bool AddLicenceInformation = true; #if defined(COMPILE_STORM_MODULES_FOR_RMS) AddLicenceInformation = false; //* The Appl is static, otherwise it is not deleted upon call to exit(). //* TODO: checkUsage() must not call exit(), either return a status, or //* throw an exception that is caught here. //* So that the app can exit gracefully. static CravaAppl CravaAppl("RMS", "RMS - Seismic inversion module", Appl::NOTRADEMARK, ReleaseInfo::GetRmsMajorMinorVersionNumber(), ReleaseInfo::GetFullVersionNumber(), Appl::RELEASE, FileVersion(0), "SEISMIC_INVERSION", ReleaseInfo::GetLicenseVersion()); Appl::Instance()->Main(argc, argv); #endif if(0) { //test of DEM RPM double effective_bulk_modulus2; double effective_shear_modulus2; double effective_density2; DEMTools::DebugTestCalcEffectiveModulus2(effective_bulk_modulus2, effective_shear_modulus2, effective_density2); double effective_bulk_modulus; double effective_shear_modulus; double effective_density; DEMTools::DebugTestCalcEffectiveModulus4(effective_bulk_modulus, effective_shear_modulus, effective_density); //float tmp10 = 5.0f; } if (argc != 2) { printf("Usage: %s modelfile\n",argv[0]); exit(1); } LogKit::SetScreenLog(LogKit::L_Low); LogKit::StartBuffering(); Program program( 4, // Major version 0, // Minor version 0, // Patch number for bug fixes //"", // Use empty string "" for release versions " beta", // Use empty string "" for release versions -1, // Validity of licence in days (-1 = infinite) //"NORSAR", // Who this copy of CRAVA is licensed to "Norsk Regnesentral/Statoil", AddLicenceInformation); double wall=0.0, cpu=0.0; TimeKit::getTime(wall,cpu); try { XmlModelFile modelFile(argv[1]); InputFiles * inputFiles = modelFile.getInputFiles(); ModelSettings * modelSettings = modelFile.getModelSettings(); CommonData * common_data = NULL; ModelGeneral * modelGeneral = NULL; ModelAVOStatic * modelAVOstatic = NULL; ModelGravityStatic * modelGravityStatic = NULL; CravaResult * crava_result = new CravaResult(); NRLib::Random::Initialize(); if (modelFile.getParsingFailed()) { LogKit::SetFileLog(IO::FileLog()+IO::SuffixTextFiles(), modelSettings->getLogLevel()); LogKit::EndBuffering(); return(1); } std::string errTxt = inputFiles->addInputPathAndCheckFiles(); if(errTxt != "") { LogKit::WriteHeader("Error opening files"); LogKit::LogMessage(LogKit::Error, "\n"+errTxt); LogKit::LogFormatted(LogKit::Error,"\nAborting\n"); LogKit::SetFileLog(IO::FileLog()+IO::SuffixTextFiles(), modelSettings->getLogLevel()); LogKit::EndBuffering(); return(1); } /*------------------------------------------------------------ READ COMMON DATA AND PERFORM ESTIMATION BASED ON INPUT FILES AND MODEL SETTINGS -------------------------------------------------------------*/ common_data = new CommonData(modelSettings, inputFiles); int n_intervals = common_data->GetMultipleIntervalGrid()->GetNIntervals(); std::vector<SeismicParametersHolder> seismicParametersIntervals(common_data->GetMultipleIntervalGrid()->GetNIntervals()); if(modelSettings->getEstimationMode() == false) { //Loop over intervals for (int i_interval = 0; i_interval < n_intervals; i_interval++) { modelGeneral = NULL; modelAVOstatic = NULL; modelGravityStatic = NULL; std::string interval_text = ""; if (n_intervals > 1) interval_text = " for interval " + NRLib::ToString(common_data->GetMultipleIntervalGrid()->GetIntervalName(i_interval)); LogKit::WriteHeader("Setting up model" + interval_text); //Priormodell i 3D const Simbox * simbox = common_data->GetMultipleIntervalGrid()->GetIntervalSimbox(i_interval); //Expectationsgrids. NRLib::Grid to FFTGrid, fills in padding LogKit::LogFormatted(LogKit::Low,"\nBackground model..\n"); seismicParametersIntervals[i_interval].setBackgroundParametersInterval(common_data->GetBackgroundParametersInterval(i_interval), simbox->GetNXpad(), simbox->GetNYpad(), simbox->GetNZpad()); //Background grids are overwritten in avoinversion std::string interval_name = common_data->GetMultipleIntervalGrid()->GetIntervalName(i_interval); crava_result->AddBackgroundVp(seismicParametersIntervals[i_interval].GetMeanVp()); crava_result->AddBackgroundVs(seismicParametersIntervals[i_interval].GetMeanVs()); crava_result->AddBackgroundRho(seismicParametersIntervals[i_interval].GetMeanRho()); //Release background grids from common_data. common_data->ReleaseBackgroundGrids(i_interval, 0); common_data->ReleaseBackgroundGrids(i_interval, 1); common_data->ReleaseBackgroundGrids(i_interval, 2); //korrelasjonsgrid (2m) float corr_grad_I = 0.0f; float corr_grad_J = 0.0f; common_data->GetCorrGradIJ(corr_grad_I, corr_grad_J, simbox); float dt = static_cast<float>(simbox->getdz()); float low_cut = modelSettings->getLowCut(); int low_int_cut = int(floor(low_cut*(simbox->GetNZpad()*0.001*dt))); // computes the integer which corresponds to the low cut frequency. if (!modelSettings->getForwardModeling()) { LogKit::LogFormatted(LogKit::Low,"\nCorrelation parameters..\n"); seismicParametersIntervals[i_interval].setCorrelationParameters(common_data->GetPriorCovEst(), common_data->GetPriorParamCov(i_interval), common_data->GetPriorAutoCov(i_interval), common_data->GetPriorCorrT(i_interval), common_data->GetPriorCorrXY(i_interval), low_int_cut, corr_grad_I, corr_grad_J, simbox->getnx(), simbox->getny(), simbox->getnz(), simbox->GetNXpad(), simbox->GetNYpad(), simbox->GetNZpad(), simbox->getdz()); } //ModelGeneral, modelAVOstatic, modelGravityStatic, (modelTravelTimeStatic?) LogKit::LogFormatted(LogKit::Low,"\nStatic models..\n"); setupStaticModels(modelGeneral, modelAVOstatic, //modelGravityStatic, modelSettings, inputFiles, seismicParametersIntervals[i_interval], common_data, i_interval); //Loop over dataset //i. ModelAVODynamic //ii. Inversion //iii. Move model one time-step ahead //Do not run avoinversion if forward modelleing or estimationmode //Syntetic seismic is generated in CravaResult if (!modelSettings->getForwardModeling() && !modelSettings->getEstimationMode()) { int eventType; int eventIndex; modelGeneral->GetTimeLine()->ReSet(); double time; int time_index = 0; bool first = true; while(modelGeneral->GetTimeLine()->GetNextEvent(eventType, eventIndex, time) == true) { if (first == false) { modelGeneral->AdvanceTime(time_index, seismicParametersIntervals[i_interval], modelSettings); time_index++; } bool failed = false; switch(eventType) { case TimeLine::AVO : { LogKit::LogFormatted(LogKit::Low,"\nAVO inversion, time lapse "+ CommonData::ConvertIntToString(time_index) +"..\n"); failed = doTimeLapseAVOInversion(modelSettings, modelGeneral, modelAVOstatic, common_data, seismicParametersIntervals[i_interval], eventIndex, i_interval); break; } case TimeLine::TRAVEL_TIME : { LogKit::LogFormatted(LogKit::Low,"\nTravel time inversion, time lapse "+ CommonData::ConvertIntToString(time_index) +"..\n"); //failed = doTimeLapseTravelTimeInversion(modelSettings, // modelGeneral, // modelTravelTimeStatic, // inputFiles, // eventIndex, // seismicParametersIntervals[i_interval]); break; } case TimeLine::GRAVITY : { LogKit::LogFormatted(LogKit::Low,"\nGravimetric inversion, time lapse "+ CommonData::ConvertIntToString(time_index) +"..\n"); //failed = doTimeLapseGravimetricInversion(modelSettings, // modelGeneral, // modelGravityStatic, // common_data, // eventIndex, // seismicParametersIntervals[i_interval]); break; } default : failed = true; break; } if(failed) return(1); first = false; } } crava_result->AddBlockedLogs(modelGeneral->GetBlockedWells()); } //interval_loop } if (n_intervals == 1) crava_result->SetBgBlockedLogs(common_data->GetBgBlockedLogs()); if (modelSettings->getEstimationMode() == true) { LogKit::WriteHeader("Combine Results and Write to Files"); if (modelSettings->getEstimateBackground() == true && n_intervals == 1 && ((modelSettings->getOutputGridFormat() & IO::CRAVA) > 0)) { const Simbox * simbox = common_data->GetMultipleIntervalGrid()->GetIntervalSimbox(0); seismicParametersIntervals[0].setBackgroundParametersInterval(common_data->GetBackgroundParametersInterval(0), simbox->GetNXpad(), simbox->GetNYpad(), simbox->GetNZpad()); crava_result->AddBackgroundVp(seismicParametersIntervals[0].GetMeanVp()); crava_result->AddBackgroundVs(seismicParametersIntervals[0].GetMeanVs()); crava_result->AddBackgroundRho(seismicParametersIntervals[0].GetMeanRho()); } crava_result->WriteEstimationResults(modelSettings, common_data); } else { //Combine interval grids to one grid per parameter LogKit::WriteHeader("Combine Results and Write to Files"); crava_result->CombineResults(modelSettings, common_data, seismicParametersIntervals); crava_result->WriteResults(modelSettings, common_data, seismicParametersIntervals[0]); if(modelSettings->getDo4DInversion()) { bool failed; if(modelSettings->getDo4DRockPhysicsInversion()) { LogKit::WriteHeader("4D Rock Physics Inversion"); failed = modelGeneral->Do4DRockPhysicsInversion(modelSettings); if(failed) return(1); } } } if (modelSettings->getDoInversion() && FFTGrid::getMaxAllowedGrids() != FFTGrid::getMaxAllocatedGrids()) { //NBNB-PAL: Memory check is bogus at the moment. Include again when 4.0 release is fixed.") //LogKit::LogFormatted(LogKit::Warning,"\nWARNING: A memory requirement inconsistency has been detected:"); //LogKit::LogFormatted(LogKit::Warning,"\n Maximum number of grids requested : %2d",FFTGrid::getMaxAllowedGrids()); //LogKit::LogFormatted(LogKit::Warning,"\n Maximum number of grids allocated : %2d",FFTGrid::getMaxAllocatedGrids()); //TaskList::addTask("The memory usage estimate failed. Please send your XML-model file and the logFile.txt\n to the CRAVA developers."); } Timings::setTimeTotal(wall,cpu); Timings::reportAll(LogKit::Medium); TaskList::viewAllTasks(modelSettings->getTaskFileFlag()); delete modelAVOstatic; delete modelGeneral; delete common_data; delete crava_result; crava_result = NULL; delete modelSettings; modelSettings = NULL; delete inputFiles; inputFiles = NULL; Timings::reportTotal(); LogKit::LogFormatted(LogKit::Low,"\n*** CRAVA closing ***\n"); LogKit::LogFormatted(LogKit::Low,"\n*** CRAVA finished ***\n"); // // The exit(0) is needed to get the gprof output file gmon.out ... // exit(0); } catch (std::bad_alloc& ba) { std::cerr << "Out of memory: " << ba.what() << std::endl; std::string error_message = std::string("Out of memory: ") + ba.what() + "\n"; LogKit::LogMessage(LogKit::Error, error_message); } #if defined(COMPILE_STORM_MODULES_FOR_RMS) Feature& feature = FEATURE_INVERSION_EXE; LicenseSystem::Instance()->CheckIn(&feature); #endif LogKit::EndLog(); //Debug messages may occur when variables go out of scope above, so this must be the final call. return(0); }
BOOL UpdateChecker::Parse(LPCSTR html, UINT size) { #ifdef _UNICODE TCHAR* res = HTMLText2Unicode(html, size); #else TCHAR* res = new TCHAR[size + 1]; _tcsncpy(res, &file[0], file.size()); res[html] = 0; #endif std::tstring xmlTag = XMLGetText(res, _T("version")); if (xmlTag.empty() || xmlTag.size() >= 100) return FALSE; m_checkResult.onlineVersion = FileVersion(); TCHAR bf[100]; _tcsncpy(bf, xmlTag.c_str(), xmlTag.size()); bf[xmlTag.size()] = 0; TCHAR* token = 0; token = _tcstok(bf, _T(".")); INT curToken = 0; while (token != NULL) { INT num = _ttoi(token); switch (curToken) { case 0: m_checkResult.onlineVersion.Major = num; break; case 1: m_checkResult.onlineVersion.Minor = num; break; case 2: m_checkResult.onlineVersion.Build = num; break; case 3: m_checkResult.onlineVersion.SubBuild = num; break; default: num = -1; ASSERT(0); break; } if (num == -1) break; curToken++; token = _tcstok(NULL, _T(".")); } m_checkResult.downloadURL = XMLGetText(res, _T("downloadurl")); m_checkResult.infoURL = XMLGetText(res, _T("infourl")); xmlTag = XMLGetText(res, _T("severity")); if (!xmlTag.empty()) { INT num = _ttoi(xmlTag.c_str()); if (num >= SEV_NoNeed && num< SEV_Last) m_checkResult.severity = (UpdateSeverity)num; } delete res; //m_checkResult.severity = SEV_Maintenance; //m_checkResult.currentVersion = FileVersion(1,1); //m_checkResult.onlineVersion = FileVersion(1,2); //m_checkResult.downloadURL = _T("http://www.defsite.com/test.zip"); //m_checkResult.infoURL = _T("http://www.defsite.com/test.php?maj=1.2.32.0"); return TRUE; }