From eb6d517dce0916eff0077dac5359b48537ddc351 Mon Sep 17 00:00:00 2001 From: kramm Date: Mon, 6 Oct 2008 12:58:11 +0000 Subject: [PATCH] made extra tag insertion during write() optional --- lib/rfxswf.c | 84 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/lib/rfxswf.c b/lib/rfxswf.c index b540cf1..16e0005 100644 --- a/lib/rfxswf.c +++ b/lib/rfxswf.c @@ -1289,6 +1289,8 @@ int swf_ReadSWF(int handle, SWF * swf) return swf_ReadSWF2(&reader, swf); } +int no_extra_tags = 0; + int swf_WriteSWF2(writer_t*writer, SWF * swf) // Writes SWF to file, returns length or <0 if fails { U32 len; TAG * t; @@ -1307,51 +1309,55 @@ int swf_WriteSWF2(writer_t*writer, SWF * swf) // Writes SWF to file, return // Insert REFLEX Tag + if(!no_extra_tags) { + /* this block needs a complete rewrite */ + #ifdef INSERT_RFX_TAG - if ((swf->firstTag && swf->firstTag->id != ST_REFLEX) && - (!swf->firstTag->next || (swf->firstTag->next->id != ST_REFLEX && - (!swf->firstTag->next->next || (swf->firstTag->next->next->id!=ST_REFLEX))))) - { - swf_SetBlock(swf_InsertTagBefore(swf, swf->firstTag,ST_REFLEX),(U8*)"rfx",3); - } + if ((swf->firstTag && swf->firstTag->id != ST_REFLEX) && + (!swf->firstTag->next || (swf->firstTag->next->id != ST_REFLEX && + (!swf->firstTag->next->next || (swf->firstTag->next->next->id!=ST_REFLEX))))) + { + swf_SetBlock(swf_InsertTagBefore(swf, swf->firstTag,ST_REFLEX),(U8*)"rfx",3); + } #endif // INSERT_RFX_TAG - if(swf->fileVersion >= 9) { - if ((!swf->firstTag || swf->firstTag->id != ST_SCENEDESCRIPTION) && - (!swf->firstTag || - !swf->firstTag->next || swf->firstTag->next->id != ST_SCENEDESCRIPTION) && - (!swf->firstTag || - !swf->firstTag->next || - !swf->firstTag->next->next || swf->firstTag->next->next->id != ST_SCENEDESCRIPTION)) - { - TAG*scene = swf_InsertTagBefore(swf, swf->firstTag,ST_SCENEDESCRIPTION); - swf_SetU16(scene, 1); - swf_SetString(scene, (U8*)"Scene 1"); - swf_SetU8(scene, 0); - } - } - - if(swf->fileVersion >= 9) { - TAG*tag = swf->firstTag; - U32 flags = 0x08; // | 128 = usenetwork, | 16 = hasmetadata | 8 = actionscript3 - int has_version_8_action=0; - int has_version_9_action=0; - while(tag) { - /* FIXME: this doesn't find actionscript in buttons */ - if(tag->id == ST_DOACTION || tag->id == ST_DOINITACTION) - has_version_8_action=1; - if(tag->id == ST_DOABC) - has_version_9_action=1; - tag = tag->next; + if(swf->fileVersion >= 9) { + if ((!swf->firstTag || swf->firstTag->id != ST_SCENEDESCRIPTION) && + (!swf->firstTag || + !swf->firstTag->next || swf->firstTag->next->id != ST_SCENEDESCRIPTION) && + (!swf->firstTag || + !swf->firstTag->next || + !swf->firstTag->next->next || swf->firstTag->next->next->id != ST_SCENEDESCRIPTION)) + { + TAG*scene = swf_InsertTagBefore(swf, swf->firstTag,ST_SCENEDESCRIPTION); + swf_SetU16(scene, 1); + swf_SetString(scene, (U8*)"Scene 1"); + swf_SetU8(scene, 0); + } } - if(has_version_8_action && !has_version_9_action) - flags = 0x00; - - if (swf->firstTag && swf->firstTag->id != ST_FILEATTRIBUTES) - { - swf_SetU32(swf_InsertTagBefore(swf, swf->firstTag,ST_FILEATTRIBUTES),flags); + + if(swf->fileVersion >= 9) { + TAG*tag = swf->firstTag; + U32 flags = 0x08; // 16 = has symbolclass tag | 8 = actionscript3 | 1 = usenetwork + int has_version_8_action=0; + int has_version_9_action=0; + while(tag) { + /* FIXME: this doesn't find actionscript in buttons */ + if(tag->id == ST_DOACTION || tag->id == ST_DOINITACTION) + has_version_8_action=1; + if(tag->id == ST_DOABC) + has_version_9_action=1; + tag = tag->next; + } + if(has_version_8_action && !has_version_9_action) + flags = 0x00; + + if (swf->firstTag && swf->firstTag->id != ST_FILEATTRIBUTES) + { + swf_SetU32(swf_InsertTagBefore(swf, swf->firstTag,ST_FILEATTRIBUTES),flags); + } } } -- 1.7.10.4