2 Shows the structure of a swf file
\r
4 Part of the swftools package.
\r
6 Copyright (c) 2001 Matthias Kramm <kramm@quiss.org>
\r
8 This file is distributed under the GPL, see file COPYING for details */
\r
12 #include "../lib/rfxswf.h"
\r
13 #include "../lib/args.h"
\r
15 char * filename = 0;
\r
17 /* idtab stores the ids which are defined in the file. This allows us
\r
18 to detect errors in the file. (i.e. ids which are defined more than
\r
22 struct options_t options[] =
\r
30 int args_callback_option(char*name,char*val)
\r
32 if(!strcmp(name, "V")) {
\r
33 printf("swfdump - part of %s %s\n", PACKAGE, VERSION);
\r
37 int args_callback_longoption(char*name,char*val)
\r
39 return args_long2shortoption(options, name, val);
\r
41 void args_callback_usage(char*name)
\r
43 printf("Usage: %s file.swf\n", name);
\r
45 int args_callback_command(char*name,char*val)
\r
48 fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n",
\r
55 int main (int argc,char ** argv)
\r
62 memset(idtab,0,65536);
\r
64 processargs(argc, argv);
\r
66 f = open(filename,O_RDONLY);
\r
70 perror("Couldn't open file: ");
\r
73 if FAILED(ReadSWF(f,&swf))
\r
75 fprintf(stderr,"%s is not a valid SWF file or contains errors.\n",filename);
\r
84 printf("[%02x] %9d %s%s", tag->id, tag->len, prefix, getTagName(tag));
\r
85 if(isDefiningTag(tag)) {
\r
86 U16 id = GetDefineID(tag);
\r
87 printf(" defines id %04x", id);
\r
89 fprintf(stderr, "Error: Id %04x is defined more than once.\n", id);
\r
92 else if(tag->id == ST_PLACEOBJECT ||
\r
93 tag->id == ST_PLACEOBJECT2) {
\r
94 printf(" places id %04x at depth %04x", GetPlaceID(tag), GetDepth(tag));
\r
96 printf(" name \"%s\"",GetName(tag));
\r
98 else if(tag->id == ST_REMOVEOBJECT) {
\r
99 printf(" removes id %04x from depth %04x", GetPlaceID(tag), GetDepth(tag));
\r
101 else if(tag->id == ST_REMOVEOBJECT2) {
\r
102 printf(" removes object from depth %04x", GetDepth(tag));
\r
107 if(tag->id == ST_DEFINESPRITE)
\r
109 sprintf(prefix, " ");
\r
111 if(tag->id == ST_END)
\r
113 sprintf(prefix, "");
\r