1 /**************************************************************************** 2 * 3 * Copyright (C) 2005-2006 "Stuart R. Anderson" <anderson@netsweng.com> 4 * 5 * This program is free software; you can redistribute it and/or modify dumpBytes(FILE * f)6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * 19 ****************************************************************************/ 20 21 #include "blocks/blocktypes.h" 22 #include "parser.h" 23 #include "read.h" 24 25 struct SWFBlock 26 { 27 SWFBlocktype type; 28 char *name; 29 SWFParseFunc parser; 30 }; 31 32 #define BlockType( block ) \ 33 { block, #block, parse##block, } 34 35 static struct SWFBlock blocks[] = { 36 BlockType (SWF_CHARACTERSET), 37 BlockType (SWF_DEFINEBITS), 38 BlockType (SWF_DEFINEBITSJPEG2), 39 BlockType (SWF_DEFINEBITSJPEG3), 40 BlockType (SWF_DEFINEBITSPTR), 41 BlockType (SWF_DEFINEBUTTON), 42 BlockType (SWF_DEFINEBUTTON2), 43 BlockType (SWF_DEFINEBUTTONCXFORM), 44 BlockType (SWF_DEFINEBUTTONSOUND), 45 BlockType (SWF_DEFINECOMMANDOBJ), 46 BlockType (SWF_DEFINEEDITTEXT), 47 BlockType (SWF_DEFINEFONT), 48 BlockType (SWF_DEFINEFONT2), 49 BlockType (SWF_DEFINEFONT3), 50 BlockType (SWF_DEFINEFONTINFO), 51 BlockType (SWF_DEFINEFONTINFO2), 52 BlockType (SWF_CSMTEXTSETTINGS), 53 BlockType (SWF_DEFINEFONTNAME), 54 BlockType (SWF_DEFINEFONTALIGNZONES), 55 BlockType (SWF_DEFINELOSSLESS), 56 BlockType (SWF_DEFINELOSSLESS2), 57 BlockType (SWF_DEFINEMORPHSHAPE), 58 BlockType (SWF_DEFINEMORPHSHAPE2), 59 BlockType (SWF_DEFINESHAPE), main(int argc,char * argv[])60 BlockType (SWF_DEFINESHAPE2), 61 BlockType (SWF_DEFINESHAPE3), 62 BlockType (SWF_DEFINESHAPE4), 63 BlockType (SWF_DEFINESOUND), 64 BlockType (SWF_DEFINESPRITE), 65 BlockType (SWF_DEFINETEXT), 66 BlockType (SWF_DEFINETEXT2), 67 BlockType (SWF_DEFINETEXTFORMAT), 68 BlockType (SWF_DEFINEVIDEO), 69 BlockType (SWF_DEFINEVIDEOSTREAM), 70 BlockType (SWF_DOACTION), 71 BlockType (SWF_ENABLEDEBUGGER), 72 BlockType (SWF_ENABLEDEBUGGER2), 73 BlockType (SWF_END), 74 BlockType (SWF_EXPORTASSETS), 75 BlockType (SWF_FONTREF), 76 BlockType (SWF_FRAMELABEL), 77 BlockType (SWF_FRAMETAG), 78 BlockType (SWF_FREEALL), 79 BlockType (SWF_FREECHARACTER), 80 BlockType (SWF_GENCOMMAND), 81 BlockType (SWF_IMPORTASSETS), 82 BlockType (SWF_IMPORTASSETS2), 83 BlockType (SWF_INITACTION), 84 BlockType (SWF_JPEGTABLES), 85 BlockType (SWF_NAMECHARACTER), 86 BlockType (SWF_PATHSAREPOSTSCRIPT), 87 BlockType (SWF_PLACEOBJECT), 88 BlockType (SWF_PLACEOBJECT2), 89 BlockType (SWF_PLACEOBJECT3), 90 BlockType (SWF_PREBUILT), 91 BlockType (SWF_PREBUILTCLIP), 92 BlockType (SWF_PROTECT), 93 BlockType (SWF_REMOVEOBJECT), 94 BlockType (SWF_REMOVEOBJECT2), 95 BlockType (SWF_SERIALNUMBER), 96 BlockType (SWF_SETBACKGROUNDCOLOR), 97 BlockType (SWF_SHOWFRAME), 98 BlockType (SWF_SOUNDSTREAMBLOCK), 99 BlockType (SWF_SOUNDSTREAMHEAD), 100 BlockType (SWF_SOUNDSTREAMHEAD2), 101 BlockType (SWF_STARTSOUND), 102 BlockType (SWF_STARTSOUND2), 103 BlockType (SWF_SYNCFRAME), 104 BlockType (SWF_VIDEOFRAME), 105 BlockType (SWF_REFLEX), 106 BlockType (SWF_FILEATTRIBUTES), 107 BlockType (SWF_METADATA), 108 BlockType (SWF_SCRIPTLIMITS), 109 BlockType (SWF_DEFINESCALINGGRID), 110 BlockType (SWF_SETTABINDEX), 111 BlockType (SWF_DOABC), 112 BlockType (SWF_SYMBOLCLASS), 113 BlockType (SWF_DEFINESCENEANDFRAMEDATA), 114 BlockType (SWF_DEFINEBINARYDATA), 115 BlockType (SWF_DEBUGID), 116 }; 117 118 static int numBlocks = sizeof (blocks) / sizeof (struct SWFBlock); 119 120 const char * 121 blockName (SWFBlocktype header) 122 { 123 int i; 124 125 for (i = 0; i < numBlocks; i++) 126 { 127 if (blocks[i].type == header) 128 { 129 return blocks[i].name; 130 } 131 } 132 return "Unknown Block Type"; /* Should never get here */ 133 134 } 135 136 SWF_Parserstruct * 137 blockParse (FILE *f, int length, SWFBlocktype header) 138 { 139 int i; 140 141 for (i = 0; i < numBlocks; i++) 142 { 143 if (blocks[i].type == header) 144 { 145 return blocks[i].parser(f,length); 146 } 147 } 148 return parseSWF_UNKNOWNBLOCK(f, length); 149 } 150