git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix the "cloud" bug
[swftools.git]
/
src
/
swfdump.c
diff --git
a/src/swfdump.c
b/src/swfdump.c
index
0363218
..
572e890
100644
(file)
--- a/
src/swfdump.c
+++ b/
src/swfdump.c
@@
-7,7
+7,7
@@
This file is distributed under the GPL, see file COPYING for details */
This file is distributed under the GPL, see file COPYING for details */
-#define HAVE_STAT
+#include "../config.h"
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@
-24,6
+24,7
@@
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
+#include <stdarg.h>
#include "../lib/rfxswf.h"
#include "../lib/args.h"
#include "../lib/rfxswf.h"
#include "../lib/args.h"
@@
-216,17
+217,17
@@
void textcallback(int*glyphs, int nr, int fontid)
break;
}
}
break;
}
}
- if(font<0) {
- printf("\n");
- return; // todo: should we report this? (may only be that it's a definefont without fontinfo)
- }
for(t=0;t<nr;t++)
{
unsigned char a;
for(t=0;t<nr;t++)
{
unsigned char a;
- if(glyphs[t] >= fonts[font]->numchars)
- continue;
- a = fonts[font]->glyph2ascii[glyphs[t]];
+ if(font>=0) {
+ if(glyphs[t] >= fonts[font]->numchars)
+ continue;
+ a = fonts[font]->glyph2ascii[glyphs[t]];
+ } else {
+ a = glyphs[t];
+ }
if(a>=32)
printf("%c", a);
else
if(a>=32)
printf("%c", a);
else
@@
-356,10
+357,23
@@
void fontcallback1(U16 id,U8 * name)
}
void fontcallback2(U16 id,U8 * name)
}
void fontcallback2(U16 id,U8 * name)
-{ swf_FontExtract(&swf,id,&fonts[fontnum]);
+{
+ swf_FontExtract(&swf,id,&fonts[fontnum]);
fontnum++;
}
fontnum++;
}
+void dumperror(const char* format, ...)
+{
+ char buf[1024];
+ va_list arglist;
+
+ va_start(arglist, format);
+ vsprintf(buf, format, arglist);
+ va_end(arglist);
+
+ printf("==== Error: %s ====\n", buf);
+}
+
int main (int argc,char ** argv)
{
TAG*tag;
int main (int argc,char ** argv)
{
TAG*tag;
@@
-401,9
+415,9
@@
int main (int argc,char ** argv)
#ifdef HAVE_STAT
fstat(f, &statbuf);
#ifdef HAVE_STAT
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);
+ if(statbuf.st_size != swf.fileSize)
+ dumperror("Real Filesize (%d) doesn't match header Filesize (%d)",
+ statbuf.st_size, swf.fileSize);
#endif
close(f);
#endif
close(f);
@@
-469,7
+483,7
@@
int main (int argc,char ** argv)
char*name = swf_TagGetName(tag);
char myprefix[128];
if(!name) {
char*name = swf_TagGetName(tag);
char myprefix[128];
if(!name) {
- fprintf(stderr, "Error: Unknown tag:0x%03x\n", tag->id);
+ dumperror("Unknown tag:0x%03x", tag->id);
tag = tag->next;
continue;
}
tag = tag->next;
continue;
}
@@
-482,33
+496,51
@@
int main (int argc,char ** argv)
if(swf_isDefiningTag(tag)) {
U16 id = swf_GetDefineID(tag);
if(swf_isDefiningTag(tag)) {
U16 id = swf_GetDefineID(tag);
- printf(" defines id %04x", id);
+ printf(" defines id %04d", id);
if(idtab[id])
if(idtab[id])
- fprintf(stderr, "Error: Id %04x is defined more than once.\n", id);
+ dumperror("Id %04d is defined more than once.", id);
idtab[id] = 1;
}
else if(swf_isPseudoDefiningTag(tag)) {
U16 id = swf_GetDefineID(tag);
idtab[id] = 1;
}
else if(swf_isPseudoDefiningTag(tag)) {
U16 id = swf_GetDefineID(tag);
- printf(" adds information to id %04x", id);
+ printf(" adds information to id %04d", id);
if(!idtab[id])
if(!idtab[id])
- fprintf(stderr, "Error: Id %04x is not yet defined.\n", id);
+ dumperror("Id %04d is not yet defined.\n", id);
}
}
- else if(tag->id == ST_PLACEOBJECT ||
- tag->id == ST_PLACEOBJECT2) {
- printf(" places id %04x at depth %04x", swf_GetPlaceID(tag), swf_GetDepth(tag));
+ else if(tag->id == ST_PLACEOBJECT) {
+ printf(" places id %04d at depth %04x", swf_GetPlaceID(tag), swf_GetDepth(tag));
if(swf_GetName(tag))
printf(" name \"%s\"",swf_GetName(tag));
}
if(swf_GetName(tag))
printf(" name \"%s\"",swf_GetName(tag));
}
+ else if(tag->id == ST_PLACEOBJECT2) {
+ if(tag->data[0]&1)
+ printf(" moves");
+ else
+ printf(" places");
+
+ if(tag->data[0]&2)
+ printf(" id %04d",swf_GetPlaceID(tag));
+ else
+ printf(" object");
+
+ printf(" at depth %04d", swf_GetDepth(tag));
+ if(swf_GetName(tag))
+ printf(" name \"%s\"",swf_GetName(tag));
+ }
else if(tag->id == ST_REMOVEOBJECT) {
else if(tag->id == ST_REMOVEOBJECT) {
- printf(" removes id %04x from depth %04x", swf_GetPlaceID(tag), swf_GetDepth(tag));
+ printf(" removes id %04d from depth %04d", swf_GetPlaceID(tag), swf_GetDepth(tag));
}
else if(tag->id == ST_REMOVEOBJECT2) {
}
else if(tag->id == ST_REMOVEOBJECT2) {
- printf(" removes object from depth %04x", swf_GetDepth(tag));
+ printf(" removes object from depth %04d", swf_GetDepth(tag));
}
}
+ else if(tag->id == ST_STARTSOUND) {
+ printf(" starts id %04d", swf_GetPlaceID(tag));
+ }
else if(tag->id == ST_FRAMELABEL) {
printf(" \"%s\"", tag->data);
else if(tag->id == ST_FRAMELABEL) {
printf(" \"%s\"", tag->data);
- if(framelabel) {
- fprintf(stderr, "Error: Frame %d has more than one label\n",
+ if((framelabel && !issprite) ||
+ (spriteframelabel && issprite)) {
+ dumperror("Frame %d has more than one label",
issprite?spriteframe:mainframe);
}
if(issprite) spriteframelabel = tag->data;
issprite?spriteframe:mainframe);
}
if(issprite) spriteframelabel = tag->data;
@@
-557,7
+589,7
@@
int main (int argc,char ** argv)
if(tag->id == ST_DEFINESPRITE) {
sprintf(prefix, " ");
if(issprite) {
if(tag->id == ST_DEFINESPRITE) {
sprintf(prefix, " ");
if(issprite) {
- fprintf(stderr, "Error: Sprite definition inside a sprite definition");
+ dumperror("Sprite definition inside a sprite definition");
}
issprite = 1;
spriteframe = 0;
}
issprite = 1;
spriteframe = 0;
@@
-566,8
+598,9
@@
int main (int argc,char ** argv)
else if(tag->id == ST_END) {
*prefix = 0;
issprite = 0;
else if(tag->id == ST_END) {
*prefix = 0;
issprite = 0;
+ spriteframelabel = 0;
if(tag->len)
if(tag->len)
- fprintf(stderr, "Error: End Tag not empty");
+ dumperror("End Tag not empty");
}
else if(tag->id == ST_DOACTION && action) {
ActionTAG*actions;
}
else if(tag->id == ST_DOACTION && action) {
ActionTAG*actions;
@@
-601,6
+634,7
@@
int main (int argc,char ** argv)
}
}
tag = tag->next;
}
}
tag = tag->next;
+ fflush(stdout);
}
swf_FreeTags(&swf);
}
swf_FreeTags(&swf);