2 Shows the structure of a swf file
4 Part of the swftools package.
6 Copyright (c) 2001 Matthias Kramm <kramm@quiss.org>
8 This file is distributed under the GPL, see file COPYING for details */
12 #ifdef HAVE_SYS_STAT_H
18 #ifdef HAVE_SYS_TYPES_H
19 #include <sys/types.h>
27 #include "../lib/rfxswf.h"
28 #include "../lib/args.h"
32 /* idtab stores the ids which are defined in the file. This allows us
33 to detect errors in the file. (i.e. ids which are defined more than
38 struct options_t options[] =
47 int args_callback_option(char*name,char*val)
49 if(!strcmp(name, "V")) {
50 printf("swfdump - part of %s %s\n", PACKAGE, VERSION);
53 else if(name[0]=='a') {
58 printf("Unknown option: -%s\n", name);
63 int args_callback_longoption(char*name,char*val)
65 return args_long2shortoption(options, name, val);
67 void args_callback_usage(char*name)
69 printf("Usage: %s [-a] file.swf\n", name);
70 printf("-h , --help\t\t\t Print help and exit\n");
71 printf("-a , --action\t\t\t Disassemble action tags\n");
72 printf("-V , --version\t\t\t Print program version and exit\n");
74 int args_callback_command(char*name,char*val)
77 fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n",
85 char* testfunc(char*str)
87 printf("%s: %s\n", what, str);
91 int main (int argc,char ** argv)
101 memset(idtab,0,65536);
103 processargs(argc, argv);
107 fprintf(stderr, "You must supply a filename.\n");
111 f = open(filename,O_RDONLY);
115 perror("Couldn't open file: ");
118 if FAILED(swf_ReadSWF(f,&swf))
120 fprintf(stderr, "%s is not a valid SWF file or contains errors.\n",filename);
127 if(statbuf.st_size != swf.FileSize)
128 fprintf(stderr, "Error: Real Filesize (%d) doesn't match header Filesize (%d)",
129 statbuf.st_size, swf.FileSize);
134 printf("[HEADER] File version: %d\n", swf.fileVersion);
135 printf("[HEADER] File size: %ld\n", swf.fileSize);
136 printf("[HEADER] Frame rate: %f\n",swf.frameRate/256.0);
137 printf("[HEADER] Frame count: %d\n",swf.frameCount);
138 printf("[HEADER] Movie width: %.3f\n",(swf.movieSize.xmax-swf.movieSize.xmin)/20.0);
139 printf("[HEADER] Movie height: %.3f\n",(swf.movieSize.ymax-swf.movieSize.ymin)/20.0);
144 char*name = swf_GetTagName(tag);
146 fprintf(stderr, "Error: Unknown tag:0x%03x\n", tag->id);
150 printf("[%03x] %9ld %s%s", tag->id, tag->len, prefix, swf_GetTagName(tag));
152 if(swf_isDefiningTag(tag)) {
153 U16 id = swf_GetDefineID(tag);
154 printf(" defines id %04x", id);
156 fprintf(stderr, "Error: Id %04x is defined more than once.\n", id);
159 else if(tag->id == ST_PLACEOBJECT ||
160 tag->id == ST_PLACEOBJECT2) {
161 printf(" places id %04x at depth %04x", swf_GetPlaceID(tag), swf_GetDepth(tag));
162 if(swf_TagGetName(tag))
163 printf(" name \"%s\"",swf_TagGetName(tag));
165 else if(tag->id == ST_REMOVEOBJECT) {
166 printf(" removes id %04x from depth %04x", swf_GetPlaceID(tag), swf_GetDepth(tag));
168 else if(tag->id == ST_REMOVEOBJECT2) {
169 printf(" removes object from depth %04x", swf_GetDepth(tag));
174 if(tag->id == ST_DEFINESPRITE) {
175 sprintf(prefix, " ");
177 else if(tag->id == ST_END) {
180 else if(tag->id == ST_DOACTION && action) {
183 sprintf(myprefix, " %s", prefix);
185 actions = swf_GetActions(tag);
187 swf_DumpActions(actions, myprefix);
190 ActionEnumerateURLs(actions, testfunc);
192 ActionEnumerateStrings(actions, testfunc);
194 ActionEnumerateTargets(actions, testfunc);*/