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
36 int args_callback_longoption(char*name,char*val)
\r
38 return args_long2shortoption(options, name, val);
\r
40 void args_callback_usage(char*name)
\r
42 printf("Usage: %s file.swf\n", name);
\r
44 int args_callback_command(char*name,char*val)
\r
47 fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n",
\r
54 int main (int argc,char ** argv)
\r
61 memset(idtab,0,65536);
\r
63 processargs(argc, argv);
\r
65 f = open(filename,O_RDONLY);
\r
69 perror("Couldn't open file: ");
\r
72 if FAILED(ReadSWF(f,&swf))
\r
74 fprintf(stderr,"%s is not a valid SWF file or contains errors.\n",filename);
\r
83 printf("[%02x] %s%s", tag->id, prefix, getTagName(tag));
\r
84 if(isDefiningTag(tag)) {
\r
85 U16 id = GetDefineID(tag);
\r
86 printf(" defines id %04x", id);
\r
88 fprintf(stderr, "Error: Id %04x is defined more than once.\n", id);
\r
91 else if(tag->id == ST_PLACEOBJECT ||
\r
92 tag->id == ST_PLACEOBJECT2) {
\r
93 printf(" places id %04x at depth %04x", GetPlaceID(tag), GetDepth(tag));
\r
95 printf(" name \"%s\"",GetName(tag));
\r
97 else if(tag->id == ST_REMOVEOBJECT) {
\r
98 printf(" removes id %04x from depth %04x", GetPlaceID(tag), GetDepth(tag));
\r
100 else if(tag->id == ST_REMOVEOBJECT2) {
\r
101 printf(" removes object from depth %04x", GetDepth(tag));
\r
106 if(tag->id == ST_DEFINESPRITE)
\r
108 sprintf(prefix, " ");
\r
110 if(tag->id == ST_END)
\r
112 sprintf(prefix, "");
\r