void uv_inject(page_desc_t *pd, page_desc_t *pdbegin, page_desc_t *pdend, unsigned long pages, unsigned long addr, unsigned long addrend, unsigned int pagesize, unsigned long mattr, unsigned long nodeid, unsigned long paddr, char *pte_str, unsigned long nodeid_start, unsigned long mattr_start, unsigned long addr_start, int mce_opt) { int count = 0; eid.cpu = sched_getcpu(); for (pd=pdbegin, pdend=pd+pages; pd<pdend && addr < addrend; pd++, addr += pagesize) { if (pd->flags & PD_HOLE) { pagesize = pd->pte; mattr = 0; nodeid = -1; } else { nodeid = get_pnodeid(*pd); paddr = get_paddr(*pd); if (nodeid == INVALID_NODE) nodeid = 0; mattr = get_memory_attr(*pd); pagesize = get_pagesize(*pd); if (mattr && paddr) { if ((pd_total / 2) == count){ sprintf(pte_str, " 0x%016lx ", pd->pte); printf("\t[%012lx] -> 0x%012lx on %s %3s %s%s\n", addr, paddr, idstr(), nodestr(nodeid), pte_str, get_memory_attr_str(nodeid, mattr)); /* Setting value at memory location for recovery * before injecting. */ memset((void *)addr, 'A', pagesize); injecteddata = (char *)addr; printf("Data:%x\n",*injecteddata); eid.addr = paddr; eid.cpu = nodeid; break;//only allow once for now } } } count++; } if (delay){ printf("Enter char to inject.."); getchar(); } if(!manual){ inject_uc(eid.addr, 0 /*int notrigger*/); } }
//新建目录 int CreateNewDir(std::string DirFiles) { std::ostringstream str; str << Uid; std::string idstr(str.str()); std::string sql = "insert into UserFileInfo(Uid ,UserFileSize , UserFilePath) values( "+idstr+",0,"+DirFiles+");"; if(0 != mysql_query(& mysql,sql.c_str())) { return -1; } return 1; }
TokenStream *NewTokenStream(const char *name) { TokenStream *pTok; pTok = (TokenStream *) malloc(sizeof(TokenStream)); pTok->next = NULL; pTok->name = idstr(name); pTok->head = NULL; pTok->current = NULL; lNewBlock(pTok); return pTok; } // NewTokenStream
TokenStream *NewTokenStream(const char *name, MemoryPool *pool) { TokenStream *pTok; if (!pool) pTok = (TokenStream *) malloc(sizeof(TokenStream)); else pTok = (TokenStream*)mem_Alloc(pool, sizeof(TokenStream)); pTok->next = NULL; pTok->name = idstr(name, pool); pTok->head = NULL; pTok->current = NULL; lNewBlock(pTok, pool); return pTok; } // NewTokenStream
void FreenetMessageInserter::StartTopicInsert(const int localidentityid, const std::string &channel, const std::string &topic) { SQLite3DB::Statement st; std::string idstr(""); std::string data(""); std::string datalengthstr(""); DateTime now; FCPv2::Message mess("ClientPut"); LoadLocalIdentityPrivateKey(localidentityid); if(m_identitykeys[localidentityid]!="") { std::string indexstr("0"); FreenetMessage fm; fm["type"]="settopic"; fm["channel"]=channel; fm["sentdate"]=now.Format("%Y-%m-%d %H:%M:%S"); fm.Body()=topic; data=fm.GetMessageText(); StringFunctions::Convert(localidentityid,idstr); StringFunctions::Convert(data.size(),datalengthstr); StringFunctions::Convert(GetNextMessageIndex(localidentityid,now),indexstr); st=m_db->Prepare("INSERT INTO tblInsertedMessageIndex(LocalIdentityID,Date,MessageIndex) VALUES(?,?,?);"); st.Bind(0,localidentityid); st.Bind(1,now.Format("%Y-%m-%d")); st.Bind(2,indexstr); st.Step(); mess["URI"]="SSK@"+m_identitykeys[localidentityid].substr(4)+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|Message-"+indexstr; mess["Identifier"]=m_fcpuniqueidentifier+"|"+idstr+"|"+now.Format("%Y-%m-%d")+"|"+indexstr+"|"+mess["URI"]; mess["RealTimeFlag"]="true"; mess["UploadFrom"]="direct"; mess["PriorityClass"]=m_insertpriority; mess["ExtraInsertsSingleBlock"]="0"; mess["DataLength"]=datalengthstr; mess["Metadata.ContentType"]=""; m_fcp->Send(mess); m_fcp->Send(std::vector<char>(data.begin(),data.end())); m_log->Debug("FreenetMessageInserter::StartInsert started insert of channel topic "+mess["Identifier"]); } }
TEST_F(LLApiTest, testRanges) { RSIndex* index = RediSearch_CreateIndex("index", NULL, NULL); RediSearch_CreateTextField(index, FIELD_NAME_1); char buf[] = {"Mark_"}; size_t nbuf = strlen(buf); for (char c = 'a'; c < 'z'; c++) { buf[nbuf - 1] = c; char did[64]; sprintf(did, "doc%c", c); RSDoc* d = RediSearch_CreateDocument(did, strlen(did), 0, NULL); RediSearch_DocumentAddFieldCString(d, FIELD_NAME_1, buf, RSFLDTYPE_DEFAULT); RediSearch_SpecAddDocument(index, d); } RSQNode* qn = RediSearch_CreateLexRangeNode(index, FIELD_NAME_1, "MarkN", "MarkX"); RSResultsIterator* iter = RediSearch_GetResultsIterator(qn, index); ASSERT_FALSE(NULL == iter); std::set<std::string> results; const char* id; size_t nid; while ((id = (const char*)RediSearch_ResultsIteratorNext(iter, index, &nid))) { std::string idstr(id, nid); ASSERT_EQ(results.end(), results.find(idstr)); results.insert(idstr); } ASSERT_EQ(10, results.size()); for (char c = 'n'; c < 'x'; c++) { char namebuf[64]; sprintf(namebuf, "doc%c", c); ASSERT_NE(results.end(), results.find(namebuf)); } RediSearch_ResultsIteratorFree(iter); // printf("Have %lu ids in range!\n", results.size()); RediSearch_DropIndex(index); }
void FreenetMessageInserter::StartPrivateInsert(const int localidentityid, const int recipientidentityid, const std::string &message) { RSAKeyPair rsa; std::string idstr(""); std::string publickey(""); std::string rsapublickey(""); std::string data(""); std::string datalengthstr(""); DateTime now; FCPv2::Message mess("ClientPut"); LoadLocalIdentityPrivateKey(localidentityid); SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, RSAPublicKey FROM tblIdentity WHERE IdentityID=?;"); st.Bind(0,recipientidentityid); st.Step(); if(st.RowReturned()) { st.ResultText(0,publickey); st.ResultText(1,rsapublickey); } if(publickey!="" && rsapublickey!="" && rsa.SetFromEncodedPublicKey(rsapublickey)) { if(m_identitykeys[localidentityid]!="") { std::string indexstr("0"); FreenetMessage fm; fm["type"]="privatemessage"; fm["recipient"]=publickey; fm["sentdate"]=now.Format("%Y-%m-%d %H:%M:%S"); rsa.Encrypt(message,fm.Body()); data=fm.GetMessageText(); StringFunctions::Convert(localidentityid,idstr); StringFunctions::Convert(data.size(),datalengthstr); StringFunctions::Convert(GetNextMessageIndex(localidentityid,now),indexstr); st=m_db->Prepare("INSERT INTO tblInsertedMessageIndex(LocalIdentityID,Date,MessageIndex) VALUES(?,?,?);"); st.Bind(0,localidentityid); st.Bind(1,now.Format("%Y-%m-%d")); st.Bind(2,indexstr); st.Step(); mess["URI"]="SSK@"+m_identitykeys[localidentityid].substr(4)+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|Message-"+indexstr; mess["Identifier"]=m_fcpuniqueidentifier+"|"+idstr+"|"+now.Format("%Y-%m-%d")+"|"+indexstr+"|"+mess["URI"]; mess["RealTimeFlag"]="true"; mess["UploadFrom"]="direct"; mess["PriorityClass"]=m_insertpriority; mess["ExtraInsertsSingleBlock"]="0"; mess["DataLength"]=datalengthstr; mess["Metadata.ContentType"]=""; m_fcp->Send(mess); m_fcp->Send(std::vector<char>(data.begin(),data.end())); m_log->Debug("FreenetMessageInserter::StartInsert started insert of private message "+mess["Identifier"]); } } }
void CBinarySerializerScriptImpl::HandleScriptVal(JS::HandleValue val) { JSContext* cx = m_ScriptInterface.GetContext(); JSAutoRequest rq(cx); switch (JS_TypeOfValue(cx, val)) { case JSTYPE_VOID: { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_VOID); break; } case JSTYPE_NULL: // This type is never actually returned (it's a JS2 feature) { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_NULL); break; } case JSTYPE_OBJECT: { if (val.isNull()) { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_NULL); break; } JS::RootedObject obj(cx, &val.toObject()); // If we've already serialized this object, just output a reference to it u32 tag = GetScriptBackrefTag(obj); if (tag) { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_BACKREF); m_Serializer.NumberU32_Unbounded("tag", tag); break; } // Arrays are special cases of Object if (JS_IsArrayObject(cx, obj)) { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_ARRAY); // TODO: probably should have a more efficient storage format // Arrays like [1, 2, ] have an 'undefined' at the end which is part of the // length but seemingly isn't enumerated, so store the length explicitly uint length = 0; if (!JS_GetArrayLength(cx, obj, &length)) throw PSERROR_Serialize_ScriptError("JS_GetArrayLength failed"); m_Serializer.NumberU32_Unbounded("array length", length); } else if (JS_IsTypedArrayObject(obj)) { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_TYPED_ARRAY); m_Serializer.NumberU8_Unbounded("array type", GetArrayType(JS_GetArrayBufferViewType(obj))); m_Serializer.NumberU32_Unbounded("byte offset", JS_GetTypedArrayByteOffset(obj)); m_Serializer.NumberU32_Unbounded("length", JS_GetTypedArrayLength(obj)); // Now handle its array buffer // this may be a backref, since ArrayBuffers can be shared by multiple views JS::RootedValue bufferVal(cx, JS::ObjectValue(*JS_GetArrayBufferViewBuffer(cx, obj))); HandleScriptVal(bufferVal); break; } else if (JS_IsArrayBufferObject(obj)) { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_ARRAY_BUFFER); #if BYTE_ORDER != LITTLE_ENDIAN #error TODO: need to convert JS ArrayBuffer data to little-endian #endif u32 length = JS_GetArrayBufferByteLength(obj); m_Serializer.NumberU32_Unbounded("buffer length", length); JS::AutoCheckCannotGC nogc; m_Serializer.RawBytes("buffer data", (const u8*)JS_GetArrayBufferData(obj, nogc), length); break; } else { // Find type of object const JSClass* jsclass = JS_GetClass(obj); if (!jsclass) throw PSERROR_Serialize_ScriptError("JS_GetClass failed"); // TODO: Remove this workaround for upstream API breakage when updating SpiderMonkey // See https://bugzilla.mozilla.org/show_bug.cgi?id=1236373 #define JSCLASS_CACHED_PROTO_WIDTH js::JSCLASS_CACHED_PROTO_WIDTH JSProtoKey protokey = JSCLASS_CACHED_PROTO_KEY(jsclass); #undef JSCLASS_CACHED_PROTO_WIDTH if (protokey == JSProto_Object) { // Object class - check for user-defined prototype JS::RootedObject proto(cx); JS_GetPrototype(cx, obj, &proto); if (!proto) throw PSERROR_Serialize_ScriptError("JS_GetPrototype failed"); if (m_SerializablePrototypes->empty() || !IsSerializablePrototype(proto)) { // Standard Object prototype m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_OBJECT); // TODO: maybe we should throw an error for unrecognized non-Object prototypes? // (requires fixing AI serialization first and excluding component scripts) } else { // User-defined custom prototype m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_OBJECT_PROTOTYPE); const std::wstring prototypeName = GetPrototypeName(proto); m_Serializer.String("proto name", prototypeName, 0, 256); // Does it have custom Serialize function? // if so, we serialize the data it returns, rather than the object's properties directly bool hasCustomSerialize; if (!JS_HasProperty(cx, obj, "Serialize", &hasCustomSerialize)) throw PSERROR_Serialize_ScriptError("JS_HasProperty failed"); if (hasCustomSerialize) { JS::RootedValue serialize(cx); if (!JS_GetProperty(cx, obj, "Serialize", &serialize)) throw PSERROR_Serialize_ScriptError("JS_GetProperty failed"); // If serialize is null, so don't serialize anything more if (!serialize.isNull()) { JS::RootedValue data(cx); if (!m_ScriptInterface.CallFunction(val, "Serialize", &data)) throw PSERROR_Serialize_ScriptError("Prototype Serialize function failed"); HandleScriptVal(data); } break; } } } else if (protokey == JSProto_Number) { // Standard Number object m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_OBJECT_NUMBER); // Get primitive value double d; if (!JS::ToNumber(cx, val, &d)) throw PSERROR_Serialize_ScriptError("JS::ToNumber failed"); m_Serializer.NumberDouble_Unbounded("value", d); break; } else if (protokey == JSProto_String) { // Standard String object m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_OBJECT_STRING); // Get primitive value JS::RootedString str(cx, JS::ToString(cx, val)); if (!str) throw PSERROR_Serialize_ScriptError("JS_ValueToString failed"); ScriptString("value", str); break; } else if (protokey == JSProto_Boolean) { // Standard Boolean object m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_OBJECT_BOOLEAN); // Get primitive value bool b = JS::ToBoolean(val); m_Serializer.Bool("value", b); break; } // TODO: Follow upstream progresses about a JS::IsMapObject // https://bugzilla.mozilla.org/show_bug.cgi?id=1285909 else if (protokey == JSProto_Map) { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_OBJECT_MAP); m_Serializer.NumberU32_Unbounded("map size", JS::MapSize(cx, obj)); JS::RootedValue keyValueIterator(cx); if (!JS::MapEntries(cx, obj, &keyValueIterator)) throw PSERROR_Serialize_ScriptError("JS::MapEntries failed"); JS::ForOfIterator it(cx); if (!it.init(keyValueIterator)) throw PSERROR_Serialize_ScriptError("JS::ForOfIterator::init failed"); JS::RootedValue keyValuePair(cx); bool done; while (true) { if (!it.next(&keyValuePair, &done)) throw PSERROR_Serialize_ScriptError("JS::ForOfIterator::next failed"); if (done) break; JS::RootedObject keyValuePairObj(cx, &keyValuePair.toObject()); JS::RootedValue key(cx); JS::RootedValue value(cx); ENSURE(JS_GetElement(cx, keyValuePairObj, 0, &key)); ENSURE(JS_GetElement(cx, keyValuePairObj, 1, &value)); HandleScriptVal(key); HandleScriptVal(value); } break; } // TODO: Follow upstream progresses about a JS::IsSetObject // https://bugzilla.mozilla.org/show_bug.cgi?id=1285909 else if (protokey == JSProto_Set) { // TODO: When updating SpiderMonkey to a release after 38 use the C++ API for Sets. // https://bugzilla.mozilla.org/show_bug.cgi?id=1159469 u32 setSize; m_ScriptInterface.GetProperty(val, "size", setSize); m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_OBJECT_SET); m_Serializer.NumberU32_Unbounded("set size", setSize); JS::RootedValue valueIterator(cx); m_ScriptInterface.CallFunction(val, "values", &valueIterator); for (u32 i=0; i<setSize; ++i) { JS::RootedValue currentIterator(cx); JS::RootedValue value(cx); ENSURE(m_ScriptInterface.CallFunction(valueIterator, "next", ¤tIterator)); m_ScriptInterface.GetProperty(currentIterator, "value", &value); HandleScriptVal(value); } break; } else { // Unrecognized class LOGERROR("Cannot serialise JS objects with unrecognized class '%s'", jsclass->name); throw PSERROR_Serialize_InvalidScriptValue(); } } // Find all properties (ordered by insertion time) JS::AutoIdArray ida (cx, JS_Enumerate(cx, obj)); if (!ida) throw PSERROR_Serialize_ScriptError("JS_Enumerate failed"); m_Serializer.NumberU32_Unbounded("num props", (u32)ida.length()); for (size_t i = 0; i < ida.length(); ++i) { JS::RootedId id(cx, ida[i]); JS::RootedValue idval(cx); JS::RootedValue propval(cx); // Forbid getters, which might delete values and mess things up. JS::Rooted<JSPropertyDescriptor> desc(cx); if (!JS_GetPropertyDescriptorById(cx, obj, id, &desc)) throw PSERROR_Serialize_ScriptError("JS_GetPropertyDescriptorById failed"); if (desc.hasGetterObject()) throw PSERROR_Serialize_ScriptError("Cannot serialize property getters"); // Get the property name as a string if (!JS_IdToValue(cx, id, &idval)) throw PSERROR_Serialize_ScriptError("JS_IdToValue failed"); JS::RootedString idstr(cx, JS::ToString(cx, idval)); if (!idstr) throw PSERROR_Serialize_ScriptError("JS_ValueToString failed"); ScriptString("prop name", idstr); if (!JS_GetPropertyById(cx, obj, id, &propval)) throw PSERROR_Serialize_ScriptError("JS_GetPropertyById failed"); HandleScriptVal(propval); } break; } case JSTYPE_FUNCTION: { // We can't serialise functions, but we can at least name the offender (hopefully) std::wstring funcname(L"(unnamed)"); JS::RootedFunction func(cx, JS_ValueToFunction(cx, val)); if (func) { JS::RootedString string(cx, JS_GetFunctionId(func)); if (string) { if (JS_StringHasLatin1Chars(string)) { size_t length; JS::AutoCheckCannotGC nogc; const JS::Latin1Char* ch = JS_GetLatin1StringCharsAndLength(cx, nogc, string, &length); if (ch && length > 0) funcname.assign(ch, ch + length); } else { size_t length; JS::AutoCheckCannotGC nogc; const char16_t* ch = JS_GetTwoByteStringCharsAndLength(cx, nogc, string, &length); if (ch && length > 0) funcname.assign(ch, ch + length); } } } LOGERROR("Cannot serialise JS objects of type 'function': %s", utf8_from_wstring(funcname)); throw PSERROR_Serialize_InvalidScriptValue(); } case JSTYPE_STRING: { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_STRING); JS::RootedString stringVal(cx, val.toString()); ScriptString("string", stringVal); break; } case JSTYPE_NUMBER: { // To reduce the size of the serialized data, we handle integers and doubles separately. // We can't check for val.isInt32 and val.isDouble directly, because integer numbers are not guaranteed // to be represented as integers. A number like 33 could be stored as integer on the computer of one player // and as double on the other player's computer. That would cause out of sync errors in multiplayer games because // their binary representation and thus the hash would be different. double d; d = val.toNumber(); i32 integer; if (JS_DoubleIsInt32(d, &integer)) { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_INT); m_Serializer.NumberI32_Unbounded("value", integer); } else { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_DOUBLE); m_Serializer.NumberDouble_Unbounded("value", d); } break; } case JSTYPE_BOOLEAN: { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_BOOLEAN); bool b = val.toBoolean(); m_Serializer.NumberU8_Unbounded("value", b ? 1 : 0); break; } default: { debug_warn(L"Invalid TypeOfValue"); throw PSERROR_Serialize_InvalidScriptValue(); } } }
void LLFloaterAO::refresh() { childSetText("line_walking", idstr(LLAO::mOverrides[LLUUID("6ed24bd8-91aa-4b12-ccc7-c97c857ab4e0")])); childSetText("line_running", idstr(LLAO::mOverrides[LLUUID("05ddbff8-aaa9-92a1-2b74-8fe77a29b445")])); childSetText("line_crouchwalk", idstr(LLAO::mOverrides[LLUUID("47f5f6fb-22e5-ae44-f871-73aaaf4a6022")])); childSetText("line_flying", idstr(LLAO::mOverrides[LLUUID("aec4610c-757f-bc4e-c092-c6e9caf18daf")])); childSetText("line_turn_left", idstr(LLAO::mOverrides[LLUUID("56e0ba0d-4a9f-7f27-6117-32f2ebbf6135")])); childSetText("line_turn_right", idstr(LLAO::mOverrides[LLUUID("2d6daa51-3192-6794-8e2e-a15f8338ec30")])); childSetText("line_jumping", idstr(LLAO::mOverrides[LLUUID("2305bd75-1ca9-b03b-1faa-b176b8a8c49e")])); childSetText("line_fly_up", idstr(LLAO::mOverrides[LLUUID("62c5de58-cb33-5743-3d07-9e4cd4352864")])); childSetText("line_crouching", idstr(LLAO::mOverrides[LLUUID("201f3fdf-cb1f-dbec-201f-7333e328ae7c")])); childSetText("line_fly_down", idstr(LLAO::mOverrides[LLUUID("20f063ea-8306-2562-0b07-5c853b37b31e")])); mStandsCombo->clearRows(); for(std::list<LLUUID>::iterator itr = LLAO::mStandOverrides.begin();itr != LLAO::mStandOverrides.end(); itr++) { mStandsCombo->add((*itr).asString()); } mStandsCombo->setSimple(LLStringExplicit(LLAO::mStandOverrides.back().asString())); childSetText("line_hover", idstr(LLAO::mOverrides[LLUUID("4ae8016b-31b9-03bb-c401-b1ea941db41d")])); childSetText("line_sitting", idstr(LLAO::mOverrides[LLUUID("1a5fe8ac-a804-8a5d-7cbd-56bd83184568")])); childSetText("line_prejump", idstr(LLAO::mOverrides[LLUUID("7a4e87fe-de39-6fcb-6223-024b00893244")])); childSetText("line_falling", idstr(LLAO::mOverrides[LLUUID("666307d9-a860-572d-6fd4-c3ab8865c094")])); childSetText("line_stride", idstr(LLAO::mOverrides[LLUUID("1cb562b0-ba21-2202-efb3-30f82cdf9595")])); childSetText("line_soft_landing", idstr(LLAO::mOverrides[LLUUID("7a17b059-12b2-41b1-570a-186368b6aa6f")])); childSetText("line_medium_landing", idstr(LLAO::mOverrides[LLUUID("f4f00d6e-b9fe-9292-f4cb-0ae06ea58d57")])); childSetText("line_hard_landing", idstr(LLAO::mOverrides[LLUUID("3da1d753-028a-5446-24f3-9c9b856d9422")])); childSetText("line_flying_slow", idstr(LLAO::mOverrides[LLUUID("2b5a38b2-5e00-3a97-a495-4c826bc443e6")])); childSetText("line_sitting_on_ground", idstr(LLAO::mOverrides[LLUUID("1a2bd58e-87ff-0df8-0b4c-53e047b0bb6e")])); }