void wxWebViewIE::ExecCommand(wxString command) { wxCOMPtr<IHTMLDocument2> document(GetDocument()); if(document) { document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL); } }
BOOL CRDB::LoadParamFromDB(CString sDeviceName , CString sDeviceType) { BOOL bResult = TRUE; HRESULT hr= S_OK; //CString strSQL; try { if(pRsDev->State==adStateClosed) { strSQL.Format(_T("select * from %s where Ãû³Æ= '%s'"),sDeviceType,sDeviceName); hr = pRsDev->Open(strSQL.AllocSysString(), theApp.pConn.GetInterfacePtr(), adOpenStatic, adLockOptimistic, -1); if (pRsDev->RecordCount>0) { pRsDev->MoveFirst(); } } else { pRsDev->MoveFirst(); for (int i=0;i<pRsDev->RecordCount;i++) { _variant_t var = pRsDev->Fields->GetItem("Ãû³Æ")->Value; if((VARIANT(var).vt!=VT_NULL)&&(CString(var.bstrVal)==sDeviceName)) { break; } pRsDev->MoveNext(); } } bResult = UpdateParamFromDB(); } catch(_com_error &e) { bResult = FALSE; e.ErrorMessage(); dump_com_error(e); } return bResult; }
int main (int argc, char **argv) { unsigned long i, k; struct timespec runtime; timing_t start, end; startup(); memset (&runtime, 0, sizeof (runtime)); unsigned long iters, res; TIMING_INIT (res); iters = 1000 * res; for (int v = 0; v < NUM_VARIANTS; v++) { /* Run for approximately DURATION seconds. */ clock_gettime (CLOCK_MONOTONIC_RAW, &runtime); runtime.tv_sec += DURATION; double d_total_i = 0; timing_t total = 0, max = 0, min = 0x7fffffffffffffff; while (1) { for (i = 0; i < NUM_SAMPLES (v); i++) { uint64_t cur; TIMING_NOW (start); for (k = 0; k < iters; k++) BENCH_FUNC (v, i); TIMING_NOW (end); TIMING_DIFF (cur, start, end); if (cur > max) max = cur; if (cur < min) min = cur; TIMING_ACCUM (total, cur); d_total_i += iters; } struct timespec curtime; memset (&curtime, 0, sizeof (curtime)); clock_gettime (CLOCK_MONOTONIC_RAW, &curtime); if (TIMESPEC_AFTER (curtime, runtime)) goto done; } double d_total_s; double d_iters; done: d_total_s = total; d_iters = iters; TIMING_PRINT_STATS (VARIANT (v), d_total_s, d_iters, d_total_i, max, min); } return 0; }
int main (int argc, char **argv) { unsigned long i, k; struct timespec runtime; timing_t start, end; bool detailed = false; json_ctx_t json_ctx; if (argc == 2 && !strcmp (argv[1], "-d")) detailed = true; bench_start (); memset (&runtime, 0, sizeof (runtime)); unsigned long iters, res; #ifdef BENCH_INIT BENCH_INIT (); #endif TIMING_INIT (res); iters = 1000 * res; json_init (&json_ctx, 2, stdout); /* Begin function. */ json_attr_object_begin (&json_ctx, FUNCNAME); for (int v = 0; v < NUM_VARIANTS; v++) { /* Run for approximately DURATION seconds. */ clock_gettime (CLOCK_MONOTONIC_RAW, &runtime); runtime.tv_sec += DURATION; double d_total_i = 0; timing_t total = 0, max = 0, min = 0x7fffffffffffffff; int64_t c = 0; while (1) { for (i = 0; i < NUM_SAMPLES (v); i++) { uint64_t cur; TIMING_NOW (start); for (k = 0; k < iters; k++) BENCH_FUNC (v, i); TIMING_NOW (end); TIMING_DIFF (cur, start, end); if (cur > max) max = cur; if (cur < min) min = cur; TIMING_ACCUM (total, cur); /* Accumulate timings for the value. In the end we will divide by the total iterations. */ RESULT_ACCUM (cur, v, i, c * iters, (c + 1) * iters); d_total_i += iters; } c++; struct timespec curtime; memset (&curtime, 0, sizeof (curtime)); clock_gettime (CLOCK_MONOTONIC_RAW, &curtime); if (TIMESPEC_AFTER (curtime, runtime)) goto done; } double d_total_s; double d_iters; done: d_total_s = total; d_iters = iters; /* Begin variant. */ json_attr_object_begin (&json_ctx, VARIANT (v)); json_attr_double (&json_ctx, "duration", d_total_s); json_attr_double (&json_ctx, "iterations", d_total_i); json_attr_double (&json_ctx, "max", max / d_iters); json_attr_double (&json_ctx, "min", min / d_iters); json_attr_double (&json_ctx, "mean", d_total_s / d_total_i); if (detailed) { json_array_begin (&json_ctx, "timings"); for (int i = 0; i < NUM_SAMPLES (v); i++) json_element_double (&json_ctx, RESULT (v, i)); json_array_end (&json_ctx); } /* End variant. */ json_attr_object_end (&json_ctx); } /* End function. */ json_attr_object_end (&json_ctx); return 0; }
static int anoubisd_msg_size(const char *buf, int buflen) { DECLARE_SIZE(); struct anoubisd_msg *msg; CAST(msg, buf, buflen); SHIFT_FIELD(msg, msg, buf, buflen); switch(msg->mtype) { VARIANT(ANOUBISD_MSG_POLREQUEST, anoubisd_msg_polrequest, buf, buflen) VARIANT(ANOUBISD_MSG_POLREQUEST_ABORT, anoubisd_msg_polrequest_abort, buf, buflen) VARIANT(ANOUBISD_MSG_POLREPLY, anoubisd_msg_polreply, buf, buflen) VARIANT(ANOUBISD_MSG_CHECKSUM_OP, anoubisd_msg_csumop, buf, buflen) VARIANT(ANOUBISD_MSG_CHECKSUMREPLY, anoubisd_msg_csumreply, buf, buflen) VARIANT(ANOUBISD_MSG_EVENTDEV, eventdev_hdr, buf, buflen) VARIANT(ANOUBISD_MSG_LOGREQUEST, anoubisd_msg_eventask, buf, buflen) VARIANT(ANOUBISD_MSG_EVENTREPLY, eventdev_reply, buf, buflen) VARIANT(ANOUBISD_MSG_EVENTCANCEL, eventdev_token, buf, buflen) VARIANT(ANOUBISD_MSG_EVENTASK, anoubisd_msg_eventask, buf, buflen) VARIANT(ANOUBISD_MSG_POLICYCHANGE, anoubisd_msg_pchange, buf, buflen) VARIANT(ANOUBISD_MSG_PGCHANGE, anoubisd_msg_pgchange, buf, buflen) VARIANT(ANOUBISD_MSG_SFSCACHE_INVALIDATE, anoubisd_sfscache_invalidate, buf, buflen) VARIANT(ANOUBISD_MSG_UPGRADE, anoubisd_msg_upgrade, buf, buflen) VARIANT(ANOUBISD_MSG_SFS_UPDATE_ALL, anoubisd_sfs_update_all, buf, buflen) VARIANT(ANOUBISD_MSG_CONFIG, anoubisd_msg_config, buf, buflen) VARIANT(ANOUBISD_MSG_LOGIT, anoubisd_msg_logit, buf, buflen) VARIANT(ANOUBISD_MSG_PASSPHRASE, anoubisd_msg_passphrase, buf, buflen); VARIANT(ANOUBISD_MSG_AUTH_REQUEST, anoubisd_msg_authrequest, buf, buflen); VARIANT(ANOUBISD_MSG_AUTH_CHALLENGE, anoubisd_msg_authchallenge, buf, buflen); VARIANT(ANOUBISD_MSG_AUTH_VERIFY, anoubisd_msg_authverify, buf, buflen); VARIANT(ANOUBISD_MSG_AUTH_RESULT, anoubisd_msg_authresult, buf, buflen); VARIANT(ANOUBISD_MSG_CSMULTIREQUEST, anoubisd_msg_csumop, buf, buflen); VARIANT(ANOUBISD_MSG_CSMULTIREPLY, anoubisd_msg_csumreply, buf, buflen); VARIANT(ANOUBISD_MSG_LISTREQUEST, anoubisd_msg_listrequest, buf, buflen); VARIANT(ANOUBISD_MSG_LISTREPLY, anoubisd_msg_listreply, buf, buflen); VARIANT(ANOUBISD_MSG_PGCOMMIT, anoubisd_msg_pgcommit, buf, buflen); VARIANT(ANOUBISD_MSG_PGCOMMIT_REPLY, anoubisd_msg_pgcommit_reply, buf, buflen); VARIANT(ANOUBISD_MSG_PGUNLINK, anoubisd_msg_pgunlink, buf, buflen); VARIANT(ANOUBISD_MSG_PGUNLINK_REPLY, anoubisd_msg_pgunlink_reply, buf, buflen); default: log_warnx("anoubisd_msg_size: Bad message type %d", msg->mtype); return -1; } RETURN_SIZE(); }
/* * Size of an eventdev_hdr. */ int eventdev_hdr_size(const char *buf, int buflen) { struct eventdev_hdr *hdr; DECLARE_SIZE(); CAST(hdr, buf, buflen); CHECK_LEN(hdr->msg_size, buflen); CHECK_SIZE(hdr->msg_size); SHIFT_CNT(sizeof(*hdr), buf, buflen); switch(hdr->msg_source) { VARIANT(ANOUBIS_SOURCE_ALF, alf_event, buf, buflen); VARIANT(ANOUBIS_SOURCE_SANDBOX, sfs_open_message, buf, buflen); VARIANT(ANOUBIS_SOURCE_SFS, sfs_open_message, buf, buflen); VARIANT(ANOUBIS_SOURCE_SFSEXEC, sfs_open_message, buf, buflen); #ifdef ANOUBIS_SOURCE_SFSPATH VARIANT(ANOUBIS_SOURCE_SFSPATH, sfs_path_message, buf, buflen); #endif VARIANT(ANOUBIS_SOURCE_PROCESS, ac_process_message, buf, buflen); VARIANT(ANOUBIS_SOURCE_STAT, anoubis_stat_message, buf, buflen); VARIANT(ANOUBIS_SOURCE_IPC, ac_ipc_message, buf, buflen); VARIANT(ANOUBIS_SOURCE_PLAYGROUND, pg_open_message, buf, buflen); VARIANT(ANOUBIS_SOURCE_PLAYGROUNDPROC, pg_proc_message, buf, buflen); VARIANT(ANOUBIS_SOURCE_PLAYGROUNDFILE, pg_file_message, buf, buflen); default: return -2; } if (__local_size > hdr->msg_size) { if (__local_size <= 0) return -3; else return -(__local_size); } if (__local_size + 8 < hdr->msg_size) { if (__local_size <= 0) return -4; else return -(__local_size + 100000); } /* * NOTE: Do NOT return the calculated size here because this * NOTE: is usually used within a container and that container * NOTE: must treat the padding space as part of the message. */ return hdr->msg_size; }