int main(const int argc, const char* const argv[]) { if (argc == 1) show_usage(); const std::string filename = argv[1]; if (filename == "-v" or filename == "--version") version_information(); if (argc >= 3 and filename == std::string(argv[2])) { errout << "Output filename: \"" << argv[2] << "\" identical with input filename."; std::exit(code(Error::file_writing)); } if (argc >= 4 and filename == std::string(argv[3])) { errout << "Log filename: \"" << argv[3] << "\" identical with input filename."; std::exit(code(Error::file_writing)); } const InOut::ConformityLevel conlev = (argc >= 5) ? InOut::s2conlev(argv[4]) : InOut::ConformityLevel::normal; const LogLevel loglev = (argc >= 6) ? s2loglev(argv[5]) : LogLevel::normal; set_output(argc, argv, solout, logout, errout); const InOut::InputStream in(filename, errout); Input::ReadDimacs rd(*in, errout, conlev); const ClauseSets::DClauseSet& F = rd(); const Encodings::Encoding enc(F); const Translations::Translation trans(F,enc); const ClauseSets::CLS G = trans(); output(filename, conlev, F, enc, trans, G, loglev); }
void CUpdater::ParseData() { const wxLongLong ownVersionNumber = CBuildInfo::ConvertToVersionNumber(CBuildInfo::GetVersion()); version_information_ = version_information(); wxString raw_version_information = raw_version_information_; while( !raw_version_information.empty() ) { wxString line; int pos = raw_version_information.Find('\n'); if (pos != -1) { line = raw_version_information.Left(pos); raw_version_information = raw_version_information.Mid(pos + 1); } else { line = raw_version_information; raw_version_information = _T(""); } wxStringTokenizer tokens(line, _T(" \t\n"), wxTOKEN_STRTOK); if( !tokens.CountTokens() ) { // After empty line, changelog follows version_information_.changelog = raw_version_information; version_information_.changelog.Trim(true); version_information_.changelog.Trim(false); break; } if( tokens.CountTokens() != 2 && tokens.CountTokens() != 6 ) { continue; } wxString type = tokens.GetNextToken(); wxString versionOrDate = tokens.GetNextToken(); if (type == _T("nightly")) { wxDateTime nightlyDate; if (!nightlyDate.ParseDate(versionOrDate)) continue; wxDateTime buildDate = CBuildInfo::GetBuildDate(); if (!buildDate.IsValid() || !nightlyDate.IsValid() || nightlyDate <= buildDate) continue; } else { wxLongLong v = CBuildInfo::ConvertToVersionNumber(versionOrDate); if (v <= ownVersionNumber) continue; } build* b = 0; if( type == _T("nightly") && UpdatableBuild() ) { b = &version_information_.nightly_; } else if( type == _T("release") ) { b = &version_information_.stable_; } else if( type == _T("beta") ) { b = &version_information_.beta_; } if( b && UpdatableBuild() ) { b->version_ = versionOrDate; if( tokens.CountTokens() == 4 ) { wxString url = tokens.GetNextToken(); wxString sizestr = tokens.GetNextToken(); wxString hash_algo = tokens.GetNextToken(); wxString hash = tokens.GetNextToken(); if( GetFilename(url).empty() ) { continue; } if( hash_algo.CmpNoCase(_T("sha512")) ) { continue; } unsigned long long l = 0; if( !sizestr.ToULongLong(&l) ) { continue; } b->url_ = url; b->size_ = l; b->hash_ = hash; } } } version_information_.update_available(); if( version_information_.empty() ) { raw_version_information_.clear(); } COptions::Get()->SetOption( OPTION_UPDATECHECK_NEWVERSION, raw_version_information_ ); }
void CUpdater::ParseData() { const wxLongLong ownVersionNumber = CBuildInfo::ConvertToVersionNumber(CBuildInfo::GetVersion().c_str()); version_information_ = version_information(); wxString raw_version_information = raw_version_information_; log_ += wxString::Format(_("Parsing %d bytes of version information.\n"), static_cast<int>(raw_version_information.size())); while( !raw_version_information.empty() ) { wxString line; int pos = raw_version_information.Find('\n'); if (pos != -1) { line = raw_version_information.Left(pos); raw_version_information = raw_version_information.Mid(pos + 1); } else { line = raw_version_information; raw_version_information.clear(); } wxStringTokenizer tokens(line, _T(" \t\n"), wxTOKEN_STRTOK); if( !tokens.CountTokens() ) { // After empty line, changelog follows version_information_.changelog = raw_version_information; version_information_.changelog.Trim(true); version_information_.changelog.Trim(false); if( COptions::Get()->GetOptionVal(OPTION_LOGGING_DEBUGLEVEL) == 4 ) { log_ += wxString::Format(_T("Changelog: %s\n"), version_information_.changelog); } break; } if( tokens.CountTokens() != 2 && tokens.CountTokens() != 6 ) { if( COptions::Get()->GetOptionVal(OPTION_LOGGING_DEBUGLEVEL) == 4 ) { log_ += wxString::Format(_T("Skipping line with %d tokens\n"), static_cast<int>(tokens.CountTokens())); } continue; } wxString type = tokens.GetNextToken(); wxString versionOrDate = tokens.GetNextToken(); if (type == _T("nightly")) { wxDateTime nightlyDate; if( !nightlyDate.ParseFormat(versionOrDate, _T("%Y-%m-%d")) ) { if( COptions::Get()->GetOptionVal(OPTION_LOGGING_DEBUGLEVEL) == 4 ) { log_ += _T("Could not parse nightly date\n"); } continue; } wxDateTime buildDate = CBuildInfo::GetBuildDate(); if (!buildDate.IsValid() || !nightlyDate.IsValid() || nightlyDate <= buildDate) { if( COptions::Get()->GetOptionVal(OPTION_LOGGING_DEBUGLEVEL) == 4 ) { log_ += _T("Nightly isn't newer\n"); } continue; } } else { wxLongLong v = CBuildInfo::ConvertToVersionNumber(versionOrDate.c_str()); if (v <= ownVersionNumber) continue; } build* b = 0; if( type == _T("nightly") && UpdatableBuild() ) { b = &version_information_.nightly_; } else if( type == _T("release") ) { b = &version_information_.stable_; } else if( type == _T("beta") ) { b = &version_information_.beta_; } if( b ) { b->version_ = versionOrDate; if( UpdatableBuild() && tokens.CountTokens() == 4 ) { wxString const url = tokens.GetNextToken(); wxString const sizestr = tokens.GetNextToken(); wxString const hash_algo = tokens.GetNextToken(); wxString const hash = tokens.GetNextToken(); if( GetFilename(url).empty() ) { if( COptions::Get()->GetOptionVal(OPTION_LOGGING_DEBUGLEVEL) == 4 ) { log_ += wxString::Format(_T("Could not extract filename from URL: %s\n"), url); } continue; } if( hash_algo.CmpNoCase(_T("sha512")) ) { continue; } unsigned long long l = 0; if( !sizestr.ToULongLong(&l) ) { if( COptions::Get()->GetOptionVal(OPTION_LOGGING_DEBUGLEVEL) == 4 ) { log_ += wxString::Format(_T("Could not parse size: %s"), sizestr); } continue; } b->url_ = url; b->size_ = l; b->hash_ = hash; // @translator: Two examples: Found new nightly 2014-04-03\n, Found new release 3.9.0.1\n log_ += wxString::Format(_("Found new %s %s\n"), type, b->version_); } } } version_information_.update_available(); COptions::Get()->SetOption( OPTION_UPDATECHECK_NEWVERSION, raw_version_information_ ); }