int main(int argc, char** argv, const char** envp) { // Setup Google Breakpad exception handler #ifdef Q_OS_LINUX google_breakpad::ExceptionHandler eh("/tmp", NULL, Utils::exceptionHandler, NULL, true); #endif #ifdef Q_OS_MAC google_breakpad::ExceptionHandler eh("/tmp", NULL, Utils::exceptionHandler, NULL, true, NULL); #endif QApplication app(argc, argv); app.setWindowIcon(QIcon(":/phantomjs-icon.png")); app.setApplicationName("PhantomJS"); app.setOrganizationName("Ofi Labs"); app.setOrganizationDomain("www.ofilabs.com"); app.setApplicationVersion(PHANTOMJS_VERSION_STRING); // Prepare the "env" singleton using the environment variables Env::instance()->parse(envp); // Get the Phantom singleton Phantom *phantom = Phantom::instance(); // Registering an alternative Message Handler Utils::printDebugMessages = phantom->printDebugMessages(); qInstallMsgHandler(Utils::messageHandler); signal(SIGALRM, timeout); FILE *in; in = fopen("timeout.txt", "r"); if (in) { int t; fscanf(in, "%d", &t); alarm(t); fclose(in); } // Start script execution if (phantom->execute()) { app.exec(); } alarm(0); // End script execution: delete the phantom singleton and set execution return value int retVal = phantom->returnValue(); delete phantom; return retVal; }
static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params) { FeatureType type = (FeatureType)params[1]; char *name; pContext->LocalToString(params[2], &name); if (sharesys->TestFeature(pContext->GetRuntime(), type, name) != FeatureStatus_Available) { char buffer[255]; char *msg = buffer; char default_message[255]; SMPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext()); DetectExceptions eh(pContext); g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 3); if (eh.HasException()) buffer[0] = '\0'; if (buffer[0] == '\0') { g_pSM->Format(default_message, sizeof(default_message), "Feature \"%s\" not available", name); msg = default_message; } pPlugin->SetErrorState(Plugin_Error, "%s", msg); if (!eh.HasException()) pContext->ReportFatalError("%s", msg); return 0; } return 1; }
int Z3_API Z3_algebraic_eval(Z3_context c, Z3_ast p, unsigned n, Z3_ast a[]) { Z3_TRY; LOG_Z3_algebraic_eval(c, p, n, a); RESET_ERROR_CODE(); polynomial::manager & pm = mk_c(c)->pm(); polynomial_ref _p(pm); polynomial::scoped_numeral d(pm.m()); expr2polynomial converter(mk_c(c)->m(), pm, 0, true); if (!converter.to_polynomial(to_expr(p), _p, d) || static_cast<unsigned>(max_var(_p)) >= n) { SET_ERROR_CODE(Z3_INVALID_ARG); return 0; } algebraic_numbers::manager & _am = am(c); scoped_anum_vector as(_am); if (!to_anum_vector(c, n, a, as)) { SET_ERROR_CODE(Z3_INVALID_ARG); return 0; } { cancel_eh<algebraic_numbers::manager> eh(_am); api::context::set_interruptable si(*(mk_c(c)), eh); scoped_timer timer(mk_c(c)->params().m_timeout, &eh); vector_var2anum v2a(as); int r = _am.eval_sign_at(_p, v2a); if (r > 0) return 1; else if (r < 0) return -1; else return 0; } Z3_CATCH_RETURN(0); }
static cell_t SetFailState(IPluginContext *pContext, const cell_t *params) { char *str; SMPlugin *pPlugin; pContext->LocalToString(params[1], &str); pPlugin = scripts->FindPluginByContext(pContext->GetContext()); if (params[0] == 1) { pPlugin->SetErrorState(Plugin_Failed, "%s", str); return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", str); } else { char buffer[2048]; { DetectExceptions eh(pContext); g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); if (eh.HasException()) { pPlugin->SetErrorState(Plugin_Failed, "%s", str); return 0; } pPlugin->SetErrorState(Plugin_Failed, "%s", buffer); pContext->ReportFatalError("%s", buffer); return 0; } } return 0; }
static Z3_lbool _solver_check(Z3_context c, Z3_solver s, unsigned num_assumptions, Z3_ast const assumptions[]) { for (unsigned i = 0; i < num_assumptions; i++) { if (!is_expr(to_ast(assumptions[i]))) { SET_ERROR_CODE(Z3_INVALID_ARG, "assumption is not an expression"); return Z3_L_UNDEF; } } expr * const * _assumptions = to_exprs(assumptions); unsigned timeout = to_solver(s)->m_params.get_uint("timeout", mk_c(c)->get_timeout()); unsigned rlimit = to_solver(s)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit()); bool use_ctrl_c = to_solver(s)->m_params.get_bool("ctrl_c", false); cancel_eh<reslimit> eh(mk_c(c)->m().limit()); api::context::set_interruptable si(*(mk_c(c)), eh); lbool result; { scoped_ctrl_c ctrlc(eh, false, use_ctrl_c); scoped_timer timer(timeout, &eh); scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit); try { result = to_solver_ref(s)->check_sat(num_assumptions, _assumptions); } catch (z3_exception & ex) { to_solver_ref(s)->set_reason_unknown(eh); if (!mk_c(c)->m().canceled()) { mk_c(c)->handle_exception(ex); } return Z3_L_UNDEF; } } if (result == l_undef) { to_solver_ref(s)->set_reason_unknown(eh); } return static_cast<Z3_lbool>(result); }
Server::Server(Settings& settings) : _settings(settings), _admMessageQueue(new Tools::SimpleMessageQueue(1)) { Tools::debug << "Server::Server()\n"; this->_rcon = new Rcon::Rcon(*this); this->_resourceManager = new Database::ResourceManager(*this); this->_clientManager = new ClientManagement::ClientManager(*this, *this->_admMessageQueue); this->_game = new Game::Game(*this, *this->_admMessageQueue); Network::Network::NewConnectionHandler nch(std::bind(&ClientManagement::ClientManager::HandleNewClient, this->_clientManager, std::placeholders::_1, std::placeholders::_2)); Network::Network::PacketHandler ph(std::bind(&ClientManagement::ClientManager::HandlePacket, this->_clientManager, std::placeholders::_1, std::placeholders::_2)); Network::Network::ErrorHandler eh(std::bind(&ClientManagement::ClientManager::HandleClientError, this->_clientManager, std::placeholders::_1)); this->_network = new Network::Network(*this, nch, ph, eh); }
int main(int argc, char* argv[]) { google_breakpad::MinidumpDescriptor descriptor("."); google_breakpad::ExceptionHandler eh(descriptor, NULL, DumpCallback, NULL, true, -1); Crash(); return 0; }
virtual void execute(cmd_context & ctx) { if (m_target == 0) throw cmd_exception("invalid simplify command, argument expected"); expr_ref r(ctx.m()); proof_ref pr(ctx.m()); if (m_params.get_bool("som", false)) m_params.set_bool("flat", true); th_rewriter s(ctx.m(), m_params); unsigned cache_sz; unsigned num_steps = 0; unsigned timeout = m_params.get_uint("timeout", UINT_MAX); unsigned rlimit = m_params.get_uint("rlimit", UINT_MAX); bool failed = false; cancel_eh<reslimit> eh(ctx.m().limit()); { scoped_rlimit _rlimit(ctx.m().limit(), rlimit); scoped_ctrl_c ctrlc(eh); scoped_timer timer(timeout, &eh); cmd_context::scoped_watch sw(ctx); try { s(m_target, r, pr); } catch (z3_error & ex) { throw ex; } catch (z3_exception & ex) { ctx.regular_stream() << "(error \"simplifier failed: " << ex.msg() << "\")" << std::endl; failed = true; r = m_target; } cache_sz = s.get_cache_size(); num_steps = s.get_num_steps(); s.cleanup(); } if (m_params.get_bool("print", true)) { ctx.display(ctx.regular_stream(), r); ctx.regular_stream() << std::endl; } if (!failed && m_params.get_bool("print_proofs", false)) { ast_smt_pp pp(ctx.m()); pp.set_logic(ctx.get_logic().str().c_str()); pp.display_expr_smt2(ctx.regular_stream(), pr.get()); ctx.regular_stream() << std::endl; } if (m_params.get_bool("print_statistics", false)) { shared_occs s1(ctx.m()); if (!failed) s1(r); unsigned long long max_mem = memory::get_max_used_memory(); unsigned long long mem = memory::get_allocation_size(); ctx.regular_stream() << "(:time " << std::fixed << std::setprecision(2) << ctx.get_seconds() << " :num-steps " << num_steps << " :memory " << std::fixed << std::setprecision(2) << static_cast<double>(mem)/static_cast<double>(1024*1024) << " :max-memory " << std::fixed << std::setprecision(2) << static_cast<double>(max_mem)/static_cast<double>(1024*1024) << " :cache-size: " << cache_sz << " :num-nodes-before " << get_num_exprs(m_target); if (!failed) ctx.regular_stream() << " :num-shared " << s1.num_shared() << " :num-nodes " << get_num_exprs(r); ctx.regular_stream() << ")" << std::endl; } }
Z3_ast_vector Z3_API Z3_algebraic_roots(Z3_context c, Z3_ast p, unsigned n, Z3_ast a[]) { Z3_TRY; LOG_Z3_algebraic_roots(c, p, n, a); RESET_ERROR_CODE(); polynomial::manager & pm = mk_c(c)->pm(); polynomial_ref _p(pm); polynomial::scoped_numeral d(pm.m()); expr2polynomial converter(mk_c(c)->m(), pm, 0, true); if (!converter.to_polynomial(to_expr(p), _p, d) || static_cast<unsigned>(max_var(_p)) >= n + 1) { SET_ERROR_CODE(Z3_INVALID_ARG); return 0; } algebraic_numbers::manager & _am = am(c); scoped_anum_vector as(_am); if (!to_anum_vector(c, n, a, as)) { SET_ERROR_CODE(Z3_INVALID_ARG); return 0; } scoped_anum_vector roots(_am); { cancel_eh<algebraic_numbers::manager> eh(_am); api::context::set_interruptable si(*(mk_c(c)), eh); scoped_timer timer(mk_c(c)->params().m_timeout, &eh); vector_var2anum v2a(as); _am.isolate_roots(_p, v2a, roots); } Z3_ast_vector_ref* result = alloc(Z3_ast_vector_ref, mk_c(c)->m()); mk_c(c)->save_object(result); for (unsigned i = 0; i < roots.size(); i++) { result->m_ast_vector.push_back(au(c).mk_numeral(roots.get(i), false)); } RETURN_Z3(of_ast_vector(result)); Z3_CATCH_RETURN(0); }
Z3_lbool Z3_API Z3_check_and_get_model(Z3_context c, Z3_model * m) { Z3_TRY; LOG_Z3_check_and_get_model(c, m); RESET_ERROR_CODE(); CHECK_SEARCHING(c); cancel_eh<smt::kernel> eh(mk_c(c)->get_smt_kernel()); api::context::set_interruptable(*(mk_c(c)), eh); flet<bool> _model(mk_c(c)->fparams().m_model, true); lbool result; try { model_ref _m; result = mk_c(c)->check(_m); if (m) { if (_m) { Z3_model_ref * m_ref = alloc(Z3_model_ref); m_ref->m_model = _m; // Must bump reference counter for backward compatibility reasons. // Don't need to invoke save_object, since the counter was bumped m_ref->inc_ref(); *m = of_model(m_ref); } else { *m = 0; } } } catch (z3_exception & ex) { mk_c(c)->handle_exception(ex); RETURN_Z3_check_and_get_model static_cast<Z3_lbool>(l_undef); } RETURN_Z3_check_and_get_model static_cast<Z3_lbool>(result); Z3_CATCH_RETURN(Z3_L_UNDEF); }
static Z3_apply_result _tactic_apply(Z3_context c, Z3_tactic t, Z3_goal g, params_ref p) { goal_ref new_goal; new_goal = alloc(goal, *to_goal_ref(g)); Z3_apply_result_ref * ref = alloc(Z3_apply_result_ref, mk_c(c)->m()); mk_c(c)->save_object(ref); unsigned timeout = p.get_uint("timeout", UINT_MAX); bool use_ctrl_c = p.get_bool("ctrl_c", false); cancel_eh<reslimit> eh(mk_c(c)->m().limit()); to_tactic_ref(t)->updt_params(p); api::context::set_interruptable si(*(mk_c(c)), eh); { scoped_ctrl_c ctrlc(eh, false, use_ctrl_c); scoped_timer timer(timeout, &eh); try { exec(*to_tactic_ref(t), new_goal, ref->m_subgoals, ref->m_mc, ref->m_pc, ref->m_core); return of_apply_result(ref); } catch (z3_exception & ex) { mk_c(c)->handle_exception(ex); return 0; } } }
void KNewStuff2Test::entryTest() { kDebug() << "-- test kns2 entry class"; QDomDocument doc; QFile f(QString("%1/testdata/entry.xml").arg(KNSSRCDIR)); if (!f.open(QIODevice::ReadOnly)) { kDebug() << "Error loading entry file."; quitTest(); } if (!doc.setContent(&f)) { kDebug() << "Error parsing entry file."; f.close(); quitTest(); } f.close(); KNS::EntryHandler eh(doc.documentElement()); KNS::Entry e = eh.entry(); kDebug() << "-- xml->entry test result: " << eh.isValid(); KNS::EntryHandler eh2(e); QDomElement exml = eh2.entryXML(); kDebug() << "-- entry->xml test result: " << eh.isValid(); if (!eh.isValid()) { quitTest(); } else { QTextStream out(stdout); out << exml; } }
void ICQInfo::apply() { ICQUserData *data = m_data; if (data == NULL){ data = &m_client->data.owner; m_client->setRandomChatGroup(getComboValue(cmbRandom, chat_groups)); } string encoding; int n = cmbEncoding->currentItem(); QString t = cmbEncoding->currentText(); if (n){ n--; QStringList l; const ENCODING *e; QStringList main; for (e = ICQClient::encodings; e->language; e++){ if (!e->bMain) continue; main.append(i18n(e->language) + " (" + e->codec + ")"); } main.sort(); QStringList::Iterator it; for (it = main.begin(); it != main.end(); ++it){ l.append(*it); } QStringList noMain; for (e = ICQClient::encodings; e->language; e++){ if (e->bMain) continue; noMain.append(i18n(e->language) + " (" + e->codec + ")"); } noMain.sort(); for (it = noMain.begin(); it != noMain.end(); ++it){ l.append(*it); } for (it = l.begin(); it != l.end(); ++it){ if (n-- == 0){ QString str = *it; int n = str.find('('); str = str.mid(n + 1); n = str.find(')'); str = str.left(n); encoding = str.latin1(); break; } } } if (!set_str(&data->Encoding, encoding.c_str())) return; Contact *contact; if (data->Uin ? m_client->findContact(number(data->Uin).c_str(), NULL, false, contact) : m_client->findContact(data->Screen, NULL, false, contact)){ Event e(EventContactChanged, contact); e.process(); Event eh(EventHistoryConfig, (void*)(contact->id())); eh.process(); } }
static cell_t PrintHintText(IPluginContext *pContext, const cell_t *params) { int client = params[1]; CPlayer *pPlayer = g_Players.GetPlayerByIndex(client); if (!pPlayer) { return pContext->ThrowNativeError("Client index %d is invalid", client); } if (!pPlayer->IsInGame()) { return pContext->ThrowNativeError("Client %d is not in game", client); } g_SourceMod.SetGlobalTarget(client); char buffer[254]; { DetectExceptions eh(pContext); g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2); if (eh.HasException()) return 0; } if (!g_HL2.HintTextMsg(client, buffer)) { return pContext->ThrowNativeError("Could not send a usermessage"); } return 1; }
static cell_t LogToFileEx(IPluginContext *pContext, const cell_t *params) { char *file; pContext->LocalToString(params[1], &file); char path[PLATFORM_MAX_PATH]; g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file); FILE *fp = fopen(path, "at"); if (!fp) { return pContext->ThrowNativeError("Could not open file \"%s\"", path); } char buffer[2048]; { DetectExceptions eh(pContext); g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2); if (eh.HasException()) { fclose(fp); return 0; } } g_Logger.LogToOpenFile(fp, "%s", buffer); fclose(fp); return 1; }
virtual void execute(cmd_context& ctx) { if (m_target == 0) { throw cmd_exception("invalid query command, argument expected"); } datalog::context& dlctx = m_dl_ctx->get_dl_context(); set_background(ctx); dlctx.updt_params(m_params); unsigned timeout = m_params.get_uint(":timeout", UINT_MAX); cancel_eh<datalog::context> eh(dlctx); lbool status = l_undef; { scoped_ctrl_c ctrlc(eh); scoped_timer timer(timeout, &eh); cmd_context::scoped_watch sw(ctx); try { status = dlctx.query(m_target); } catch (z3_error & ex) { throw ex; } catch (z3_exception& ex) { ctx.regular_stream() << "(error \"query failed: " << ex.msg() << "\")" << std::endl; } dlctx.cleanup(); } switch (status) { case l_false: ctx.regular_stream() << "unsat\n"; print_certificate(ctx); break; case l_true: ctx.regular_stream() << "sat\n"; print_answer(ctx); print_certificate(ctx); break; case l_undef: ctx.regular_stream() << "unknown\n"; switch(dlctx.get_status()) { case datalog::INPUT_ERROR: break; case datalog::MEMOUT: ctx.regular_stream() << "memory bounds exceeded\n"; break; case datalog::TIMEOUT: ctx.regular_stream() << "timeout\n"; break; case datalog::OK: break; default: UNREACHABLE(); } break; } print_statistics(ctx); m_target = 0; }
Z3_lbool Z3_API Z3_solver_get_consequences(Z3_context c, Z3_solver s, Z3_ast_vector assumptions, Z3_ast_vector variables, Z3_ast_vector consequences) { Z3_TRY; LOG_Z3_solver_get_consequences(c, s, assumptions, variables, consequences); ast_manager& m = mk_c(c)->m(); RESET_ERROR_CODE(); CHECK_SEARCHING(c); init_solver(c, s); expr_ref_vector _assumptions(m), _consequences(m), _variables(m); ast_ref_vector const& __assumptions = to_ast_vector_ref(assumptions); for (ast* e : __assumptions) { if (!is_expr(e)) { _assumptions.finalize(); _consequences.finalize(); _variables.finalize(); SET_ERROR_CODE(Z3_INVALID_USAGE, "assumption is not an expression"); return Z3_L_UNDEF; } _assumptions.push_back(to_expr(e)); } ast_ref_vector const& __variables = to_ast_vector_ref(variables); for (ast* a : __variables) { if (!is_expr(a)) { _assumptions.finalize(); _consequences.finalize(); _variables.finalize(); SET_ERROR_CODE(Z3_INVALID_USAGE, "variable is not an expression"); return Z3_L_UNDEF; } _variables.push_back(to_expr(a)); } lbool result = l_undef; unsigned timeout = to_solver(s)->m_params.get_uint("timeout", mk_c(c)->get_timeout()); unsigned rlimit = to_solver(s)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit()); bool use_ctrl_c = to_solver(s)->m_params.get_bool("ctrl_c", false); cancel_eh<reslimit> eh(mk_c(c)->m().limit()); api::context::set_interruptable si(*(mk_c(c)), eh); { scoped_ctrl_c ctrlc(eh, false, use_ctrl_c); scoped_timer timer(timeout, &eh); scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit); try { result = to_solver_ref(s)->get_consequences(_assumptions, _variables, _consequences); } catch (z3_exception & ex) { to_solver_ref(s)->set_reason_unknown(eh); _assumptions.finalize(); _consequences.finalize(); _variables.finalize(); mk_c(c)->handle_exception(ex); return Z3_L_UNDEF; } } if (result == l_undef) { to_solver_ref(s)->set_reason_unknown(eh); } for (expr* e : _consequences) { to_ast_vector_ref(consequences).push_back(e); } return static_cast<Z3_lbool>(result); Z3_CATCH_RETURN(Z3_L_UNDEF); }
int main(int argc, char *argv[]) { google_breakpad::MinidumpDescriptor descriptor("/tmp"); google_breakpad::ExceptionHandler eh(descriptor, NULL, dumpCallback, NULL, true, -1); printf("pid: %d\n", getpid()); crash(); return 0; }
void tst_sat_local_search(char ** argv, int argc, int& i) { if (argc < i + 2) { std::cout << "require dimacs file name\n"; return; } reslimit limit; params_ref params; sat::solver solver(params, limit); sat::local_search local_search; local_search.import(solver, true); char const* file_name = argv[i + 1]; ++i; int cutoff_time = 1; int v; while (i + 1 < argc) { std::cout << argv[i + 1] << "\n"; // set other ad hoc parameters. if (argv[i + 1][0] == '-' && i + 2 < argc) { switch (argv[i + 1][1]) { case 's': // seed v = atoi(argv[i + 2]); local_search.config().set_random_seed(v); break; case 't': // cutoff_time v = atoi(argv[i + 2]); cutoff_time = v; break; case 'b': // best_known_value v = atoi(argv[i + 2]); local_search.config().set_best_known_value(v); break; default: ++i; v = -1; break; } } ++i; } if (!build_instance(file_name, solver, local_search)) { return; } //std::cout << "local instance built\n"; // set up cancellation/timeout environment. cancel_eh<reslimit> eh(local_search.rlimit()); scoped_ctrl_c ctrlc(eh, false, true); scoped_timer timer(cutoff_time*1000, &eh); local_search.check(); }
void YahooInfo::getEncoding(YahooUserData *data, bool bDefault) { string encoding; int n = cmbEncoding->currentItem(); QString t = cmbEncoding->currentText(); if (n){ n--; QStringList l; const ENCODING *e; QStringList main; for (e = YahooPlugin::core->encodings; e->language; e++){ if (!e->bMain) continue; main.append(i18n(e->language) + " (" + e->codec + ")"); } main.sort(); QStringList::Iterator it; for (it = main.begin(); it != main.end(); ++it){ l.append(*it); } QStringList noMain; for (e = YahooPlugin::core->encodings; e->language; e++){ if (e->bMain) continue; noMain.append(i18n(e->language) + " (" + e->codec + ")"); } noMain.sort(); for (it = noMain.begin(); it != noMain.end(); ++it){ l.append(*it); } for (it = l.begin(); it != l.end(); ++it){ if (n-- == 0){ QString str = *it; int n = str.find('('); str = str.mid(n + 1); n = str.find(')'); str = str.left(n); encoding = str.latin1(); break; } } } if (bDefault) YahooPlugin::core->setDefaultEncoding(encoding.c_str()); if (!set_str(&data->Encoding.ptr, encoding.c_str())) return; if (data->Login.ptr){ Contact *contact = NULL; m_client->findContact(data->Login.ptr, NULL, contact); if (contact){ Event e(EventContactChanged, contact); e.process(); Event eh(EventHistoryConfig, (void*)(contact->id())); eh.process(); } } }
void EditMode::slotAddHeadClicked() { EditHead eh(this, QLCFixtureHead(), m_mode); if (eh.exec() == QDialog::Accepted) { m_mode->insertHead(-1, eh.head()); refreshHeadList(); } }
void LDAPConnectionTest::ConnectionTest() { StartTrace(LDAPConnectionTest.ConnectionTest); ROAnything cConfig; AnyExtensions::Iterator<ROAnything> aEntryIterator(GetTestCaseConfig()); while ( aEntryIterator.Next(cConfig) ) { for ( long l = 0; l < cConfig["NumberOfConnects"].AsLong(1); l++ ) { Anything params; params["Server"] = cConfig["LDAPServer"].AsString(); params["Port"] = cConfig["LDAPPort"].AsLong(); params["Timeout"] = cConfig["LDAPTimeout"].AsLong(); params["ConnectionTimeout"] = cConfig["LDAPConnectionTimeout"].AsLong(0); params["BindName"] = cConfig["LDAPBindName"].AsString(); params["BindPW"] = cConfig["LDAPBindPW"].AsString(); params["PooledConnections"] = cConfig["LDAPPooledConnections"].AsLong(0L); params["RebindTimeout"] = cConfig["LDAPRebindTimeout"].AsLong(3600L); params["TryAutoRebind"] = cConfig["LDAPTryAutoRebind"].AsLong(0L); params["MaxConnections"] = cConfig["LDAPMaxConnections"].AsLong(2L); Context ctx; ParameterMapper pm("ConnectionTestParameterMapper"); ResultMapper rm("ConnectionTestResultMapper"); pm.Initialize("ParameterMapper"); rm.Initialize("ResultMapper"); String da("DataAccess_"); da << aEntryIterator.Index(); LDAPErrorHandler eh(ctx, &pm, &rm, da); eh.PutConnectionParams(params); // connect LDAPConnection lc(params); LDAPConnection::EConnectState eConnectState = lc.DoConnect(params, eh); String result(LDAPConnection::ConnectRetToString(eConnectState)); Trace("Connect result: " << result); // check for errors Anything error; if ( !eh.GetError(error) ) { Trace("No error reported."); } else { TraceAny(error, "Error description:"); } // compare result and expected error assertEqual(cConfig["ConnectRet"].AsString(), result); bool ret = LDAPConnection::IsConnectOk(eConnectState); assertEqual(cConfig["ConnectIsOk"].AsBool(1), ret); if (!ret) { String where; aEntryIterator.SlotName(where); assertAnyCompareEqual(cConfig["Error"], error, String(getConfigFileName()) << ":" << where, '.',':'); } // now release sema and lock lc.ReleaseHandleInfo(); } } }
void HE_Mesh::checkModel(std::vector<ModelProblem>& problems) { for (int f = 0; f < faces.size(); f++) { if (faces[f].edge_idx[0] < 0) { problems.emplace_back("face doesn't know its edges! : " + std::to_string(f)); continue; } if (faces[f].edge_idx[1] < 0) { problems.emplace_back("face doesn't know its edges! : " + std::to_string(f)); continue; } if (faces[f].edge_idx[2] < 0) { problems.emplace_back("face doesn't know its edges! : " + std::to_string(f)); continue; } HE_FaceHandle fh(*this, f); if (fh.edge0().next() != fh.edge1()) problems.emplace_back("disconnected prev-next edges : " + std::to_string(f)); if (fh.edge1().next() != fh.edge2()) problems.emplace_back("disconnected prev-next edges : " + std::to_string(f)); if (fh.edge2().next() != fh.edge0()) problems.emplace_back("disconnected prev-next edges : " + std::to_string(f)); if (fh.edge0().face() != fh) problems.emplace_back("face's edge not connected to face : " + std::to_string(f)); if (fh.edge1().face() != fh) problems.emplace_back("face's edge not connected to face : " + std::to_string(f)); if (fh.edge2().face() != fh) problems.emplace_back("face's edge not connected to face : " + std::to_string(f)); } for (int e = 0; e < edges.size(); e++) { bool hasNull = false; if(edges[e].from_vert_idx < 0) { problems.emplace_back("edge doesn't know its vert! : " + std::to_string(e)); hasNull = true; } if(edges[e].next_edge_idx < 0) { problems.emplace_back("edge doesn't know its next edge! : " + std::to_string(e)); hasNull = true; } if(edges[e].converse_edge_idx < 0) { problems.emplace_back("edge doesn't know its converse! : " + std::to_string(e)); hasNull = true; } if(edges[e].face_idx < 0) { problems.emplace_back("edge doesn't know its face! : " + std::to_string(e)); hasNull = true; } if (hasNull) continue; HE_EdgeHandle eh(*this, e); if(eh.converse().converse() != eh) problems.emplace_back("edge isn't the converse of its converse : " + std::to_string(e)); int counter = 0; HE_EdgeHandle eh2 = eh; do { if (counter > MAX_EDGES_PER_VERTEX) { problems.emplace_back("edges don't form a circular loop! : " + std::to_string(e)); break; } // continue outer for-loop eh2 = eh2.converse().next(); counter++; } while (eh2 != eh); // dont put more code here } for (int v = 0; v < vertices.size(); v++) { if (vertices[v].someEdge_idx < 0) { problems.emplace_back("vertex doesn't know any edge! : " + std::to_string(v)); continue; } HE_VertexHandle vh(*this, v); // done for each edge! // int counter = 0; // HE_EdgeHandle eh = vh.someEdge(); // do // { // if (counter > MAX_EDGES_PER_VERTEX) { problems.emplace_back("vertex edges don't form a circular loop!"); break; } // continue outer for-loop // eh = eh.converse().next(); counter++; // } while (eh != vh.someEdge()); // // dont put more code here } }
void MainInfo::getEncoding() { string encoding; int n = cmbEncoding->currentItem(); QString t = cmbEncoding->currentText(); Contact *contact = m_contact; if (contact == NULL) contact = getContacts()->owner(); if (n) { n--; QStringList l; const ENCODING *e; QStringList main; for (e = getContacts()->getEncodings(); e->language; e++) { if (!e->bMain) continue; main.append(i18n(e->language) + " (" + e->codec + ")"); } main.sort(); QStringList::Iterator it; for (it = main.begin(); it != main.end(); ++it) { l.append(*it); } QStringList noMain; for (e = getContacts()->getEncodings(); e->language; e++) { if (e->bMain) continue; noMain.append(i18n(e->language) + " (" + e->codec + ")"); } noMain.sort(); for (it = noMain.begin(); it != noMain.end(); ++it) { l.append(*it); } for (it = l.begin(); it != l.end(); ++it) { if (n-- == 0) { QString str = *it; int n = str.find('('); str = str.mid(n + 1); n = str.find(')'); str = str.left(n); encoding = str.latin1(); break; } } } if (!contact->setEncoding(encoding.c_str())) return; Event e(EventContactChanged, contact); e.process(); Event eh(EventHistoryConfig, (void*)(contact->id())); eh.process(); }
void Core::Handle (Entity e) { if (e.Mime_ == "x-leechcraft/browser-import-data") { std::auto_ptr<ImportEntityHandler> eh (new ImportEntityHandler (this)); eh->Import (e); } else if (e.Entity_.canConvert<QUrl> ()) { QUrl url = e.Entity_.toUrl (); NewURL (url, true); } }
void EditMode::slotEditHeadClicked() { QTreeWidgetItem* item = m_headList->currentItem(); if (item == NULL) return; EditHead eh(this, currentHead(), m_mode); if (eh.exec() == QDialog::Accepted) { int index = m_headList->indexOfTopLevelItem(item); m_mode->replaceHead(index, eh.head()); refreshHeadList(); } }
Z3_lbool Z3_API Z3_check_assumptions(Z3_context c, unsigned num_assumptions, Z3_ast const assumptions[], Z3_model * m, Z3_ast* proof, unsigned* core_size, Z3_ast core[]) { Z3_TRY; LOG_Z3_check_assumptions(c, num_assumptions, assumptions, m, proof, core_size, core); RESET_ERROR_CODE(); CHECK_SEARCHING(c); expr * const* _assumptions = to_exprs(assumptions); flet<bool> _model(mk_c(c)->fparams().m_model, true); cancel_eh<smt::kernel> eh(mk_c(c)->get_smt_kernel()); api::context::set_interruptable(*(mk_c(c)), eh); lbool result; result = mk_c(c)->get_smt_kernel().check(num_assumptions, _assumptions); if (result != l_false && m) { model_ref _m; mk_c(c)->get_smt_kernel().get_model(_m); if (_m) { Z3_model_ref * m_ref = alloc(Z3_model_ref); m_ref->m_model = _m; // Must bump reference counter for backward compatibility reasons. // Don't need to invoke save_object, since the counter was bumped m_ref->inc_ref(); *m = of_model(m_ref); } else { *m = 0; } } if (result == l_false && core_size) { *core_size = mk_c(c)->get_smt_kernel().get_unsat_core_size(); if (*core_size > num_assumptions) { SET_ERROR_CODE(Z3_INVALID_ARG); } for (unsigned i = 0; i < *core_size; ++i) { core[i] = of_ast(mk_c(c)->get_smt_kernel().get_unsat_core_expr(i)); } } else if (core_size) { *core_size = 0; } if (result == l_false && proof) { *proof = of_ast(mk_c(c)->get_smt_kernel().get_proof()); } else if (proof) { *proof = 0; // breaks abstraction. } RETURN_Z3_check_assumptions static_cast<Z3_lbool>(result); Z3_CATCH_RETURN(Z3_L_UNDEF); }
/** * \fn DIA_gotoTime * \brief Popup a display to enter hour/minutes/seconds/ms * @param hh * @param mm * @param ss * @param ms * @return */ uint8_t DIA_gotoTime(uint32_t *hh, uint32_t *mm, uint32_t *ss,uint32_t *ms) { uint32_t v=(*hh)*3600*1000+(*mm)*60*1000+(*ss)*1000+*ms; uint32_t max=(uint32_t)(video_body->getVideoDuration()/1000); diaElemTimeStamp eh(&v,QT_TRANSLATE_NOOP("adm","TimeStamp:"),0,max); diaElem *allWidgets[]={&eh}; if(!diaFactoryRun(QT_TRANSLATE_NOOP("adm","Go to Time"),1,allWidgets)) return 0; // ms2time(v,hh,mm,ss,ms); return 1; }
uint8_t DIA_gotoTime(uint16_t *hh, uint16_t *mm, uint16_t *ss) { uint32_t h=*hh,m=*mm,s=*ss; diaElemUInteger eh(&h,QT_TR_NOOP("_Hours:"),0,24); diaElemUInteger em(&m,QT_TR_NOOP("_Minutes:"),0,59); diaElemUInteger es(&s,QT_TR_NOOP("_Seconds:"),0,59); diaElem *allWidgets[]={&eh,&em,&es}; if(!diaFactoryRun(QT_TR_NOOP("Go to Time"),3,allWidgets)) return 0; *hh=h; *mm=m; *ss=s; return 1; }
static cell_t ThrowError(IPluginContext *pContext, const cell_t *params) { char buffer[512]; g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); { DetectExceptions eh(pContext); g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1); if (eh.HasException()) return 0; } pContext->ReportError("%s", buffer); return 0; }