int main(int argc, char **argv) { const char *s1 = "I have\na lovely\nbunch of\ncoco nuts\n"; printf("on start :\n"); dump(); printf("initing to '%s'\n", s1); tl.readBuf(s1); dump(); printf("val for tag I is '%s'\n", tl.get("I")); printf("val for tag A is '%s'\n", tl.get("A")); printf("val for tag a is '%s'\n", tl.get("a")); printf("val for tag bunch is '%s'\n", tl.get("bunch")); printf("val for tag foo is '%s'\n", tl.get("foo")); printf("int val for tag foo is %d\n", tl.getInt("foo")); printf("int val for tag bunch is %d\n", tl.getInt("bunch")); printf("calling set('i', 'fly')\n"); tl.set("i", "fly"); printf("get('i') returns '%s'\n", tl.get("i")); dump(); printf("calling setInt('i', 777)\n"); tl.set("i", 777); printf("getInt('i') returns %d\n", tl.getInt("i")); dump(); printf("get('coco') returns '%s'\n", tl.get("coco")); printf("calling rem('coco')\n"); tl.rem("coco"); dump(); printf("get('coco') returns '%s'\n", tl.get("coco")); printf("writing to bar.txt returns %d\n", tl.writeFile("bar.txt")); printf("clearing\n"); tl.clear(); dump(); printf("get('i') returns '%s'\n", tl.get("i")); printf("reading back from bar.txt ... returns %d\n", tl.readFile("bar.txt")); dump(); printf("get('i') returns '%s'\n", tl.get("i")); printf("val for tag I is '%s'\n", tl.get("I")); printf("val for tag a is '%s'\n", tl.get("a")); printf("val for tag bunch is '%s'\n", tl.get("bunch")); }
bool MovieClip::createFrames( Reader& reader, SWF& swf, MovieFrames &data ) { RECT empty = {FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX}; data._rectangle = empty; sbCalculateRectangle = true; // get all tags and build frame lists TagHeader header; ITag* tag = NULL; TagList* frame_tags = new TagList; TagList actionTags; do { header.read( reader ); const uint32_t code = header.code(); SWF::TagFactoryFunc factory = SWF::getTagFactory( code ); if (! factory ) { // no registered factory so skip this tag SWF_TRACE("*** SKIP *** "); header.print(); reader.skip( header.length() ); continue; } tag = factory( header ); SWF_ASSERT(tag); int32_t end_pos = reader.getCurrentPos() + tag->length(); bool keepTag = tag->read( reader, swf, data ); tag->print(); reader.align(); int32_t dif = end_pos - reader.getCurrentPos(); if( dif != 0 ) { SWF_TRACE("WARNING: tag not read correctly. trying to skip.\n"); reader.skip( dif ); } if (keepTag) { // collect action tags if (tag->code() == TAG_DO_ACTION) { actionTags.push_back(tag); } else { frame_tags->push_back( tag ); } } else { delete tag; } // create a new frame if ( TAG_SHOW_FRAME == code ) { SWF_TRACE("[%d] has %d tags\n", data._frames.size(), frame_tags->size()); // put action tags at the end of list in order to avoid callback error TagList::iterator it = actionTags.begin(); while (it != actionTags.end()) { frame_tags->push_back( *it ); ++it; } actionTags.clear(); data._frames.push_back( frame_tags ); frame_tags = new TagList; sbCalculateRectangle = false; } } while( header.code() != TAG_END ); delete frame_tags; return true; }