/* V_STRING -> V_LENS */ static struct value *lns_seq(struct info *info, struct value *str) { assert(str->tag == V_STRING); return lns_make_prim(L_SEQ, ref(info), NULL, ref(str->string)); }
inline void setRef(Instance* instance) const { ref() = instance; }
Transformer::Transformer() { identity_ = true; mat00 = mat11 = 1; mat01 = mat10 = mat20 = mat21 = 0; ref(); }
void MediaElementAudioSourceNode::lock() { ref(); m_processLock.lock(); }
Variant HHVM_FUNCTION(eregi, const String& pattern, const String& str, VRefParam regs /* = null */) { return HHVM_FN(mb_eregi)(pattern, str, ref(regs)); }
bool TestExtPreg::test_preg_match_all() { Variant matches; f_preg_match_all("/\\(? (\\d{3})? \\)? (?(1) [\\-\\s] ) \\d{3}-\\d{4}/x", "Call 555-1212 or 1-800-555-1212", ref(matches)); VS(f_print_r(matches, true), "Array\n" "(\n" " [0] => Array\n" " (\n" " [0] => 555-1212\n" " [1] => 800-555-1212\n" " )\n" "\n" " [1] => Array\n" " (\n" " [0] => \n" " [1] => 800\n" " )\n" "\n" ")\n"); // The \\2 is an example of backreferencing. This tells pcre that // it must match the second set of parentheses in the regular expression // itself, which would be the ([\w]+) in this case. The extra backslash is // required because the string is in double quotes. String html = "<b>bold text</b><a href=howdy.html>click me</a>"; f_preg_match_all("/(<([\\w]+)[^>]*>)(.*)(<\\/\\2>)/", html, ref(matches), k_PREG_SET_ORDER); VS(f_print_r(matches, true), "Array\n" "(\n" " [0] => Array\n" " (\n" " [0] => <b>bold text</b>\n" " [1] => <b>\n" " [2] => b\n" " [3] => bold text\n" " [4] => </b>\n" " )\n" "\n" " [1] => Array\n" " (\n" " [0] => <a href=howdy.html>click me</a>\n" " [1] => <a href=howdy.html>\n" " [2] => a\n" " [3] => click me\n" " [4] => </a>\n" " )\n" "\n" ")\n"); String str = "a: 1\nb: 2\nc: 3\n"; f_preg_match_all("/(?<name>\\w+): (?<digit>\\d+)/", str, ref(matches)); VS(f_print_r(matches, true), "Array\n" "(\n" " [0] => Array\n" " (\n" " [0] => a: 1\n" " [1] => b: 2\n" " [2] => c: 3\n" " )\n" "\n" " [name] => Array\n" " (\n" " [0] => a\n" " [1] => b\n" " [2] => c\n" " )\n" "\n" " [1] => Array\n" " (\n" " [0] => a\n" " [1] => b\n" " [2] => c\n" " )\n" "\n" " [digit] => Array\n" " (\n" " [0] => 1\n" " [1] => 2\n" " [2] => 3\n" " )\n" "\n" " [2] => Array\n" " (\n" " [0] => 1\n" " [1] => 2\n" " [2] => 3\n" " )\n" "\n" ")\n"); return Count(true); }
Variant f_collator_sort(CVarRef obj, VRefParam arr, int64 sort_flag /* = q_Collator$$SORT_REGULAR */) { CHECK_COLL(obj); return coll->t_sort(ref(arr), sort_flag); }
bool f_getmxrr(const String& hostname, VRefParam mxhosts, VRefParam weight /* = uninit_null() */) { return f_dns_get_mx(hostname, ref(mxhosts), weight); }
void smthread_scanner_t::scan_i_scan(const stid_t& fid, int num_recs, ss_m::concurrency_t cc) { outstream << "********** Starting scanning file " << fid << " expecting " << num_recs << " records" << endl; sendout(); scan_file_i scan(fid, cc); w_rc_t rc = scan.error_code(); if(rc.is_error()) { cerr << "Could not create scan_i with fid " << fid << " error is " << rc << endl; ::exit(1); } pin_i *handle; bool eof = false; int i = START; do { w_rc_t rc; rc = scan.error_code(); if(rc.is_error()) { cerr << "Could not create scan_i with fid " << fid << " error is " << rc << endl; ::exit(1); } w_assert1(scan.error_code().is_error() == false); rc = scan.next(handle, 0, eof); if(rc.is_error()) { W_COERCE(rc); } if(debug) { outstream << " scanned i " << i << ": " << scan.curr_rid << " eof=" << eof << endl; sendout(); } if(eof) break; w_assert1(handle->pinned()); const char *hdr =handle->hdr(); smsize_t hdrsize=handle->hdr_size(); /// alignment should be ok: vec_t ref(hdr, hdrsize); int refi; ref.copy_to(&refi, sizeof (refi)); const char *datum =handle->body(); smsize_t datasize=handle->body_size(); outstream << handle->rid(); outstream << " header " << refi ; if(append_only) { w_assert1(refi == i); // if we used append-only on the file creation, // we had better find the order preserved. outstream << "; data (size " << datasize << ") " << datum ; outstream << " A:OK " << endl; } else { rid_t r; memcpy(&r, datum, sizeof(r)); w_assert1(r == handle->rid()); outstream << "; data (size " << datasize << ") " << r ; outstream << " rid:OK " << endl; } sendout(); /* const char *body =handle->body(); smsize_t bodysize=handle->body_size(); */ i++; } while (1) ; if(num_recs == i-1) { if(debug) { outstream << "scan_i scan complete, OK" << endl; sendout(); } } else { outstream << "ERROR IN COUNT: scan_i scan complete, i=" << i-1 << " num_rec expected =" << num_recs << endl; sendout(); } assert(i-START == num_recs); }
std::pair<int, int> Puzzle::get(int row, int column) const { int value = ref(row, column)-1; return { value / d_columns, value % d_columns }; }
int main () { struct ss ss; struct ss ssa[2]; struct arraystruct arraystruct; string x = make_string ("this is x"); zzz_type c = make_container ("container"); zzz_type c2 = make_container ("container2"); const struct string_repr cstring = { { "const string" } }; /* Clearing by being `static' could invoke an other GDB C++ bug. */ struct nullstr nullstr; nostring_type nstype, nstype2; struct memory_error me; struct ns ns, ns2; struct lazystring estring, estring2; struct hint_error hint_error; struct children_as_list children_as_list; nstype.elements = narray; nstype.len = 0; me.s = "blah"; init_ss(&ss, 1, 2); init_ss(ssa+0, 3, 4); init_ss(ssa+1, 5, 6); memset (&nullstr, 0, sizeof nullstr); arraystruct.y = 7; init_s (&arraystruct.x[0], 23); init_s (&arraystruct.x[1], 24); ns.null_str = "embedded\0null\0string"; ns.length = 20; /* Make a "corrupted" string. */ ns2.null_str = NULL; ns2.length = 20; estring.lazy_str = "embedded x\201\202\203\204" ; /* Incomplete UTF-8, but ok Latin-1. */ estring2.lazy_str = "embedded x\302"; #ifdef __cplusplus S cps; cps.zs = 7; init_s(&cps, 8); SS cpss; cpss.zss = 9; init_s(&cpss.s, 10); SS cpssa[2]; cpssa[0].zss = 11; init_s(&cpssa[0].s, 12); cpssa[1].zss = 13; init_s(&cpssa[1].s, 14); SSS sss(15, cps); SSS& ref (sss); Derived derived; Fake fake (42); #endif add_item (&c, 23); /* MI breakpoint here */ add_item (&c, 72); #ifdef MI add_item (&c, 1011); c.elements[0] = 1023; c.elements[0] = 2323; add_item (&c2, 2222); add_item (&c2, 3333); substruct_test (); do_nothing (); #endif nstype.elements[0] = 7; nstype.elements[1] = 42; nstype.len = 2; nstype2 = nstype; eval_sub (); bug_14741(); /* break to inspect struct and union */ return 0; }
Variant f_stream_select(VRefParam read, VRefParam write, VRefParam except, CVarRef vtv_sec, int tv_usec /* = 0 */) { return f_socket_select(ref(read), ref(write), ref(except), vtv_sec, tv_usec); }
Status WriteOp::targetWrites( const NSTargeter& targeter, std::vector<TargetedWrite*>* targetedWrites ) { bool isUpdate = _itemRef.getOpType() == BatchedCommandRequest::BatchType_Update; bool isDelete = _itemRef.getOpType() == BatchedCommandRequest::BatchType_Delete; // In case of error, don't leak. OwnedPointerVector<ShardEndpoint> endpointsOwned; vector<ShardEndpoint*>& endpoints = endpointsOwned.mutableVector(); if ( isUpdate || isDelete ) { // Updates/deletes targeted by query BSONObj queryDoc = isUpdate ? _itemRef.getUpdate()->getQuery() : _itemRef.getDelete()->getQuery(); Status targetStatus = targeter.targetQuery( queryDoc, &endpoints ); if ( targetStatus.isOK() ) { targetStatus = isUpdate ? updateTargetsOk( *this, endpoints ) : deleteTargetsOk( *this, endpoints ); } if ( !targetStatus.isOK() ) return targetStatus; } else { dassert( _itemRef.getOpType() == BatchedCommandRequest::BatchType_Insert ); // Inserts targeted by doc itself ShardEndpoint* endpoint = NULL; Status targetStatus = targeter.targetDoc( _itemRef.getDocument(), &endpoint ); if ( !targetStatus.isOK() ) { dassert( NULL == endpoint ); return targetStatus; } dassert( NULL != endpoint ); endpoints.push_back( endpoint ); } for ( vector<ShardEndpoint*>::iterator it = endpoints.begin(); it != endpoints.end(); ++it ) { ShardEndpoint* endpoint = *it; _childOps.push_back( new ChildWriteOp( this ) ); WriteOpRef ref( _itemRef.getItemIndex(), _childOps.size() - 1 ); // For now, multiple endpoints imply no versioning if ( endpoints.size() == 1u ) { targetedWrites->push_back( new TargetedWrite( *endpoint, ref ) ); } else { ShardEndpoint broadcastEndpoint( endpoint->shardName, ChunkVersion::IGNORED(), endpoint->shardHost ); targetedWrites->push_back( new TargetedWrite( broadcastEndpoint, ref ) ); } _childOps.back()->pendingWrite = targetedWrites->back(); _childOps.back()->state = WriteOpState_Pending; } _state = WriteOpState_Pending; return Status::OK(); }
/* V_STRING -> V_LENS */ static struct value *lns_counter(struct info *info, struct value *str) { assert(str->tag == V_STRING); return lns_make_prim(L_COUNTER, ref(info), NULL, ref(str->string)); }
void KOrganizerPlugin::saveToProfile( const QString& directory ) const { DCOPRef ref( "korganizer", "KOrganizerIface" ); ref.send( "saveToProfile", directory ); }
// SingleResponse ::= SEQUENCE { // certID CertID, // certStatus CertStatus, // thisUpdate GeneralizedTime, // nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, // singleExtensions [1] EXPLICIT Extensions{{re-ocsp-crl | // re-ocsp-archive-cutoff | // CrlEntryExtensions, ...} // } OPTIONAL } static inline Result SingleResponse(Reader& input, Context& context) { bool match = false; Result rv = der::Nested(input, der::SEQUENCE, bind(CertID, _1, cref(context), ref(match))); if (rv != Success) { return rv; } if (!match) { // This response does not reference the certificate we're interested in. // By consuming the rest of our input and returning successfully, we can // continue processing and examine another response that might have what // we want. input.SkipToEnd(); return Success; } // CertStatus ::= CHOICE { // good [0] IMPLICIT NULL, // revoked [1] IMPLICIT RevokedInfo, // unknown [2] IMPLICIT UnknownInfo } // // In the event of multiple SingleResponses for a cert that have conflicting // statuses, we use the following precedence rules: // // * revoked overrides good and unknown // * good overrides unknown if (input.Peek(static_cast<uint8_t>(CertStatus::Good))) { rv = der::ExpectTagAndLength(input, static_cast<uint8_t>(CertStatus::Good), 0); if (rv != Success) { return rv; } if (context.certStatus != CertStatus::Revoked) { context.certStatus = CertStatus::Good; } } else if (input.Peek(static_cast<uint8_t>(CertStatus::Revoked))) { // We don't need any info from the RevokedInfo structure, so we don't even // parse it. TODO: We should mention issues like this in the explanation of // why we treat invalid OCSP responses equivalently to revoked for OCSP // stapling. rv = der::ExpectTagAndSkipValue(input, static_cast<uint8_t>(CertStatus::Revoked)); if (rv != Success) { return rv; } context.certStatus = CertStatus::Revoked; } else { rv = der::ExpectTagAndLength(input, static_cast<uint8_t>(CertStatus::Unknown), 0); if (rv != Success) { return rv; } } // http://tools.ietf.org/html/rfc6960#section-3.2 // 5. The time at which the status being indicated is known to be // correct (thisUpdate) is sufficiently recent; // 6. When available, the time at or before which newer information will // be available about the status of the certificate (nextUpdate) is // greater than the current time. Time thisUpdate(Time::uninitialized); rv = der::GeneralizedTime(input, thisUpdate); if (rv != Success) { return rv; } static const uint64_t SLOP_SECONDS = Time::ONE_DAY_IN_SECONDS; Time timePlusSlop(context.time); rv = timePlusSlop.AddSeconds(SLOP_SECONDS); if (rv != Success) { return rv; } if (thisUpdate > timePlusSlop) { return Result::ERROR_OCSP_FUTURE_RESPONSE; } Time notAfter(Time::uninitialized); static const uint8_t NEXT_UPDATE_TAG = der::CONTEXT_SPECIFIC | der::CONSTRUCTED | 0; if (input.Peek(NEXT_UPDATE_TAG)) { Time nextUpdate(Time::uninitialized); rv = der::Nested(input, NEXT_UPDATE_TAG, bind(der::GeneralizedTime, _1, ref(nextUpdate))); if (rv != Success) { return rv; } if (nextUpdate < thisUpdate) { return Result::ERROR_OCSP_MALFORMED_RESPONSE; } notAfter = thisUpdate; if (notAfter.AddSeconds(context.maxLifetimeInDays * Time::ONE_DAY_IN_SECONDS) != Success) { // This could only happen if we're dealing with times beyond the year // 10,000AD. return Result::ERROR_OCSP_FUTURE_RESPONSE; } if (nextUpdate <= notAfter) { notAfter = nextUpdate; } } else { // NSS requires all OCSP responses without a nextUpdate to be recent. // Match that stricter behavior. notAfter = thisUpdate; if (notAfter.AddSeconds(Time::ONE_DAY_IN_SECONDS) != Success) { // This could only happen if we're dealing with times beyond the year // 10,000AD. return Result::ERROR_OCSP_FUTURE_RESPONSE; } } Time timeMinusSlop(context.time); rv = timeMinusSlop.SubtractSeconds(SLOP_SECONDS); if (rv != Success) { return rv; } if (timeMinusSlop > notAfter) { context.expired = true; } rv = der::OptionalExtensions(input, der::CONTEXT_SPECIFIC | der::CONSTRUCTED | 1, ExtensionNotUnderstood); if (rv != Success) { return rv; } if (context.thisUpdate) { *context.thisUpdate = thisUpdate; } if (context.validThrough) { *context.validThrough = notAfter; } return Success; }
bool TestExtPreg::test_preg_replace() { { String str = "April 15, 2003"; String pattern = "/(\\w+) (\\d+), (\\d+)/i"; String replacement = "${1}1,$3"; VS(f_preg_replace(pattern, replacement, str), "April1,2003"); } { String str = "The quick brown fox jumped over the lazy dog."; Variant patterns, replacements; patterns.set(0, "/quick/"); patterns.set(1, "/brown/"); patterns.set(2, "/fox/"); replacements.set(2, "bear"); replacements.set(1, "black"); replacements.set(0, "slow"); VS(f_preg_replace(patterns, replacements, str), "The bear black slow jumped over the lazy dog."); f_ksort(ref(patterns)); f_ksort(ref(replacements)); VS(f_preg_replace(patterns, replacements, str), "The slow black bear jumped over the lazy dog."); } { Array foos; foos.set(0, "foo"); foos.set(1, "Foo"); foos.set(2, "FOO"); Array expFoo; expFoo.set(0, "FOO"); expFoo.set(1, "FOO"); expFoo.set(2, "FOO"); VS(f_preg_replace("/some pattern/", "", Array::Create()), Array::Create()); VS(f_preg_replace("/foo/i", "FOO", foos), expFoo); } { Array patterns = CREATE_VECTOR2("/(19|20)(\\d{2})-(\\d{1,2})-(\\d{1,2})/", "/^\\s*{(\\w+)}\\s*=/"); Array replace = CREATE_VECTOR2("\\3/\\4/\\1\\2", "$\\1 ="); VS(f_preg_replace(patterns, replace, "{startDate} = 1999-5-27"), "$startDate = 5/27/1999"); } { String str = "foo o"; str = f_preg_replace("/\\s\\s+/", " ", str); VS(str, "foo o"); } { Variant count = 0; f_preg_replace(CREATE_VECTOR2("/\\d/", "/\\s/"), "*", "xp 4 to", -1, ref(count)); VS(count, 3); } { String html_body = "<html><body></body></html>"; String html_body2 = f_preg_replace("/(<\\/?\\w+[^>]*>)/e", "strtoupper(\"$1\")", html_body); VS(html_body2, "<HTML><BODY></BODY></HTML>"); String css_text = "#AAAA;"; String css_text2 = f_preg_replace("/#([A-Fa-f0-9]{3,6});/e", "strtolower(\"#\\1;\");", css_text); VS(css_text2, "#aaaa;"); String rgb_text = "rgb(13, 14, 15)"; String rgb_text2 = f_preg_replace("/rgb\\(([0-9]{1,3}), ([0-9]{1,3}), ([0-9]{1,3})\\)/e", "sprintf(\"%02x%02x%02x\", \"\\1\", \"\\2\", \"\\3\")", rgb_text); VS(rgb_text2, "0d0e0f"); String res = f_preg_replace("/(a*)(b*)/e", "test_preg_rep(\"\\1\",\"smu\\\"rf\",\"\\2\")", "aaabbbblahblahaabbbababab"); VS(res, "BBBBaaalahBlahBBBaaBaBaBa"); try { f_preg_replace("/(<\\/?)(\\w+)([^>]*>)/e", "'\\\\1'.strtoupper('\\\\2').'\\\\3'", html_body); } catch (const NotSupportedException& e) { return Count(true); } } return Count(false); }
main() { var x = 4; ref(x); return x; }
Variant f_collator_sort_with_sort_keys(CVarRef obj, VRefParam arr) { CHECK_COLL(obj); return coll->t_sortwithsortkeys(ref(arr)); }
/** * @brief bisystemControl * Initiates the bilateral control between master and slave systems * @param allSys Vector of pointers to the instantiated DXMotorSystem object pointers * @param runFlag Boolean run flag, continues the bilateral control while true - passed by reference to allow changes at runtime * @param goalTorqueSetting Desired torque settings to be used (parameters defined as macro in header) - passed by reference to allow modifications at runtime * @param filename Prefix filename where recorded position data is saved to */ void bisystemControl(vector<DXMotorSystem*>& allSys, bool& runFlag, int& goalTorqueSetting, const string& filename) { try { DXMotorSystem dmaster = *(allSys[0]); unsigned int numMotors = dmaster.getNumMotors(); dmaster.setAllTorqueEn(0); vector<int> allMasterTorqueLimit(numMotors,MASTER_TORQUE); dmaster.setAllTorqueLimit(allMasterTorqueLimit); // Check that all systems have the same motor count for (unsigned int ii = 1; ii < allSys.size(); ii++) { if (allSys[ii]->getNumMotors() != numMotors) throw(runtime_error("Master and slave motor count do not tally.")); vector<int> allSlaveTorqueLimit(numMotors, SLAVE_TORQUE); allSys[ii]->setAllTorqueLimit(allSlaveTorqueLimit); } vector<int> posWrite = dmaster.getAllHomePosition(); //dmaster.getAllPosition(); string writeFilename = "data/" + filename + getTimeStr() + ".csv"; ofstream file (writeFilename); ostringstream header; header << "timestep"; for (unsigned int ii = 0; ii < numMotors; ii++) { header << ",#" << ii; } file << header.str() << endl; int torqueSetting = 0; vector<int> lowTorques(numMotors,MASTER_LOW_TORQUE); vector<int> highTorques(numMotors,MASTER_HIGH_TORQUE); vector<queue<vector<int> > > allPosHistory; for (unsigned int ii = 0; ii < allSys.size(); ii++) { queue<vector<int> > posHistory; allPosHistory.push_back(posHistory); } int timestep = 0; while(runFlag) { thread write(write2file, ref(file), ref(posWrite), timestep); // Change torque settings of master if (torqueSetting != goalTorqueSetting) { switch(goalTorqueSetting) { case 1: dmaster.setAllTorqueLimit(lowTorques); dmaster.setAllTorqueEn(1); break; case 2: dmaster.setAllTorqueLimit(highTorques); dmaster.setAllTorqueEn(1); break; case 0: default: dmaster.setAllTorqueLimit(allMasterTorqueLimit); dmaster.setAllTorqueEn(0); break; } torqueSetting = goalTorqueSetting; } vector<int> pos = dmaster.getAllPosition(); thread thr[allSys.size()-1]; for (unsigned int ii = 0; ii < allSys.size()-1; ii++) { thr[ii] = thread(setPositions,ref(*(allSys[ii+1])),ref(pos)); // allSys[ii+1]->setAllPosition(pos); // allSys[ii+1]->getAllPosition(); } posWrite = pos; // position data to write (in next time step) write.join(); for (unsigned int ii = 0; ii < allSys.size()-1; ii++) { thr[ii].join(); } timestep++; } file.close(); // Delete pointers for (unsigned int nn = 0; nn < allSys.size(); nn++) { allSys[nn]->setAllTorqueLimit(vector<int>(numMotors,1023)); allSys[nn]->setAllTorqueEn(0); delete allSys[nn]; } } catch(runtime_error e) { cout << e.what() << endl; } }
static Variant php_intl_idn_to(CStrRef domain, int64 options, IdnVariant idn_variant, VRefParam idna_info, int mode) { UChar* ustring = NULL; int ustring_len = 0; UErrorCode status; char *converted_utf8 = NULL; int32_t converted_utf8_len; UChar* converted = NULL; int32_t converted_ret_len; if (idn_variant != INTL_IDN_VARIANT_2003) { #ifdef HAVE_46_API if (idn_variant == INTL_IDN_VARIANT_UTS46) { return php_intl_idn_to_46(domain, options, idn_variant, ref(idna_info), mode); } #endif return false; } // Convert the string to UTF-16 status = U_ZERO_ERROR; intl_convert_utf8_to_utf16(&ustring, &ustring_len, (char*)domain.data(), domain.size(), &status); if (U_FAILURE(status)) { free(ustring); return false; } // Call the appropriate IDN function int converted_len = (ustring_len > 1) ? ustring_len : 1; for (;;) { UParseError parse_error; status = U_ZERO_ERROR; converted = (UChar*)malloc(sizeof(UChar)*converted_len); // If the malloc failed, bail out if (!converted) { free(ustring); return false; } if (mode == INTL_IDN_TO_ASCII) { converted_ret_len = uidna_IDNToASCII(ustring, ustring_len, converted, converted_len, (int32_t)options, &parse_error, &status); } else { converted_ret_len = uidna_IDNToUnicode(ustring, ustring_len, converted, converted_len, (int32_t)options, &parse_error, &status); } if (status != U_BUFFER_OVERFLOW_ERROR) break; // If we have a buffer overflow error, try again with a larger buffer free(converted); converted = NULL; converted_len = converted_len * 2; } free(ustring); if (U_FAILURE(status)) { free(converted); return false; } // Convert the string back to UTF-8 status = U_ZERO_ERROR; intl_convert_utf16_to_utf8(&converted_utf8, &converted_utf8_len, converted, converted_ret_len, &status); free(converted); if (U_FAILURE(status)) { free(converted_utf8); return false; } // Return the string return String(converted_utf8, converted_utf8_len, AttachString); }
bool TestExtNetwork::test_getmxrr() { Variant hosts; VERIFY(f_getmxrr("facebook.com", ref(hosts))); VERIFY(!hosts.toArray().empty()); return Count(true); }
bool TestExtServer::test_pagelet_server_task_result() { const int TEST_SIZE = 20; String baseurl("ext/pageletserver?getparam="); String baseheader("MyHeader: "); String basepost("postparam="); std::vector<Resource> tasks; for (int i = 0; i < TEST_SIZE; ++i) { String url = baseurl + String(i); String header = baseheader + String(i); String post = basepost + String(i); Resource task = HHVM_FN(pagelet_server_task_start)(url, make_packed_array(header), post); tasks.push_back(task); } for (int i = 0; i < TEST_SIZE; ++i) { HHVM_FN(pagelet_server_task_status)(tasks[i]); } // Calls that time out (try 1 ms) should return a status code of -1 for (int i = 0; i < TEST_SIZE; ++i) { Variant code, headers; VS("", HHVM_FN(pagelet_server_task_result)(tasks[i], ref(headers), ref(code), 1)); VS(code, -1); } for (int i = 0; i < TEST_SIZE; ++i) { String expected = "pagelet postparam: postparam="; expected += String(i); expected += "pagelet getparam: "; expected += String(i); expected += "pagelet header: "; expected += String(i); // A timeout of 0 indicates an infinite timeout that blocks. Variant code, headers; VS(expected, HHVM_FN(pagelet_server_task_result)(tasks[i], ref(headers), ref(code), 0)); VS(code, 200); Array headerArray = headers.toArray(); bool hasResponseHeader = false; String expectedHeader = String("ResponseHeader: okay"); for (int headerIdx = 0; headerIdx < headerArray.size(); headerIdx++) { if (headerArray[headerIdx].toString() == expectedHeader) { hasResponseHeader = true; break; } } VERIFY(hasResponseHeader); VS(expected, HHVM_FN(pagelet_server_task_result)(tasks[i], ref(headers), ref(code), 1)); VS(code, 200); } return Count(true); }
if (this->resp.len > 0) { /* Some parts are still unsent. Therefore, the connection must stay * open. */ return; } if (!this->persistent) { Server_Client_Close(this->client); } } Impl(Connection) = { .size = sizeof(self), .init = ref(Init), .destroy = ref(Destroy), .pull = ref(Parse), .push = ref(Respond) }; ExportImpl(Connection); #undef self // ----------- // Application // ----------- #define self Application
inline void killRef() { ref().~Ref<Instance,Owner>(); }
void KOrganizerPlugin::slotSyncEvents() { DCOPRef ref( "kmail", "KMailICalIface" ); ref.send( "triggerSync", QString("Calendar") ); }
inline Ref<T> toInstance() const { check(type_ & RefType, illegalConversion()); return ref(); }
void KOrganizerPlugin::loadProfile( const QString& directory ) { DCOPRef ref( "korganizer", "KOrganizerIface" ); ref.send( "loadProfile", directory ); }
bool ResourceHandle::start() { if (firstRequest().url().isLocalFile() || firstRequest().url().protocolIsData()) { ref(); // balanced by deref in fileLoadTimer if (d->m_loadSynchronously) fileLoadTimer(0); else d->m_fileLoadTimer.startOneShot(0.0); return true; } if (!d->m_internetHandle) d->m_internetHandle = asynchronousInternetHandle(d->m_context->userAgent()); if (!d->m_internetHandle) return false; DWORD flags = INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD; d->m_connectHandle = InternetConnectW(d->m_internetHandle, firstRequest().url().host().charactersWithNullTermination(), firstRequest().url().port(), 0, 0, INTERNET_SERVICE_HTTP, flags, reinterpret_cast<DWORD_PTR>(this)); if (!d->m_connectHandle) return false; String urlStr = firstRequest().url().path(); String urlQuery = firstRequest().url().query(); if (!urlQuery.isEmpty()) { urlStr.append('?'); urlStr.append(urlQuery); } String httpMethod = firstRequest().httpMethod(); String httpReferrer = firstRequest().httpReferrer(); LPCWSTR httpAccept[] = { L"*/*", 0 }; d->m_requestHandle = HttpOpenRequestW(d->m_connectHandle, httpMethod.charactersWithNullTermination(), urlStr.charactersWithNullTermination(), 0, httpReferrer.charactersWithNullTermination(), httpAccept, flags, reinterpret_cast<DWORD_PTR>(this)); if (!d->m_requestHandle) { InternetCloseHandle(d->m_connectHandle); return false; } if (firstRequest().httpBody()) { firstRequest().httpBody()->flatten(d->m_formData); d->m_bytesRemainingToWrite = d->m_formData.size(); } Vector<UChar> httpHeaders; const HTTPHeaderMap& httpHeaderFields = firstRequest().httpHeaderFields(); for (HTTPHeaderMap::const_iterator it = httpHeaderFields.begin(); it != httpHeaderFields.end(); ++it) { if (equalIgnoringCase(it->key, "Accept") || equalIgnoringCase(it->key, "Referer") || equalIgnoringCase(it->key, "User-Agent")) continue; if (!httpHeaders.isEmpty()) httpHeaders.append('\n'); httpHeaders.append(it->key.characters(), it->key.length()); httpHeaders.append(':'); httpHeaders.append(it->value.characters(), it->value.length()); } INTERNET_BUFFERSW internetBuffers; ZeroMemory(&internetBuffers, sizeof(internetBuffers)); internetBuffers.dwStructSize = sizeof(internetBuffers); internetBuffers.lpcszHeader = httpHeaders.data(); internetBuffers.dwHeadersLength = httpHeaders.size(); internetBuffers.dwBufferTotal = d->m_bytesRemainingToWrite; HttpSendRequestExW(d->m_requestHandle, &internetBuffers, 0, 0, reinterpret_cast<DWORD_PTR>(this)); ref(); // balanced by deref in onRequestComplete if (d->m_loadSynchronously) while (onRequestComplete()) { // Loop until finished. } return true; }
/* V_REGEXP -> V_LENS */ static struct value *lns_key(struct info *info, struct value *rxp) { assert(rxp->tag == V_REGEXP); return lns_make_prim(L_KEY, ref(info), ref(rxp->regexp), NULL); }