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
10 #ifdef HAVE_SYS_STAT_H
\r
11 #include <sys/stat.h>
\r
16 #include "../lib/rfxswf.h"
\r
17 #include "../lib/args.h"
\r
19 char * filename = 0;
\r
21 /* idtab stores the ids which are defined in the file. This allows us
\r
22 to detect errors in the file. (i.e. ids which are defined more than
\r
26 struct options_t options[] =
\r
34 int args_callback_option(char*name,char*val)
\r
36 if(!strcmp(name, "V")) {
\r
37 printf("swfdump - part of %s %s\n", PACKAGE, VERSION);
\r
41 int args_callback_longoption(char*name,char*val)
\r
43 return args_long2shortoption(options, name, val);
\r
45 void args_callback_usage(char*name)
\r
47 printf("Usage: %s file.swf\n", name);
\r
49 int args_callback_command(char*name,char*val)
\r
52 fprintf(stderr, "Only one file allowed. You supplied at least two. (%s and %s)\n",
\r
59 int main (int argc,char ** argv)
\r
63 #ifdef HAVE_SYS_STAT_H
\r
64 struct stat statbuf;
\r
69 memset(idtab,0,65536);
\r
71 processargs(argc, argv);
\r
73 f = open(filename,O_RDONLY);
\r
77 perror("Couldn't open file: ");
\r
80 if FAILED(ReadSWF(f,&swf))
\r
82 fprintf(stderr,"%s is not a valid SWF file or contains errors.\n",filename);
\r
87 #ifdef HAVE_SYS_STAT_H
\r
89 if(statbuf.st_size != swf.FileSize)
\r
90 fprintf(stderr, "Error: Real Filesize (%d) doesn't match header Filesize (%d)",
\r
91 statbuf.st_size, swf.FileSize);
\r
96 printf("[HEADER] File version: %d\n", swf.FileVersion);
\r
97 printf("[HEADER] File size: %d\n", swf.FileSize);
\r
98 printf("[HEADER] Frame rate: %f\n",swf.FrameRate/256.0);
\r
99 printf("[HEADER] Frame count: %d\n",swf.FrameCount);
\r
100 printf("[HEADER] Movie width: %.3f\n",(swf.MovieSize.xmax-swf.MovieSize.xmin)/20.0);
\r
101 printf("[HEADER] Movie height: %.3f\n",(swf.MovieSize.ymax-swf.MovieSize.ymin)/20.0);
\r
103 tag = swf.FirstTag;
\r
106 printf("[%03x] %9d %s%s", tag->id, tag->len, prefix, getTagName(tag));
\r
107 if(isDefiningTag(tag)) {
\r
108 U16 id = GetDefineID(tag);
\r
109 printf(" defines id %04x", id);
\r
111 fprintf(stderr, "Error: Id %04x is defined more than once.\n", id);
\r
114 else if(tag->id == ST_PLACEOBJECT ||
\r
115 tag->id == ST_PLACEOBJECT2) {
\r
116 printf(" places id %04x at depth %04x", GetPlaceID(tag), GetDepth(tag));
\r
118 printf(" name \"%s\"",GetName(tag));
\r
120 else if(tag->id == ST_REMOVEOBJECT) {
\r
121 printf(" removes id %04x from depth %04x", GetPlaceID(tag), GetDepth(tag));
\r
123 else if(tag->id == ST_REMOVEOBJECT2) {
\r
124 printf(" removes object from depth %04x", GetDepth(tag));
\r
129 if(tag->id == ST_DEFINESPRITE)
\r
131 sprintf(prefix, " ");
\r
133 if(tag->id == ST_END)
\r
135 sprintf(prefix, "");
\r