bool SQClosure::Load( SQVM *v, SQUserPointer up, SQREADFUNC read ) { _CHECK_IO( CheckTag( v, read, up, SQ_CLOSURESTREAM_HEAD ) ); _CHECK_IO( CheckTag( v, read, up, sizeof( SQChar ) ) ); _CHECK_IO( _funcproto( _function )->Load( v, up, read ) ); _CHECK_IO( CheckTag( v, read, up, SQ_CLOSURESTREAM_TAIL ) ); return true; }
bool SQClosure::Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret) { _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_HEAD)); _CHECK_IO(CheckTag(v,read,up,sizeof(SQChar))); SQObjectPtr func; _CHECK_IO(SQFunctionProto::Load(v,up,read,func)); _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_TAIL)); ret = SQClosure::Create(_ss(v),_funcproto(func)); return true; }
bool SQFunctionProto::Load(SQVM *v,SQUserPointer up,SQREADFUNC read) { SQInteger i, nsize = _literals.size(); SQObjectPtr o; _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(ReadObject(v, up, read, _sourcename)); _CHECK_IO(ReadObject(v, up, read, _name)); _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(SafeRead(v,read,up, &nsize, sizeof(nsize))); for(i = 0;i < nsize; i++){ _CHECK_IO(ReadObject(v, up, read, o)); _literals.push_back(o); } _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(SafeRead(v,read,up, &nsize, sizeof(nsize))); for(i = 0; i < nsize; i++){ _CHECK_IO(ReadObject(v, up, read, o)); _parameters.push_back(o); } _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(SafeRead(v,read,up,&nsize,sizeof(nsize))); for(i = 0; i < nsize; i++){ SQUnsignedInteger type; SQObjectPtr name; _CHECK_IO(SafeRead(v,read,up, &type, sizeof(SQUnsignedInteger))); _CHECK_IO(ReadObject(v, up, read, o)); _CHECK_IO(ReadObject(v, up, read, name)); _outervalues.push_back(SQOuterVar(name,o, (SQOuterType)type)); } _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(SafeRead(v,read,up,&nsize, sizeof(nsize))); for(i = 0; i < nsize; i++){ SQLocalVarInfo lvi; _CHECK_IO(ReadObject(v, up, read, lvi._name)); _CHECK_IO(SafeRead(v,read,up, &lvi._pos, sizeof(SQUnsignedInteger))); _CHECK_IO(SafeRead(v,read,up, &lvi._start_op, sizeof(SQUnsignedInteger))); _CHECK_IO(SafeRead(v,read,up, &lvi._end_op, sizeof(SQUnsignedInteger))); _localvarinfos.push_back(lvi); } _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(SafeRead(v,read,up, &nsize,sizeof(nsize))); _lineinfos.resize(nsize); _CHECK_IO(SafeRead(v,read,up, &_lineinfos[0], sizeof(SQLineInfo)*nsize)); _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(SafeRead(v,read,up, &nsize, sizeof(nsize))); _instructions.resize(nsize); _CHECK_IO(SafeRead(v,read,up, &_instructions[0], sizeof(SQInstruction)*nsize)); _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(SafeRead(v,read,up, &nsize, sizeof(nsize))); for(i = 0; i < nsize; i++){ o = SQFunctionProto::Create(); _CHECK_IO(_funcproto(o)->Load(v, up, read)); _functions.push_back(o); } _CHECK_IO(SafeRead(v,read,up, &_stacksize, sizeof(_stacksize))); _CHECK_IO(SafeRead(v,read,up, &_bgenerator, sizeof(_bgenerator))); _CHECK_IO(SafeRead(v,read,up, &_varparams, sizeof(_varparams))); return true; }
static bool_t Login_Validate_m ( Login_cl *self, string_t certificate, Domain_ID domain ) { Login_st *st = self->st; UnixLoginMod_st *lst = st->lst; Certificate *c; MU_LOCK(&lst->mu); /* Find the certificate */ if (!StringTbl$Get(lst->certificate_tbl, certificate, (void *)&c)) { MU_RELEASE(&lst->mu); TRC(printf("Login_Validate: unknown certificate %s\n",certificate)); return False; /* Not a valid certificate */ } /* Check the certificate */ if (!Security$CheckTag(lst->sec, c->tag, domain)) { MU_RELEASE(&lst->mu); TRC(printf("Login_Validate: certificate %s (%s) may not be used by" "domain %qx\n",certificate, c->u->username, domain)); return False; /* Domain does not own certificate */ } MU_RELEASE(&lst->mu); return True; /* Certificate is valid for domain to use */ }
//run simulation for 10000 void runSimulation(int *world, int worldsize, player *people, int players, int numSteps){ for (int i = 0; i < numSteps; i++){ CheckTag(world, worldsize, people, players); MoveZombies(world, worldsize, people, players); updateWorld(world, worldsize, people, players); CheckTag(world, worldsize, people, players); MoveZombies(world, worldsize, people, players); updateWorld(world, worldsize, people, players); CheckTag(world, worldsize, people, players); MoveZombies(world, worldsize, people, players); updateWorld(world, worldsize, people, players); CheckTag(world, worldsize, people, players); MoveHumans(world, worldsize, people, players); updateWorld(world, worldsize, people, players); CheckTag(world, worldsize, people, players); } }
static bool_t Login_Login_m ( Login_cl *self, Security_Tag tag /* IN */, string_t username /* IN */, string_t password /* IN */ /* RETURNS */, string_t *certificate ) { Login_st *st = self->st; UnixLoginMod_st *lst = st->lst; User *u; Certificate *c; /* Check that caller owns the tag */ if (!Security$CheckTag(lst->sec, tag, st->id)) { TRC(printf("Login: domain %qx doesn't have tag %qx\n",st->id,tag)); *certificate=strduph("invalid", lst->heap); return False; /* Bad tag */ } /* Lookup username */ if (!StringTbl$Get(lst->users, username, (void *)&u)) { *certificate=strduph("invalid", lst->heap); TRC(printf("Login: domain %qx tried to login with unknown " "username %s\n",st->id,username)); return False; /* Bad username */ } /* XXX Check password; skip for now */ /* Proceed: generate a new certificate */ c=Heap$Malloc(lst->heap, sizeof(*c)); if (!c) { TRC(printf("Login: out of memory\n")); return False; /* Out of memory */ } MU_LOCK(&lst->mu); c->tag=tag; c->u=u; c->cert=Heap$Malloc(lst->heap, 18+strlen(username)); sprintf(c->cert, "%s:%x", username, lst->certificate_id++); LINK_ADD_TO_HEAD(&lst->certificate_list, c); StringTbl$Put(lst->certificate_tbl, c->cert, c); MU_RELEASE(&lst->mu); *certificate=strduph(c->cert, lst->heap); TRC(printf("Login: user %s logged in; issued certificate %s\n" " bound to tag %qx\n",c->u->username,c->cert,tag)); return True; /* User logged on */ }
static bool_t Login_Logout_m ( Login_cl *self, string_t certificate /* IN */ ) { Login_st *st = self->st; UnixLoginMod_st *lst = st->lst; Certificate *c; MU_LOCK(&lst->mu); /* Find the certificate */ if (!StringTbl$Get(lst->certificate_tbl, certificate, (void *)&c)) { MU_RELEASE(&lst->mu); TRC(printf("Logout: unknown certificate %s\n",certificate)); return False; /* Not a valid certificate */ } /* Check that the caller is allowed to use the certificate */ if (!Security$CheckTag(lst->sec, c->tag, st->id)) { MU_RELEASE(&lst->mu); TRC(printf("Logout: domain %qx attempted to delete certificate " "%s (%s),\n" " but does not possess tag %qx\n",st->id, certificate, c->u->username, c->tag)); return False; /* Invalid logout attempt */ } /* Go ahead and do it */ TRC(printf("Logout: domain %qx deleted certificate %s (%s)\n", st->id, certificate, c->u->username)); StringTbl$Delete(lst->certificate_tbl, certificate, (void *)&c); LINK_REMOVE(c); FREE(c->cert); FREE(c); MU_RELEASE(&lst->mu); return True; /* User logged off */ }
void CHandleOutSearch::HandleChildElement(TiXmlNode* aElement) { TInt index=iPointArray.Count()-1; TInt itemIndex=iPointArray[index]->GetItemCount()-1; if(itemIndex<0) { iPointArray[index]->CreatNewItem(); itemIndex=0; } if(aElement->NoChildren()) { if(iFlag) { HBufC* buf = CnvUtfConverter::ConvertToUnicodeFromUtf8L(TPtrC8((const TUint8*)aElement->Value())); CleanupStack::PushL(buf); if(buf->Compare(_L("br"))==0) { if(!iPointArray[index]->GetItem(itemIndex).IsNull()) iPointArray[index]->CreatNewItem(); } if(buf->Compare(_L("br"))!=0&&buf->Compare(_L("img"))!=0&&buf->Compare(_L("input"))!=0&&buf->Compare(_L("|"))!=0) { if(buf->Left(2).Compare(_L("--"))==0) { TInt f=0; for(TInt i=0;i<buf->Length();i++) { if(buf->Mid(i,1).Compare(_L("-"))!=0) { f=1; break; } } if(f==0) { iFlag=EFalse; } } if(iFlag) iPointArray[index]->GetItem(itemIndex).SetName(*buf); else { if(!iPointArray[index]->GetItem(itemIndex).IsNull()) iPointArray[index]->CreatNewItem(); } } iMainEngine.WriteLog16(*buf); CleanupStack::PopAndDestroy(1); } } else { HBufC8* tag=TPtrC8((const TUint8*)aElement->Value()).Alloc(); CleanupStack::PushL(tag); TInt value=CheckTag(*tag); CleanupStack::PopAndDestroy(1); if(value>0) { switch(value) { case 1: //P±êÇ© { TiXmlNode* element=aElement->FirstChild(); while(element!=0) { HandleChildElement(element); element=element->NextSibling(); } } break; case 2: //Á¬½Ó±êÇ© { HBufC8* bufUrl = TPtrC8((const TUint8*)aElement->ToElement()->Attribute("href")).Alloc(); CleanupStack::PushL(bufUrl); TInt urlFlag=CheckUrl(*bufUrl); if(urlFlag>0) { iPointArray[index]->GetItem(itemIndex).SetUrl(*bufUrl); } CleanupStack::PopAndDestroy(1); if(urlFlag==1||urlFlag==2) { HBufC* buf = CnvUtfConverter::ConvertToUnicodeFromUtf8L(TPtrC8((const TUint8*)aElement->FirstChild()->Value())); CleanupStack::PushL(buf); iPointArray[index]->GetItem(itemIndex).SetName(*buf); iMainEngine.WriteLog16(*buf); CleanupStack::PopAndDestroy(1); iPointArray[index]->GetItem(itemIndex).SetIsLink(ETrue); iPointArray[index]->CreatNewItem(); } else { HBufC* buf = CnvUtfConverter::ConvertToUnicodeFromUtf8L(TPtrC8((const TUint8*)aElement->FirstChild()->Value())); CleanupStack::PushL(buf); HBufC8* bufUrl = TPtrC8((const TUint8*)aElement->ToElement()->Attribute("href")).Alloc(); CleanupStack::PushL(bufUrl); if(CheckUrl(*bufUrl)==3) { if(buf->Compare(iMainEngine.GetDesById(ETurkeyTextRes_DownPage))==0||buf->Compare(iMainEngine.GetDesById(ETurkeyTextRes_HXML_DPage))==0) { iPointArray[index]->SetNextPageUrl(*bufUrl); } else if(buf->Compare(iMainEngine.GetDesById(ETurkeyTextRes_UpPage))==0||buf->Compare(iMainEngine.GetDesById(ETurkeyTextRes_HXML_UPage))==0) { iPointArray[index]->SetPrePageUrl(*bufUrl); } } iMainEngine.WriteLog16(*buf); CleanupStack::PopAndDestroy(2); } } break; case 4://»»ÐбêÇ© if(!iPointArray[index]->GetItem(itemIndex).IsNull()&&iFlag) iPointArray[index]->CreatNewItem(); break; case 3://×ÖÌå±êÇ© { if(iFlag) { HBufC* buf = CnvUtfConverter::ConvertToUnicodeFromUtf8L(TPtrC8((const TUint8*)aElement->FirstChild()->Value())); CleanupStack::PushL(buf); iPointArray[index]->GetItem(itemIndex).SetName(*buf); iMainEngine.WriteLog16(*buf); CleanupStack::PopAndDestroy(1); } } break; } } } }
bool SQFunctionProto::Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret) { SQInteger i, nliterals,nparameters; SQInteger noutervalues ,nlocalvarinfos ; SQInteger nlineinfos,ninstructions ,nfunctions,ndefaultparams ; SQObjectPtr sourcename, name; SQObjectPtr o; _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(ReadObject(v, up, read, sourcename)); _CHECK_IO(ReadObject(v, up, read, name)); _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(SafeRead(v,read,up, &nliterals, sizeof(nliterals))); _CHECK_IO(SafeRead(v,read,up, &nparameters, sizeof(nparameters))); _CHECK_IO(SafeRead(v,read,up, &noutervalues, sizeof(noutervalues))); _CHECK_IO(SafeRead(v,read,up, &nlocalvarinfos, sizeof(nlocalvarinfos))); _CHECK_IO(SafeRead(v,read,up, &nlineinfos, sizeof(nlineinfos))); _CHECK_IO(SafeRead(v,read,up, &ndefaultparams, sizeof(ndefaultparams))); _CHECK_IO(SafeRead(v,read,up, &ninstructions, sizeof(ninstructions))); _CHECK_IO(SafeRead(v,read,up, &nfunctions, sizeof(nfunctions))); SQFunctionProto *f = SQFunctionProto::Create(ninstructions,nliterals,nparameters, nfunctions,noutervalues,nlineinfos,nlocalvarinfos,ndefaultparams); SQObjectPtr proto = f; //gets a ref in case of failure f->_sourcename = sourcename; f->_name = name; _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); for(i = 0;i < nliterals; i++){ _CHECK_IO(ReadObject(v, up, read, o)); f->_literals[i] = o; } _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); for(i = 0; i < nparameters; i++){ _CHECK_IO(ReadObject(v, up, read, o)); f->_parameters[i] = o; } _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); for(i = 0; i < noutervalues; i++){ SQUnsignedInteger type; SQObjectPtr name; _CHECK_IO(SafeRead(v,read,up, &type, sizeof(SQUnsignedInteger))); _CHECK_IO(ReadObject(v, up, read, o)); _CHECK_IO(ReadObject(v, up, read, name)); f->_outervalues[i] = SQOuterVar(name,o, (SQOuterType)type); } _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); for(i = 0; i < nlocalvarinfos; i++){ SQLocalVarInfo lvi; _CHECK_IO(ReadObject(v, up, read, lvi._name)); _CHECK_IO(SafeRead(v,read,up, &lvi._pos, sizeof(SQUnsignedInteger))); _CHECK_IO(SafeRead(v,read,up, &lvi._start_op, sizeof(SQUnsignedInteger))); _CHECK_IO(SafeRead(v,read,up, &lvi._end_op, sizeof(SQUnsignedInteger))); f->_localvarinfos[i] = lvi; } _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(SafeRead(v,read,up, f->_lineinfos, sizeof(SQLineInfo)*nlineinfos)); _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(SafeRead(v,read,up, f->_defaultparams, sizeof(SQInteger)*ndefaultparams)); _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); _CHECK_IO(SafeRead(v,read,up, f->_instructions, sizeof(SQInstruction)*ninstructions)); _CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART)); for(i = 0; i < nfunctions; i++){ _CHECK_IO(_funcproto(o)->Load(v, up, read, o)); f->_functions[i] = o; } _CHECK_IO(SafeRead(v,read,up, &f->_stacksize, sizeof(f->_stacksize))); _CHECK_IO(SafeRead(v,read,up, &f->_bgenerator, sizeof(f->_bgenerator))); _CHECK_IO(SafeRead(v,read,up, &f->_varparams, sizeof(f->_varparams))); ret = f; return true; }
bool ReadTag ( IO::InputStream* inputStream, TagState & inOutTagState, long* tagType, XMP_Uns32* tagLength, XMP_Uns64& inOutPosition ) { try { XMP_Uns64 startPosition = inOutPosition; long bytesRead; XMP_Uns8 buffer[4]; bytesRead = inputStream->Read ( buffer, 2 ); if ( bytesRead != 2 ) return false; inOutPosition += 2; XMP_Uns16 code = GetUns16LE ( buffer ); *tagType = code >> 6; *tagLength = code & 0x3f; bool longTag = false; if ( *tagLength == 0x3f ) { longTag = true; bytesRead = inputStream->Read ( buffer, 4 ); if ( bytesRead != 4 ) return false; inOutPosition += 4; *tagLength = GetUns32LE ( buffer ); } inOutPosition += *tagLength; TagData newTag; newTag.pos = startPosition; newTag.len = *tagLength; newTag.id = *tagType; newTag.offset = ( (! longTag) ? 2 : 6 ); // we cannot check valid XMP within the handler // provide validating XMP by invoking XMPCore // check tag for XMP if ( newTag.id == SWF_TAG_ID_METADATA ) { newTag.xmp = true; inOutTagState.xmpTag = newTag; CheckTag ( inputStream, inOutTagState, newTag ); if ( ! inOutTagState.hasFileAttrTag ) inOutTagState.hasXMP = true; } //store FileAttribute Tag if ( newTag.id == SWF_TAG_ID_FILEATTRIBUTES ) { inOutTagState.hasFileAttrTag = true; inOutTagState.fileAttrTag = newTag; inOutTagState.hasXMP = HasMetadata ( inputStream, inOutTagState ); //decreasing since stream moved on within HasMetadata function *tagLength -= 4; } //store tag in vector to process later inOutTagState.tags.push_back ( newTag ); //seek to next tag if ( ! newTag.xmp ) inputStream->Skip ( *tagLength ); if ( inputStream->IsEOF() ) return false; } catch ( ... ) { return false; } return true; } // ReadTag