X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fswfdump.c;h=df55e9be31fcc26174ace1713fd6b99dee2e57ee;hb=89174f31c34e6a727efe9600b4a81c90dc63e23a;hp=fc9fda1b944f4a3983985582ec3c96aa6a7785ef;hpb=fc554a43712b76d16b41ec77dd311b4a78b1ef6b;p=swftools.git diff --git a/src/swfdump.c b/src/swfdump.c index fc9fda1..df55e9b 100644 --- a/src/swfdump.c +++ b/src/swfdump.c @@ -7,10 +7,14 @@ This file is distributed under the GPL, see file COPYING for details */ +#ifdef HAVE_SYS_STAT_H +#include +#endif +#include #include #include #include "../lib/rfxswf.h" -#include "args.h" +#include "../lib/args.h" char * filename = 0; @@ -19,16 +23,28 @@ char * filename = 0; once */ char idtab[65536]; +struct options_t options[] = +{ + {"v","verbose"}, + {"V","version"}, + {0,0} +}; + + int args_callback_option(char*name,char*val) { + if(!strcmp(name, "V")) { + printf("swfdump - part of %s %s\n", PACKAGE, VERSION); + exit(0); + } } int args_callback_longoption(char*name,char*val) { + return args_long2shortoption(options, name, val); } void args_callback_usage(char*name) { printf("Usage: %s file.swf\n", name); - printf("\n"); } int args_callback_command(char*name,char*val) { @@ -44,6 +60,9 @@ int main (int argc,char ** argv) { SWF swf; TAG*tag; +#ifdef HAVE_SYS_STAT_H + struct stat statbuf; +#endif int f; char prefix[128]; prefix[0] = 0; @@ -64,12 +83,27 @@ int main (int argc,char ** argv) close(f); exit(1); } + +#ifdef HAVE_SYS_STAT_H + fstat(f, &statbuf); + if(statbuf.st_size != swf.FileSize) + fprintf(stderr, "Error: Real Filesize (%d) doesn't match header Filesize (%d)", + statbuf.st_size, swf.FileSize); +#endif + close(f); + printf("[HEADER] File version: %d\n", swf.FileVersion); + printf("[HEADER] File size: %d\n", swf.FileSize); + printf("[HEADER] Frame rate: %f\n",swf.FrameRate/256.0); + printf("[HEADER] Frame count: %d\n",swf.FrameCount); + printf("[HEADER] Movie width: %.3f\n",(swf.MovieSize.xmax-swf.MovieSize.xmin)/20.0); + printf("[HEADER] Movie height: %.3f\n",(swf.MovieSize.ymax-swf.MovieSize.ymin)/20.0); + tag = swf.FirstTag; while(tag) { - printf("[%02x] %s%s", tag->id, prefix, getTagName(tag)); + printf("[%03x] %9d %s%s", tag->id, tag->len, prefix, getTagName(tag)); if(isDefiningTag(tag)) { U16 id = GetDefineID(tag); printf(" defines id %04x", id);